Skip to content

A basic template written to solve the entry-level challenges of the project, suitable for FastAPI beginners to quickly get started.

License

Notifications You must be signed in to change notification settings

bamboostrip/fastapi-template

Repository files navigation

FastAPI Project Template

🇨🇳 中文文档 | 🇺🇸 English

This project is a basic template for FastAPI, created to help beginners quickly start their own FastAPI projects.

Project Overview

  • 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.

Directory Structure

├── 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

Quick Start

  1. Install dependencies (recommended: uv):
    uv sync
  2. Start the project:
    uv run main.py
  3. Build and run with Docker:
    docker-compose up --build

Features

  • FastAPI basic project structure for rapid development
  • SQLAlchemy ORM support
  • Alembic database migration
  • APScheduler scheduled tasks
  • Unified response and error handling
  • Containerization support

For Whom

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!


License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A basic template written to solve the entry-level challenges of the project, suitable for FastAPI beginners to quickly get started.

Resources

License

Stars

Watchers

Forks

Packages

No packages published