🇨🇳 中文文档 | 🇺🇸 English
This project is a basic template for FastAPI, created to help beginners quickly start their own FastAPI projects.
- Uses uv for dependency management and running. It is recommended to install dependencies with
uv sync. - Start the project with
uv run main.py. - Supports Docker containerized development, with ready-to-use Dockerfile and docker-compose configuration.
- Includes a basic structure and template for FastAPI development.
- Integrates SQLAlchemy as the ORM layer for database operations.
- Uses Alembic for database migration and version control.
- Adds scheduled task support (based on APScheduler). You can integrate it with database initialization to avoid multiple entry points.
- Provides unified response data format (response) for frontend-backend communication.
- Handles and intercepts common errors in a unified way.
- Simulated database table models for easy extension.
- Simulated CRUD (Create, Read, Update, Delete) operations for the database.
├── app/
│ ├── api/ # API routes
│ ├── core/ # Config, scheduler, security, etc.
│ ├── crud/ # Database operation encapsulation
│ ├── db/ # Database models, session, etc.
│ ├── models/ # ORM models
│ ├── schemas/ # Pydantic schemas
│ ├── services/ # Business logic
│ └── utils/ # Utilities, response, exception, etc.
├── alembic/ # Alembic migrations
├── data/ # Database files
├── tests/ # Test cases
├── main.py # FastAPI app entry
├── Dockerfile # Docker build file
├── docker-compose.yml # Docker Compose config
├── pyproject.toml # Project dependencies
└── README.md # Project documentation
- Install dependencies (recommended: uv):
uv sync
- Start the project:
uv run main.py
- Build and run with Docker:
docker-compose up --build
- FastAPI basic project structure for rapid development
- SQLAlchemy ORM support
- Alembic database migration
- APScheduler scheduled tasks
- Unified response and error handling
- Containerization support
This template is suitable for FastAPI beginners or developers who want to quickly scaffold a new project.
Hope this template helps you get started with FastAPI development faster!
This project is licensed under the MIT License. See the LICENSE file for details.