Skip to content

AhsanHasan/fastapi-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Project Template

A production-ready FastAPI project template following industry best practices. This template provides a solid foundation for building scalable and maintainable APIs.

Features

  • 🎯 Modular Structure: Clear separation of concerns with layered architecture
  • 🔐 Authentication & Authorization: JWT-based auth system
  • 📝 API Documentation: Automatic Swagger/OpenAPI documentation
  • 🔄 Database Integration: SQLAlchemy ORM with migrations
  • 🎭 Environment Management: Configuration via environment variables
  • 📊 Logging: Structured logging setup
  • Testing: Pytest setup with fixtures and examples
  • 🔍 Input Validation: Pydantic models for request/response validation
  • 🛠 Dependency Injection: Clean dependency management
  • 🚀 Docker Support: Containerization ready

Project Structure

├── app/
│   ├── api/
│   │   ├── v1/
│   │   │   ├── endpoints/
│   │   │   └── dependencies.py
│   │   └── deps.py
│   ├── core/
│   │   ├── config.py
│   │   ├── security.py
│   │   └── logging.py
│   ├── db/
│   │   ├── base.py
│   │   ├── session.py
│   │   └── models/
│   ├── models/
│   ├── schemas/
│   ├── services/
│   └── utils/
├── tests/
│   ├── conftest.py
│   ├── test_api/
│   └── test_services/
├── alembic/
│   ├── env.py
│   └── versions/
├── scripts/
├── .env.example
├── .gitignore
├── docker-compose.yml
├── Dockerfile
├── requirements.txt
└── main.py

Quick Start

  1. Clone the template:
git clone https://github.com/yourusername/fastapi-template.git
cd fastapi-template
  1. Create and activate virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: .\venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your configurations
  1. Run the application:
uvicorn main:app --reload

Visit http://localhost:8000/docs for the Swagger documentation.

Development Guidelines

  1. API Versioning: Place new endpoints under app/api/v1/endpoints/
  2. Database Models: Add SQLAlchemy models in app/db/models/
  3. Schemas: Define Pydantic models in app/schemas/
  4. Business Logic: Implement services in app/services/
  5. Configuration: Add new settings in app/core/config.py
  6. Testing: Write tests in the tests/ directory

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages