FastAPI backend example with REST API, Docker support, and best practices
Modern REST API built with FastAPI demonstrating:
- Clean architecture with separated concerns
- Pydantic schemas for validation
- Docker containerization
- In-memory data store (demo)
- Type hints and modern Python
- RESTful endpoints
- ✅ FastAPI framework
- ✅ Pydantic models for validation
- ✅ CRUD operations (Create, Read, Delete)
- ✅ Dockerized application
- ✅ Health check endpoint
- ✅ Auto-generated OpenAPI docs
fastapi-backend-example/
├── README.md
├── requirements.txt
├── Dockerfile
└── app/
├── main.py # Application entry point
├── routes.py # API endpoints
├── schemas.py # Pydantic models
└── models.py # Domain models
pip install -r requirements.txt
uvicorn app.main:app --reloadAPI will be available at: http://localhost:8000
docker build -t fastapi-backend .
docker run -p 8000:8000 fastapi-backendGET /health- Check API status
GET /items- List all itemsPOST /items- Create new itemGET /items/{id}- Get item by IDDELETE /items/{id}- Delete item
Interactive API documentation available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Python 3.11+
- FastAPI 0.115.0
- Uvicorn 0.30.6