A FastAPI complete application with nice features and tests.
- Senior organization support
- Database support
- Scheduler jobs support
- Test, mock and code coverage support
- Service layer support
- Pydantic support
- Rate limiter support
- CORS support
- Static files support
- Docker support (single and compose)
- Ready for production
- Support for Python version from 3.10 to 3.14
APIs are essential for various types of applications, including:
- Mobile applications
- Progressive Web Applications (PWA)
- Single Page Applications (SPA)
- Microservices
- Internet of Things (IoT) applications
- Desktop applications that require online functionalities
- JAMstack websites and applications
- Low-Code and No-Code services like Bubble, FlutterFlow and others
To start locally execute:
uvicorn main:app --host 0.0.0.0 --port 8000 --log-level debug --reloador
make startTo build and start docker in single mode:
docker build -f Dockerfile.web -t fastapi-app .
docker run --rm -v ./:/app -p 8000:8000 fastapi-appor
make docker-single-build
make docker-single-startTo use a different database url when run:
docker run --rm -v ./:/app -p 8000:8000 -e DATABASE_URL="sqlite+aiosqlite:///./other.db" fastapi-appTo build and start docker compose with application and database:
docker compose build
docker compose up -dor
make docker-compose-build
make docker-compose-startTo stop docker compose:
docker compose downor
make docker-compose-stopTo run tests execute:
python3 -m pytestor
make testTo run tests execute with code coverage:
python3 -m pytest --cov=. --maxfail=1 tests/or
make test-covOnce the API server is running, you can test your APIs by accessing the following URL:
http://localhost:8000/docs
The project includes a sample database model with the following structure:
CREATE TABLE my_model (
id SERIAL PRIMARY KEY,
field1 VARCHAR(255) NOT NULL,
field2 BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);This model demonstrates:
- Auto-incrementing primary key (
id) - String field with maximum length of 255 characters (
field1) - Boolean field with default value (
field2) - Automatic timestamp for record creation (
created_at) - Automatic timestamp for record updates (
updated_at)
The database is configured to use SQLite by default, but you can easily switch to other databases by modifying the DATABASE_URL environment variable.
Copyright (c) 2024-2026, Paulo Coutinho