4.7 KiB
linkpulse
A project for monitoring websites, built with FastAPI and React.
Structure
A description of the project's folder structure.
/backendA backend server using FastAPI, managed with Poetry./backend/linkpulseA python module containing the FastAPI application, database models, migration scripts, and more./backend/migrationsMigration scripts forpeewee; most of this is generated automatically.
/frontendA frontend server using React, managed with pnpm, built with Vite./frontend/CaddyfileA Caddy configuration file used for proxying API requests to the backend server via Private Networking (Railway)./frontend/nixpacks.tomlConfigures the frontend build process for Nixpacks, enabling the use of Caddy for deployment.
Setup
Windows WSL is strongly recommended for development. See here for setup instructions.
The following instructions were written for Ubuntu 22.04 LTS, the primary (default) target for WSL.
Frontend
- Install Node.js 22.x
I recommend asdf or nvm for managing this (although asdf is superior in my opinion, and it's tool/language agnostic). Alternatives are available though.
Assuming you're using Bash/Zsh & Git, you'll need to add this to your bashrc file: . "$HOME/.asdf/asdf.sh". Shell completions are recommended, but optional. Refer to documentation here for further detail.
Once added, restart your terminal and cd into the project root.
asdf plugin add nodejs
asdf install
This installs the version of Node.js specified in .tool-versions.
Note
If you use Node.js for other projects, you may want to install the version you need & set it as the global version via
asdf global nodejs <version>orasdf install nodejs latest:<version>. If you don't care,asdf install latest nodejsalso works.
- Install
pnpmwithnpm install -g pnpm cd frontend- Install frontend dependencies with
pnpm install - Start the frontend server with
./run.sh
Backend
-
- Install Python 3.12 (
pyenv install 3.12)
- Install Python 3.12 (
-
Install
poetry- Requires
pipx, see here. You will NOT have this by default. This is NOTpip, do not install either withpip. - Install with
pipx install poetry
- Requires
-
Install backend dependencies with
poetry install. -
Start the backend server with
./run.sh -
(optional) Install the Railway CLI
- Fastest installation is via shell:
bash <(curl -fsSL cli.new)- Alternatives found here.
- This will let us skip creating a local
.envfile, as well as keeping your database URL synchronized. - You will have to run
railway loginupon install as well asrailway linkin the backend directory.
- Fastest installation is via shell:
Usage
A full stack (frontend and backend), automatically reloading project is possible, but it requires two terminals.
- Open a terminal in each respective directory (
/backendand/frontend). - Execute
./run.shto start the development server for each.- For the backend, you'll either need to have the
railwayCLI installed or a.envfile with the database URL.- See
.env.examplefor a list of all available environment variables.
- See
- For the frontend, the defaults are already sufficient.
- For the backend, you'll either need to have the
Warning
The
run.shscripts provide default environment variables internally; if you want to run the commands manually, you'll need to provide them to.envfiles or the command line.