Wauplin's picture
Wauplin HF Staff
backend boilerplate
0b85fad verified
# Pydantic + FastAPI + SQLModel + SQLite
This template provides a minimal setup to get FastAPI working with a sqlite database.
[SQLModel](https://sqlmodel.tiangolo.com/) is used on top of Pydantic and SQLAlchemy to easily define database objects.
## Getting started
### Install dependencies
First, create a new virtual environment for the project:
```bash
uv venv
```
This will create an environment `.venv/` that you can instantiate like this:
```bash
source .venv/bin/activate
```
Once that's done, install the dependencies like this:
```
uv pip install -e ".[dev]"
```
This will install the project in editable mode, meaning your changes will be reflected in the server.
The dev dependencies are also installed for code formatting.
### Run server
Run:
```bash
make dev
```
Backend server should be available on localhost:
```
INFO: Will watch for changes in these directories: ['/home/wauplin/projects/docker-space-fastapi-react/backend']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [355687] using StatReload
INFO: Started server process [355689]
INFO: Waiting for application startup.
INFO: Application startup complete.
```
Hot reload is enabled, meaning backend is reloaded on each file update.
### Code quality
You can run the formatter with:
```bash
make style
```
and then test everything's fine with:
```bash
make quality
```