Skip to main content

backend-service Template

A Python FastAPI template for building APIs, webhooks, agent backends, and data processing services.

Quick Start

Visit http://localhost:8080/docs to see the OpenAPI documentation.

Specifications

Project Structure

Key Files

main.py

Adding Routes

Create new routes in app/api/v1/:
Register in main.py:

Business Logic

Keep business logic in app/services/:
Use in routes:

Database Integration

Enable SQLite persistence:
This adds:
  • Persistent volume at /data
  • SQLAlchemy with SQLite
  • Auto-migrations on startup

Creating Models

Using the Database

Environment Variables

Declare required env vars in runtm.yaml:
Set secrets locally:

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

Routes should only handle HTTP concerns. Put business logic in services/.
Use FastAPI’s Depends() for database sessions, auth, etc.
Use Pydantic models for request/response validation.
Use the provided app.core.logging for JSON logs.