Skip to content

sajidahmed66/fastapi-api-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Starter Template (Scalable)

Overview This repository provides a clean, scalable starter template for building a FastAPI backend service.

Key features

  • FastAPI app factory with lifespan events
  • Environment-based configuration via Pydantic Settings
  • Structured logging
  • Versioned API router (v1)
  • Health and readiness endpoints
  • CORS configuration
  • Placeholders for DB session and models (SQLAlchemy ready)

Project structure

  • app/
    • main.py
    • core/
      • config.py
      • logging.py
    • api/
      • router.py
      • v1/
        • endpoints/
          • health.py
    • dependencies/
      • common.py
    • db/
      • session.py
    • models/
      • init.py
    • schemas/
      • common.py

Getting started

  1. Create a virtual environment and install dependencies: python -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt

  2. Configure environment variables (optional): cp .env.example .env

    Edit .env as needed

  3. Run the app: uvicorn app.main:app --reload

  4. Test endpoints:

Environment variables (.env)

  • PROJECT_NAME: Service name
  • ENV: Environment (development|staging|production)
  • DEBUG: true/false
  • API_V1_PREFIX: API prefix (default: /api/v1)
  • CORS_ORIGINS: Comma-separated origins

Docker (optional) Build and run with Docker:

  • docker build -t fastapi-starter .
  • docker run -p 8000:8000 --env-file .env fastapi-starter

Notes

  • Extend app/api/v1/endpoints with your own routers.
  • Implement DB connection logic in app/db/session.py when needed.
  • Configure logging levels and formats in app/core/logging.py.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors