backend-service Template
A Python FastAPI template for building APIs, webhooks, agent backends, and data processing services.Quick Start
http://localhost:8080/docs to see the OpenAPI documentation.
Specifications
Project Structure
Key Files
main.py
Adding Routes
Create new routes inapp/api/v1/:
main.py:
Business Logic
Keep business logic inapp/services/:
Database Integration
Enable SQLite persistence:- Persistent volume at
/data - SQLAlchemy with SQLite
- Auto-migrations on startup
Creating Models
Using the Database
Environment Variables
Declare required env vars inruntm.yaml:
Local Development
Testing
Deployment
Use Cases
REST API
Build JSON APIs with automatic OpenAPI documentation
Webhook Handler
Process webhooks from Stripe, GitHub, etc.
AI Agent Backend
LLM integration, tool execution, agent orchestration
Data Processing
ETL pipelines, data transformation, batch jobs
Best Practices
Keep routes thin
Keep routes thin
Routes should only handle HTTP concerns. Put business logic in
services/.Use dependency injection
Use dependency injection
Use FastAPI’s
Depends() for database sessions, auth, etc.Type everything
Type everything
Use Pydantic models for request/response validation.
Log structured data
Log structured data
Use the provided
app.core.logging for JSON logs.