The frontend is built with Vite, React, TypeScript, TanStack Query, TanStack Router, Tailwind CSS, and shadcn/ui.
From the project root, install the dependencies and start the frontend development server:
bun install
bun run devThen open http://localhost:5173/ in your browser.
Run uv run bash scripts/prestart.sh and uv run fastapi dev from the backend directory, with PostgreSQL running in Docker Compose. See ../development.md for the complete setup.
To serve the frontend with FastAPI, run bun run build from the frontend directory and open http://localhost:8000.
Check frontend/package.json to see the other available commands.
If you are developing an API-only app and want to remove the frontend, you can do it easily:
-
Remove the
./frontenddirectory. -
In the
backend/app/main.pyfile, remove theapp.frontend()call. -
In the
backend/Dockerfilefile, remove the frontend build stage and theCOPY --from=frontend-buildinstruction. -
In the
compose.override.ymlfile, remove theplaywrightservice. -
In the
.github/workflows/deploy.ymlfile, remove the Set up Bun, Install frontend dependencies, and Build frontend steps. -
In the
.fastapicloudignorefile, remove the!backend/app/frontend/entry.
Done, you now have an API-only app. 🤓
- From the project root, run the script:
bash ./scripts/generate-client.sh- Commit the changes.
-
Make sure the backend is running.
-
Download the OpenAPI JSON file from
http://localhost:8000/api/v1/openapi.jsonand copy it to a new fileopenapi.jsonat the root of thefrontenddirectory. -
To generate the frontend client, run:
bun run generate-client- Commit the changes.
Regenerate the client whenever backend changes affect the OpenAPI schema.
By default, the built frontend uses the same origin as the FastAPI app. If you want to use a remote API while running the Vite development server, you can set the environment variable VITE_API_URL to the URL of the remote API. For example, you can set it in the frontend/.env file:
VITE_API_URL=https://my-domain.example.comThen, when you run the frontend, it will use that URL as the base URL for the API.
The frontend code is structured as follows:
frontend/src- The main frontend code.frontend/public- Static assets.frontend/src/client- The generated OpenAPI client.frontend/src/components- The components of the frontend, including the shadcn/ui components infrontend/src/components/ui.frontend/src/hooks- Custom hooks.frontend/src/lib- Shared frontend utilities.frontend/src/routes- The frontend routes and pages.
The frontend includes initial end-to-end tests using Playwright. To run the tests, you need to have the Docker Compose stack running. Start the stack with the following command:
docker compose run --rm backend bash scripts/prestart.sh
docker compose up -d --wait backendThen, you can run the tests with the following command:
bunx playwright testYou can also run your tests in UI mode to see the browser and interact with it running:
bunx playwright test --uiTo stop and remove the Docker Compose stack and clean the data created in tests, use the following command:
docker compose down -vTo update the tests, navigate to the tests directory and modify the existing test files or add new ones as needed.
For more information on writing and running Playwright tests, refer to the official Playwright documentation.