A clean, fast, and production-ready example of a CRUD API built with FastAPI, PostgreSQL, and Redis caching.
- Full async CRUD operations
- Smart Redis caching for GET endpoints (with automatic cache invalidation on create/update/delete)
- PostgreSQL via Tortoise ORM + asyncpg
- Pydantic v2 models & strict validation
- Dependency injection & clean project structure
- Managed with uv – the blazingly fast Python package manager
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/users |
List all users |
POST |
/api/v1/users |
Create a new user |
GET |
/api/v1/users/{id} |
Get user by ID (cached) |
PUT |
/api/v1/users/{id} |
Update user (invalidates cache) |
DELETE |
/api/v1/users/{id} |
Delete user (invalidates cache) |
git clone https://github.com/Fsoky/fastapi-crud.git
cd fastapi-crud
# Using uv (recommended)
uv sync
# Run
uv run -m src.__main__- Tests (pytest)
- Docker