A mini production-style REST API built with FastAPI for tracking issues. This project demonstrates core FastAPI concepts including routing, data validation with Pydantic, CRUD operations, and file-based persistence.
- Full CRUD operations for issues
- Data validation with Pydantic schemas
- UUID generation for issue IDs
- Priority levels (low, medium, high)
- Status tracking (open, in_progress, closed)
- JSON file-based storage
- Auto-generated API documentation
- Custom middleware (timing, CORS)
- Python 3.9+
- Clone the repository:
git clone https://github.com/bradtraversy/fastapi-issue-tracker.git
cd fastapi-issue-tracker- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install "fastapi[standard]"Start the development server:
fastapi dev main.pyThe API will be available at http://localhost:8000
Once running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/health |
Health check |
| GET | /api/v1/issues |
Get all issues |
| GET | /api/v1/issues/{id} |
Get issue by ID |
| POST | /api/v1/issues |
Create a new issue |
| PUT | /api/v1/issues/{id} |
Update an issue |
| DELETE | /api/v1/issues/{id} |
Delete an issue |
curl -X POST http://localhost:8000/api/v1/issues \
-H "Content-Type: application/json" \
-d '{
"title": "Fix login bug",
"description": "Users cannot log in with special characters in password",
"priority": "high"
}'{
"id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Fix login bug",
"description": "Users cannot log in with special characters in password",
"priority": "high",
"status": "open"
}curl -X PUT http://localhost:8000/api/v1/issues/{id} \
-H "Content-Type: application/json" \
-d '{
"status": "in_progress"
}'This project includes custom middleware to demonstrate the middleware pattern in FastAPI.
Adds an X-Process-Time header to all responses showing how long the request took to process:
# app/middleware/timing.py
async def timing_middleware(request: Request, call_next):
start = time.perf_counter()
response = await call_next(request)
response.headers["X-Process-Time"] = f"{time.perf_counter() - start:.4f}s"
return responseEnables cross-origin requests from frontend applications:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)fastapi-issue-tracker/
├── main.py # Application entry point
├── app/
│ ├── schemas.py # Pydantic models for validation
│ ├── storage.py # JSON file storage functions
│ ├── middleware/
│ │ └── timing.py # Response timing middleware
│ └── routes/
│ └── issues.py # Issue CRUD endpoints
├── data/
│ └── issues.json # Data storage (auto-created)
└── docs/
├── crash_course.md # Written FastAPI tutorial
└── crash_course_excalidraw.png # Architecture diagram from video
The docs folder contains supplementary learning materials:
- crash_course.md - A written FastAPI crash course covering all the concepts used in this project
- crash_course_excalidraw.png - The Excalidraw architecture diagram from the YouTube video
MIT