Skip to content

Backend

FastAPI application with a modular architecture, custom ORM, and auto-generated CRUD API.

Key concepts

Environment — the central application object. Contains models, apps, settings and manages service lifecycle.

Service — base class for modules. Each module (chat, security, users...) is a Service with startup(), shutdown(), post_init() methods.

DotORM — async ORM with declarative models, auto-generated DDL, and CRUD API.

Entry Points

backend/main.py
from contextlib import asynccontextmanager
from fastapi import FastAPI

@asynccontextmanager
async def lifespan(application: FastAPI):
    """Application lifecycle — start and stop services."""
    env = Environment(Settings, Models, Apps)
    application.state.env = env

    await env.setup_services()
    await env.start_services_before(application)
    await env.load_routers(application)
    await env.start_services_after(application)
    await env.start_post_init(application)

    yield

    await env.stop_services(application)

app = FastAPI(lifespan=lifespan)

Sections

Section Description
Architecture Environment, Service, lifecycle
DotORM Models, fields, queries, relations
Modules Chat, Security, and other CRM modules
Testing pytest, fixtures, integration tests