A comprehensive FastAPI template with Azure cloud services integration, Agent-based workflows, and multi-service API architecture.
- Multiple API Services: Items management, file operations, restaurant discovery, speech transcription, and agent-based chat
- Azure Cloud Integration: CosmosDB, Blob Storage, OpenAI, AI Speech, and Application Insights
- Agent Workflows: LangGraph and Azure AI Foundry integration for conversational AI
- Real-time Communication: WebSocket-based chat functionality
- Comprehensive Logging: Configurable log levels with structured error handling
- Testing & Quality: 37+ automated tests with logging and monitoring
- Container Ready: Docker support with multi-stage builds
- Python 3.10+
- uv (recommended) or pip
- GNU Make
# Clone the repository
git clone https://github.com/ks6088ts-labs/template-fastapi.git
cd template-fastapi
# Install dependencies
make install-deps-dev
# Copy environment template
cp .env.template .env
# Edit .env with your Azure service credentials
# Development server with hot reload
make dev
# Production server
make run
# Run tests
make test
# View documentation
make docs-serve
The API will be available at http://localhost:8000 with interactive documentation at http://localhost:8000/docs.
- Items API (
/items/
): CRUD operations for item management - Files API (
/files/
): File upload, download, and management with Azure Blob Storage - Restaurants API (
/foodies/
): Restaurant discovery with geospatial search - Speech API (
/speeches/
): Batch transcription jobs using Azure AI Speech
- LangGraph Agents (
/agents/langgraph/
): AI agents with custom tools - Azure AI Foundry (
/agents/azure-ai-foundry/
): Thread-based conversations - Chat Interface (
/chats/
): Real-time WebSocket chat with agent integration
- Demo Endpoints (
/demos/
): Dice rolling, flaky endpoints for testing - Health & Monitoring: Application Insights integration with OpenTelemetry
Key configuration options in .env
:
# Logging
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR, CRITICAL
# Azure OpenAI
AZURE_OPENAI_ENDPOINT=https://<name>.openai.azure.com/
AZURE_OPENAI_API_KEY=<key>
AZURE_OPENAI_MODEL_CHAT=gpt-4o
# Azure Storage & Database
AZURE_COSMOSDB_CONNECTION_STRING=<connection-string>
AZURE_BLOB_STORAGE_CONNECTION_STRING=<connection-string>
# Monitoring
APPLICATIONINSIGHTS_CONNECTION_STRING=<connection-string>
See .env.template
for complete configuration options.
# Build image
make docker-build
# Run container
docker run -p 8000:8000 --env-file .env ks6088ts/template-fastapi:latest
template_fastapi/
├── routers/ # API route handlers
│ ├── agents/ # Agent-based endpoints
│ ├── chats.py # WebSocket chat
│ ├── demos.py # Demo endpoints
│ ├── files.py # File operations
│ ├── foodies.py # Restaurant API
│ ├── items.py # Items CRUD
│ └── speeches.py # Speech transcription
├── models/ # Pydantic data models
├── repositories/ # Data access layer
├── settings/ # Configuration management
└── templates/ # Jinja2 templates
# Run all tests
make test
# Run with coverage
pytest --cov=template_fastapi
# Run specific test file
pytest tests/test_api.py -v
# Format code
make format
# Lint code
make lint
# Apply auto-fixes
make fix
The application supports Azure Functions deployment:
# Export requirements
uv export --format requirements-txt --no-dev --no-hashes --output-file requirements.txt
# Deploy to Azure Functions
func azure functionapp publish <function-app-name>
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes with tests
- Run quality checks (
make ci-test
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.