Skip to content

Project structure

AgentBI follows the same documentation style as AegisAI: visual layout diagrams plus path reference tables. This page maps the repository so you can find API routes, services, frontend pages, and ops scripts quickly.

Repository layout

flowchart TB
    ROOT[agentbi/]

    ROOT --> APP[app/]
    ROOT --> FE[frontend/]
    ROOT --> DOCS[docs/]
    ROOT --> SCRIPTS[scripts/]
    ROOT --> SDK[sdk/]
    ROOT --> OPS[ops configs]

    APP --> MODELS[models/]
    APP --> API[api/v1/]
    APP --> SVCS[services/]
    APP --> CORE[core/]
    APP --> SCH[schemas/]
    APP --> PR[prompts/]

    FE --> PUB[public/]
    FE --> SRC[src/]
    SRC --> PAGES[pages/]
    SRC --> JS[js/]
    SRC --> CSS[css/]

    DOCS --> ASSETS[assets/brand/]
    OPS --> DC[docker-compose.yml]
    OPS --> DEP[deploy.sh]
    OPS --> ENV[.env.example]
    OPS --> MK[mkdocs.yml]

Backend (app/)

flowchart LR
    subgraph Entrypoint
        MAIN[main.py]
        CFG[config.py]
        DB[database.py]
        ST[startup.py]
    end

    subgraph API["api/v1"]
        AUTH[auth / sso / api-keys]
        TEN[tenants / tenant_domain]
        BILL[billing]
        ING[ingest]
        MET[metrics]
        DASH[dashboard]
        ROI[roi]
        CMP[compare]
        REP[reports]
        AGT[agents]
        HL[health / version]
    end

    subgraph Domain
        M[models/]
        S[services/]
        C[core/]
        SC[schemas/]
    end

    MAIN --> API
    API --> S
    S --> M
    API --> C
    API --> SC
    ST --> DB
    MAIN --> CFG
Path Responsibility
app/main.py FastAPI app, CORS, lifespan, Sentry, exception handlers
app/config.py Settings from environment
app/database.py Async SQLAlchemy engine, table init, Timescale hooks
app/startup.py Admin bootstrap, optional demo seed
app/models/ ORM: agents, events, metrics, reports, users, tenants, dashboards
app/api/v1/ REST under /api/v1 (auth, billing, tenant domain, analytics)
app/services/ Aggregation, ROI, SSO, tenants, ingest, export
app/core/ Security, RBAC, entitlements, Redis, domain validation, version
app/schemas/ Pydantic request/response models
app/prompts/ Deterministic executive summary text

Frontend (frontend/)

flowchart LR
    INDEX[index.html<br/>landing] --> LOGIN[login.html]
    LOGIN --> LAYOUT[layout.js]
    LAYOUT --> DASH[dashboard.js]
    LAYOUT --> AGENTS[agents.js]
    LAYOUT --> ROI[roi.js]
    LAYOUT --> CMP[compare.js]
    LAYOUT --> REP[reports.js]
    DASH --> CHARTS[charts.js]
    AGENTS --> APIJS[api.js]
    ROI --> APIJS
    PUB[public/<br/>logo + favicon] --> INDEX
Path Responsibility
frontend/index.html Public demo landing
frontend/login.html Sign-in page (password, demo button, Google SSO)
frontend/demo/login.html Prefill demo sign-in
frontend/src/pages/ Dashboard, agents, ROI, compare, reports, users, pricing, settings
frontend/src/js/ Page logic, Chart.js helpers, auth session, billing/domain UI, demo mode
frontend/src/css/style.css Executive UI styles
frontend/src/css/landing.css Public demo landing
frontend/public/ Logo and favicon assets
frontend/nginx.conf / Dockerfile.prod Landing + login + demo + SPA + /api reverse proxy

Docs, SDK, and scripts

Path Responsibility
docs/ MkDocs Material content (this site)
docs/assets/brand/ Logo / icon for docs
mkdocs.yml Site nav, theme, Mermaid fences
sdk/agentbi.py Minimal Python client for event ingest
scripts/backup_postgres.sh Pre-migrate / cron DB dump
scripts/restore_postgres.sh Restore from dump
scripts/rollback.sh Roll back to previous SHA images
scripts/check_lockfile.sh requirements vs lockfile gate
scripts/vps/ Host swapfile + safe Docker prune
scripts/seed_demo_data.py Demo agents + events
alembic/versions/ Schema migrations (004_tenant_custom_domain, …)
requirements-lock.txt Pinned transitive deps for Docker/CI
docker-compose.yml / .prod.yml Local / Traefik production stacks
deploy.sh Safe deploy: backup → SHA build → migrate → health
VERSION Deployed Git SHA (written by deploy)
.env.example Environment template

Runtime topology

flowchart TB
    subgraph Docker Compose
        PG[(postgres:15)]
        RD[(redis:7)]
        API[api<br/>FastAPI + Uvicorn]
        WEB[frontend<br/>nginx]
        TR[traefik]
    end

    TR --> WEB
    TR --> API
    WEB -->|/api| API
    API --> PG & RD

In production the frontend is static nginx assets behind the shared Traefik edge (agentops-edge); the API speaks to PostgreSQL and Redis on an internal Docker network (no published host ports). See Deploy and Architecture.