A modern Python monorepo template for platform engineering projects, featuring FastAPI and Typer with best practices built-in.
- Platform Agnostic: Docker and devcontainer support for consistent development across all platforms
- Monorepo Structure: Organized workspace with separate API and CLI projects
- Modern Tooling:
- Type Safety: Fully typed codebase with mypy/pyright configuration
- Best Practices: Pre-configured linting, formatting, testing, and containerization
.
βββ .devcontainer/ # VS Code dev container configuration
β βββ devcontainer.json
βββ .github/
β βββ workflows/
β βββ ci.yml # GitHub Actions CI/CD
βββ api/ # FastAPI application
β βββ src/api/
β β βββ main.py # FastAPI app
β β βββ config.py # Settings management
β βββ tests/
β β βββ test_main.py # API tests
β βββ pyproject.toml
β βββ README.md
βββ cli/ # Typer CLI application
β βββ src/cli/
β β βββ main.py # CLI app
β β βββ config.py # CLI configuration
β βββ tests/
β β βββ test_main.py # CLI tests
β βββ pyproject.toml
β βββ README.md
βββ scripts/ # Platform-specific dev scripts
β βββ dev.bat # Windows batch script
β βββ dev.ps1 # Windows PowerShell script
β βββ README.md
βββ Dockerfile # Multi-stage Docker build
βββ docker-compose.yml # Docker Compose for development
βββ .dockerignore
βββ pyproject.toml # Workspace configuration
βββ Makefile # macOS/Linux shortcuts
βββ DOCKER.md # Docker guide
βββ CONTRIBUTING.md # Contributing guidelines
βββ README.md
Choose one of the following approaches:
- Docker Desktop (macOS, Windows, Linux)
- VS Code with Dev Containers extension (optional but recommended)
- Python 3.11 or higher
- uv package manager
Why Docker? Platform-agnostic, consistent environment, matches production, zero Python installation needed.
-
Clone the repository
git clone <your-repo-url> cd platform-engineering-template
-
Start with Docker Compose
# Start the API docker-compose up api # Or start development environment docker-compose up dev # Run CLI docker-compose run cli hello --name "Docker"
-
Access the API
- Visit http://localhost:8000/docs for interactive API documentation
VS Code Users: Open the project in VS Code and click "Reopen in Container" when prompted. Everything will be set up automatically!
Click to expand local development instructions
-
Install uv
# macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
-
Clone and Install
git clone <your-repo-url> cd platform-engineering-template uv sync
-
Run the API
cd api uv run uvicorn api.main:app --reload -
Run the CLI
cd cli uv run platform-cli --help
With Docker (all platforms):
# Run all tests
docker-compose run dev uv run pytest
# Run with coverage
docker-compose run dev uv run pytest --cov=api --cov=cli
# Or inside the dev container
docker-compose run dev bash
uv run pytestLocal development:
# Run all tests
uv run pytest
# Run API tests only
cd api && uv run pytest
# Run CLI tests only
cd cli && uv run pytest
# Run with coverage
uv run pytest --cov=api --cov=cliWith Docker:
# Check code style
docker-compose run dev uv run ruff check .
# Fix and format
docker-compose run dev uv run ruff format .
docker-compose run dev uv run ruff check --fix .Local development:
# Check code style
uv run ruff check .
# Fix auto-fixable issues
uv run ruff check --fix .
# Format code
uv run ruff format .With Docker:
docker-compose run dev uv run mypy api/src cli/srcLocal development:
# Run mypy
uv run mypy api/src cli/src
# Or use pyright
uv run pyrightWhen adding dependencies, you'll need to rebuild Docker images:
With Docker:
# 1. Add dependency to pyproject.toml
cd api # or cli
uv add <package-name>
# 2. Rebuild Docker image
docker-compose buildLocal development:
# Add to API
cd api
uv add <package-name>
# Add to CLI
cd cli
uv add <package-name>
# Add dev dependencies
uv add --dev <package-name>The API uses FastAPI with the following features:
- Automatic OpenAPI documentation
- Pydantic models for request/response validation
- Settings management with pydantic-settings
- Health check endpoint
- Example REST endpoints
See api/README.md for more details.
The CLI uses Typer with the following features:
- Rich terminal output with colors
- Auto-completion support
- Type-safe command definitions
- Comprehensive help text
See cli/README.md for more details.
The API can be configured via environment variables or a .env file:
API_HOST=0.0.0.0
API_PORT=8000
DEBUG=falseThe CLI stores configuration in ~/.platform-cli/ by default.
This template supports multiple development workflows. Choose what works best for your team:
Best for: Platform engineering, team consistency, CI/CD alignment
Pros:
- β Platform-agnostic (works on macOS, Windows, Linux)
- β Zero local Python setup required
- β Consistent environment across team
- β Matches production environment
- β Easy CI/CD integration
Quick commands:
docker-compose up api # Start API
docker-compose run dev bash # Interactive dev shell
docker-compose run dev uv run pytest # Run testsVS Code: Install Dev Containers extension and click "Reopen in Container"
Best for: Quick iterations, offline development, resource constraints
macOS/Linux - Using Make:
make install # Install all dependencies
make test # Run all tests
make lint # Run ruff linting
make format # Format code with ruff
make type-check # Run mypy type checking
make run-api # Run the API serverWindows - Using Scripts:
# PowerShell
.\scripts\dev.ps1 install
.\scripts\dev.ps1 test
.\scripts\dev.ps1 run-api
# Or Command Prompt
scripts\dev.bat install
scripts\dev.bat test
scripts\dev.bat run-apiDirect commands (all platforms):
uv sync # Install dependencies
uv run pytest # Run tests
uv run ruff check . # LintSee scripts/README.md for more details on local development helpers.
This template is ready for CI/CD integration. Example GitHub Actions workflow:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: uv sync
- name: Run linting
run: uv run ruff check .
- name: Run type checking
run: uv run mypy api/src cli/src
- name: Run tests
run: uv run pytest- Use Docker for Development: Ensures consistency across team and matches production
- Type Hints: Always use type hints for function parameters and return values
- Testing: Write tests for all new functionality
- Documentation: Keep docstrings up to date
- Code Style: Run ruff before committing
- Dependencies: Keep dependencies minimal and up to date
- Dev Containers: Use VS Code dev containers for the best experience
- Update project names in
pyproject.tomlfiles - Rename directory structures
- Update import statements
- Update CLI entry point in
cli/pyproject.toml
Create new directories under the root and add them to the workspace in the root pyproject.toml:
[tool.uv.workspace]
members = ["api", "cli", "new-package"]MIT License - feel free to use this template for your projects.
- DOCKER.md - Comprehensive Docker and dev container guide
- CONTRIBUTING.md - Contributing guidelines
- api/README.md - API documentation
- cli/README.md - CLI documentation