The FastAPI Best Architecture skill implements a structured three-tier architecture for FastAPI applications. It is intended for developers looking to standardize their FastAPI projects with best practices in design.
$ npx skills add https://github.com/fastapi-practices/skills --skill fbaThe FastAPI Best Architecture skill equips developers with comprehensive guidance for building scalable, standardized FastAPI applications following enterprise-level patterns. It covers three-tier architecture specifications, CRUD and service layer conventions, API router organization, and Pydantic schema standards. The skill includes references for JWT authentication, RBAC permission configuration, database model design, and plugin development at both app and extend levels. Developers use it to maintain consistent coding styles, perform code reviews, and implement database migrations while adhering to established best practices.
Install using the provided command and follow the official documentation for implementation.
Standardizing FastAPI project structures
Improving code maintainability
Facilitating collaboration among developers
$ npx skills add https://github.com/fastapi-practices/skills --skill fbagit clone https://github.com/fastapi-practices/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Design a FastAPI application using a clean three-tier architecture for [COMPANY]'s [INDUSTRY] project. The architecture should include: 1) A well-structured `models/` directory for SQLAlchemy or Pydantic models, 2) A `services/` layer for business logic, 3) A `routers/` directory for API endpoints, and 4) Proper dependency injection for database and external services. Use [DATA] as the sample data model. Include a README.md with setup instructions and example API calls.
```markdown
# FastAPI Three-Tier Architecture for Acme Corp's Inventory System
## Project Structure
```
acme-inventory/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app initialization
│ ├── models/
│ │ ├── __init__.py
│ │ ├── item.py # SQLAlchemy model for inventory items
│ │ └── schemas.py # Pydantic models for request/response
│ ├── services/
│ │ ├── __init__.py
│ │ ├── item_service.py # Business logic for inventory items
│ │ └── database.py # Database connection management
│ └── routers/
│ ├── __init__.py
│ ├── items.py # API endpoints for inventory items
│ └── health.py # Health check endpoint
├── tests/
│ ├── test_items.py
│ └── conftest.py
├── requirements.txt
└── README.md
## Key Features Implemented
- **Three-tier separation**: Models (data), Services (logic), Routers (API)
- **Dependency injection**: Database session management via FastAPI's Depends
- **Pydantic validation**: Request/response schemas with type hints
- **SQLAlchemy ORM**: For database operations
- **Health check endpoint**: `/health` for monitoring
## Example API Calls
```bash
# Create an inventory item
curl -X POST "http://localhost:8000/items/" \
-H "Content-Type: application/json" \
-d '{"name": "Wireless Mouse", "quantity": 50, "price": 29.99}'
# Get all inventory items
curl "http://localhost:8000/items/"
# Get a specific item
curl "http://localhost:8000/items/1"
# Update an item
curl -X PUT "http://localhost:8000/items/1" \
-H "Content-Type: application/json" \
-d '{"quantity": 45}'
# Delete an item
curl -X DELETE "http://localhost:8000/items/1"
```
```Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan