Featured

Python FastAPI CLAUDE.md Template

Complete CLAUDE.md for FastAPI backend projects

Category:templates
Type:template
Difficulty:intermediate
Language:Markdown
python
api
beginner

Description

Comprehensive CLAUDE.md template for Python FastAPI projects. Includes API structure, dependency injection patterns, database integration with SQLAlchemy, authentication setup, and testing guidelines.

Content

Resource Content
# FastAPI Project

## Overview
Python backend API built with FastAPI framework.

## Tech Stack
- Framework: FastAPI
- Language: Python 3.11+
- Database: PostgreSQL + SQLAlchemy
- Validation: Pydantic v2
- Testing: pytest

## Key Commands
```bash
# Development
uvicorn main:app --reload --port 8000

# Testing
pytest -v
pytest --cov=app tests/

# Linting
ruff check .
mypy .

# Database
alembic upgrade head
alembic revision --autogenerate -m "description"
```

## Project Structure
```
app/
├── main.py           # App entry point
├── api/
│   ├── routes/       # Route handlers
│   └── dependencies/ # DI dependencies
├── core/
│   ├── config.py     # Settings
│   └── security.py   # Auth utilities
├── models/           # SQLAlchemy models
├── schemas/          # Pydantic schemas
├── services/         # Business logic
└── tests/            # Test files
```

## Conventions
- Use type hints everywhere
- Dependency injection for services
- Separate schemas for Create/Update/Response
- Use async/await for I/O operations

## Important Notes
- API docs at `/docs` (Swagger) and `/redoc`
- Use `settings.py` for configuration
- Alembic for database migrations