Bumps [@tanstack/router-devtools](https://github.com/TanStack/router/tree/HEAD/packages/router-devtools) from 1.157.17 to 1.159.10. - [Release notes](https://github.com/TanStack/router/releases) - [Commits](https://github.com/TanStack/router/commits/v1.159.10/packages/router-devtools) --- updated-dependencies: - dependency-name: "@tanstack/router-devtools" dependency-version: 1.159.10 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
FastAPI Project - Frontend
The frontend is built with Vite, React, TypeScript, TanStack Query, TanStack Router and Tailwind CSS.
Requirements
Quick Start
bun install
bun run dev
- Then open your browser at http://localhost:5173/.
Notice that this live server is not running inside Docker, it's for local development, and that is the recommended workflow. Once you are happy with your frontend, you can build the frontend Docker image and start it, to test it in a production-like environment. But building the image at every change will not be as productive as running the local development server with live reload.
Check the file package.json to see other available options.
Removing the frontend
If you are developing an API-only app and want to remove the frontend, you can do it easily:
-
Remove the
./frontenddirectory. -
In the
compose.ymlfile, remove the whole service / sectionfrontend. -
In the
compose.override.ymlfile, remove the whole service / sectionfrontendandplaywright.
Done, you have a frontend-less (api-only) app. 🤓
If you want, you can also remove the FRONTEND environment variables from:
.env./scripts/*.sh
But it would be only to clean them up, leaving them won't really have any effect either way.
Generate Client
Automatically
- Activate the backend virtual environment.
- From the top level project directory, run the script:
bash ./scripts/generate-client.sh
- Commit the changes.
Manually
-
Start the Docker Compose stack.
-
Download the OpenAPI JSON file from
http://localhost/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.
Notice that everytime the backend changes (changing the OpenAPI schema), you should follow these steps again to update the frontend client.
Using a Remote API
If you want to use a remote API, 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://api.my-domain.example.com
Then, when you run the frontend, it will use that URL as the base URL for the API.
Code Structure
The frontend code is structured as follows:
frontend/src- The main frontend code.frontend/src/assets- Static assets.frontend/src/client- The generated OpenAPI client.frontend/src/components- The different components of the frontend.frontend/src/hooks- Custom hooks.frontend/src/routes- The different routes of the frontend which include the pages.
End-to-End Testing with Playwright
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 up -d --wait backend
Then, you can run the tests with the following command:
bunx playwright test
You can also run your tests in UI mode to see the browser and interact with it running:
bunx playwright test --ui
To stop and remove the Docker Compose stack and clean the data created in tests, use the following command:
docker compose down -v
To 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.