masterzdran.fastapi.project.accelerator 1.0.0

Prefix Reserved
dotnet new install masterzdran.fastapi.project.accelerator::1.0.0
                    
This package contains a .NET Template Package you can call from the shell/command line.

FastAPI Project Template

A production-ready FastAPI project template featuring:

  • Modular service structure
  • Azure AD JWT authentication and role-based authorization
  • OpenTelemetry logging and tracing
  • Environment-based configuration
  • Docker support
  • Pre-commit hooks and type checking
  • Example health and secure endpoints

Project Structure

src/
  main.py                # FastAPI app entrypoint
  config/                # App configuration and settings
  authorization/         # Azure AD auth, user/role models
  features/              # Modular service features (health, secure, etc.)
  observability/         # Logging and tracing setup
static/                  # Static assets (e.g., logo, favicon)
tests/                   # Unit tests
Dockerfile
docker-compose.yml
requirements.txt
.env / sample.env
.pre-commit-config.yaml

Setup Instructions

Prerequisites

  • Python 3.11.9
  • Docker (optional, for containerized deployment)

Installation

  1. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Copy sample.env to .env and fill in required environment variables.


Running the Application

  • Start the FastAPI app:
    uvicorn src.main:app --reload
    
  • Access the API at http://127.0.0.1:8000
  • Swagger UI: /docs
  • ReDoc: /redoc

Running with Docker

  1. Build the Docker image:
    docker build -t fastapi-project .
    
  2. Run the container:
    docker run -p 8000:80 fastapi-project
    

Running Tests

python -m unittest discover -s tests

Debugging

  • Use the provided VSCode launch configuration (.vscode/launch.json).

Pre-commit Hooks

  1. Install hooks:
    pre-commit install
    
  2. Run hooks manually:
    pre-commit run --all-files
    

Configuration


Authentication & Authorization


Logging and Tracing


Example Endpoints

  • Health check: /api/v1/healthcheck
  • Secure endpoint (requires Azure AD auth): /api/v1/secure

License

This project is licensed under the MIT License.

  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 195 5/20/2025