Based on A Production-First Approach to AI Engineering - a methodology for building reliable AI systems.
The Problem: Most AI projects fail when moving from prototype to production. Research notebooks that work brilliantly in development fail catastrophically under real-world conditionsβlatency spikes, cost spirals, non-deterministic failures, and maintenance nightmares.
The Root Cause: The AI industry focuses 90% on model development and 10% on the infrastructure needed for production. This ratio should be reversed. Production AI systems require engineering discipline, not just algorithmic innovation.
The Solution: This template provides a production-ready foundation for AI projects, embodying the principle that "Research optimizes for possibility. Engineering optimizes for reliability."
A modern Python foundation designed for AI systems that need to work reliably in production:
- Modern Python Tooling - Python 3.12+, FastAPI, Pydantic, type hints throughout
- Production Logging - Structured JSON logging with correlation tracking and dual-mode rendering
- Development Automation - Pre-configured linting, formatting, testing, and validation
- Production-Ready Structure - Organized for maintainability and scaling
- Comprehensive Testing - Unit, functional, and integration test patterns (21+ logging tests included)
- CI/CD Ready - GitHub Actions, pre-commit hooks, semantic versioning
- Documentation Standards - Clear guides for development and deployment
This isn't another ML experiment templateβit's an engineering foundation for AI systems that need to work reliably at scale.
# Clone the production-ready foundation
git clone <repository-url> my-ai-service
cd my-ai-service
# Set up the complete development environment
make init
# Verify everything works
make validate-branchYou now have a production-ready Python service foundation. Add your AI logic on top of this reliable base.
Research Approach:
- Optimize for accuracy and novel algorithms
- Success = high F1 scores, paper publications
- Acceptable to fail fast and iterate
- Focus on the happy path
Production-First Approach:
- Optimize for reliability and maintainability
- Success = uptime, cost efficiency, user satisfaction
- Must handle edge cases gracefully
- Plan for failure from the start
In production AI systems:
- 10% of your code is the actual AI/ML logic
- 90% is infrastructure: validation, monitoring, error handling, cost controls, testing
This template provides that crucial 90% foundation.
# Environment management
make init # Complete development setup
make sync # Update dependencies
make clean-env # Reset environment
# Code quality
make format # Auto-format code
make lint # Fix linting issues
make type-check # Validate type hints
make validate-branch # Run all checks before committing
# Testing
make test # Standard test suite
make test-unit # Fast unit tests
make test-functional # Feature tests
make test-integration # Integration tests
make test-all # Complete test suiteai-base-template/
βββ src/ # Your service code goes here
β βββ __init__.py
β βββ main.py # Simple starting point with logging integration
β βββ logging.py # Production structured logging system
βββ tests/ # Comprehensive test suite
β βββ test_main.py # Example test patterns
β βββ test_logging.py # 21+ logging system tests
βββ research/ # Notebooks and experiments
β βββ EDA.ipynb # Exploratory work stays here
βββ Makefile # All automation commands
βββ pyproject.toml # Modern Python configuration
βββ CLAUDE.md # Detailed development guide
Start with a solid engineering foundation while learning AI concepts. The template provides the safety rails you're accustomed to in production systems.
Stop reinventing infrastructure. Focus on your models while using battle-tested patterns for the production wrapper.
Give your team a consistent, production-ready starting point that embodies engineering best practices from day one.
This template includes a production-grade structured logging system built with structlog that handles the observability requirements of real-world AI systems.
Development Mode - Human-readable format optimized for local debugging:
22:45:00 [INFO] api.handlers: Processing request [status_code=200, duration_ms=150, user_id=user-123] [id:req-abc1]Production Mode - Structured JSON for monitoring and analytics:
{
"timestamp": "2025-08-31T22:45:00.123Z",
"level": "info",
"logger": "src.api.handlers",
"message": "Processing request",
"context": "default",
"extra": {
"status_code": 200,
"duration_ms": 150,
"user_id": "user-123",
"correlation_id": "req-abc-123"
}
}- Correlation ID Tracking - Automatically trace requests across your entire system
- Context Isolation - Prevent data leakage between concurrent requests and operations
- Smart Field Organization - Separates standard fields from custom data for optimal readability
- Environment-Driven Configuration - Dynamic log levels and format switching via environment variables
- Edge Case Handling - Graceful handling of long values, special characters, and null data
See src/main.py for a complete demonstration of the logging system in action, including context binding, multi-function logging, and both development and production formatting modes.
- A Production-First Approach to AI Engineering - The article that inspired this template
- Google's Rules for ML - Engineering discipline for ML systems
- Hidden Technical Debt in ML Systems - Foundational NIPS paper
- FastAPI - Modern Python web framework
- Pydantic - Data validation using type annotations
- structlog - Structured logging for production systems
- uv - Modern Python package management
This template embodies battle-tested patterns from production AI systems. When contributing, prioritize:
- Reliability over features
- Simplicity over cleverness
- Documentation over assumptions
- Tests over trust
Apache License 2.0 - See LICENSE file for details.
Remember: The hardest part of AI isn't the algorithmsβit's making them work reliably in production. This template gives you a head start on that challenge.
"The best AI is the AI that works."