A comprehensive FastAPI application demonstrating core concepts including asynchronous operations, request validation with Pydantic, error handling, and system diagnostics.
This project showcases:
- Advanced FastAPI Concepts: Routing, middleware, dependency injection
- Asynchronous Programming: Async/await patterns for non-blocking I/O operations
- Data Validation: Pydantic models for request/response validation with email support
- API Organization: Modular routing with separate routers for different domains
- Error Handling: Comprehensive error logging and status tracking
- System Diagnostics: Health checks and error monitoring endpoints
- Create, retrieve, and manage support tickets
- Async database and audit service simulations
- Email validation for ticket submissions
- Monitor recent critical errors
- System diagnostics and health status
- Python 3.14 or higher
- uv (fast Python package manager)
- Docker (optional, for containerized deployment)
-
Clone the repository
git clone https://github.com/yskulkarni/fastapi-tutorial.git cd fastapi-tutorial -
Install dependencies with uv
uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv pip install -r pyproject.toml
-
Run the application
uvicorn main:app --reload
The API will be available at
http://localhost:8000
Once the server is running, access:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
docker build -t fastapi-tutorial .docker run -p 8000:8000 fastapi-tutorialThe application will be accessible at http://localhost:8000
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"pytestpytest --cov.
├── main.py # FastAPI application entry point
├── config.py # Configuration and shared state
├── schemas.py # Pydantic data models
├── conftest.py # Pytest configuration
├── test_main.py # Test suite
├── routers/
│ ├── __init__.py
│ ├── tickets.py # Tickets API endpoints
│ └── system.py # System diagnostics endpoints
├── Dockerfile # Docker configuration
├── .dockerignore # Docker build exclusions
├── pyproject.toml # Project metadata and dependencies
└── README.md # This file
- FastAPI: Modern web framework for building APIs
- Uvicorn: ASGI web server
- Pydantic: Data validation using Python type annotations
- pytest: Testing framework
- httpx: Async HTTP client for testing
- anyio: Async compatibility layer
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.