Skip to main content

Architecture overview

ContentsVision is a two-tier web application with an asynchronous AI processing pipeline. This page is the map: the stack, the repo layout, the runtime topology, and how requests and jobs flow. The following pages drill into each layer.

Tech stack​

LayerTechnology
FrontendNext.js 14 (App Router), React 18, TypeScript, Tailwind CSS, Framer Motion, TanStack Virtual
BackendPython 3.11, FastAPI, SQLAlchemy 2 (async), Pydantic v2
DatabaseSQLite via aiosqlite (async)
Job queueRedis + ARQ (app/worker.py) when REDIS_URL is set; FastAPI background tasks otherwise
MediaFFmpeg (via ffmpeg-python), Pillow, OpenCV (headless), PyMuPDF (reading photos out of PDFs)
AIOpenRouter (Claude vision and analysis), Deepgram Nova-2 (transcription)
AuthAdjustSquare SSO, JSON Web Tokens (python-jose, HS256)
AnalyticsPostHog (product analytics + session replay), optional, off by default
Error trackingSentry (sentry-sdk[fastapi] on the backend and worker, @sentry/nextjs on the frontend), off unless a DSN is set
TelemetryOpenTelemetry to Grafana (traces, logs, metrics), optional, off by default
Exportspandas + openpyxl (Excel), hand-rolled CSV
DeploymentLaravel Forge (one server per instance), Docker Compose, nginx, Cloudflare Tunnel

Repository layout​

contentsvision/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI app, router registration, CORS, health checks
│ │ ├── worker.py # ARQ worker that runs pipelines off the queue
│ │ ├── api/routes/ # HTTP endpoints, one router per file (see the API reference)
│ │ ├── core/ # config, database, queue, security (JWT), auth_deps, actor,
│ │ │ # ownership, observability, telemetry, sentry, analytics
│ │ ├── models/ # SQLAlchemy ORM models (claim, room, job, inventory, team, user,
│ │ │ # hierarchy, views, training, integration, insured_link, activity, ...)
│ │ ├── schemas/ # Pydantic request/response shapes
│ │ ├── services/ # pipeline, video_processor, audio_processor, claude_analyzer,
│ │ │ # numbering, billing, adjust_square, contents_estimation,
│ │ │ # integrations/, config_registry, access, assignment, training*
│ │ └── training_modules/ # built-in training module documents (JSON) and their media
│ ├── tests/ # pytest suite (offline, in-memory DB)
│ └── requirements.txt
├── frontend/
│ └── src/
│ ├── app/ # Next.js App Router pages
│ ├── components/ # React components
│ ├── content/ # Help Center articles and changelogs
│ ├── hooks/ # shared React hooks
│ ├── lib/ # api client, auth, settings contexts, helpers
│ └── types/ # TypeScript interfaces
├── docs/ # this handbook (Docusaurus)
├── nginx/nginx.conf
├── docker-compose.yml # local
└── docker-compose.prod.yml # production (worker, Redis, nginx, Cloudflare Tunnel)

Runtime topology​

Each instance (production, a second customer instance, and stage) is its own server on Laravel Forge, running docker-compose.prod.yml and redeployed on push. Six containers run behind a Cloudflare Tunnel: backend, worker, redis, frontend, nginx and cloudflared. No ports are exposed to the public internet; all ingress arrives through the tunnel into nginx. See deployment.

The same logical split exists in local development, just without nginx, the tunnel, Redis or the worker (pipelines run as in-process background tasks): the Next dev server proxies /api to the uvicorn backend. See local development.

Backend layering​

The backend follows a conventional layered shape. Requests flow down; the pipeline runs to the side, in the worker container in production.

LayerResponsibilityKey files
RoutesHTTP surface, validation, auth, response shapingapp/api/routes/*
AuthValidate JWT, resolve current user and team, build the Actorcore/auth_deps.py, core/actor.py, core/security.py
ServicesBusiness logic: the pipeline, billing, numbering, auto-approve, Adjust Square clientapp/services/*
ModelsSQLAlchemy ORM tablesapp/models/*
SchemasPydantic request/response contractsapp/schemas/*
CoreConfig, database engine, job queue, observability, error trackingcore/config.py, core/database.py, core/queue.py, core/observability.py, core/sentry.py

Two request paths: synchronous API vs background pipeline​

ContentsVision has two distinct execution paths, and understanding the split explains most of the design.

Synchronous API calls​

Standard REST. The route reads or writes the database and returns immediately. Most endpoints (claims, rooms, inventory edits, settings) work this way.

Background pipeline jobs​

Uploading media returns right away, but the heavy AI work never runs inside the request. Every pipeline start goes through app/core/queue.enqueue_job: in production (REDIS_URL set) the route pushes the job id onto a Redis queue and a separate worker container (app/worker.py, ARQ) runs the pipeline against its own database session; in local development (no REDIS_URL) the same call schedules a FastAPI background task in the web server instead. The frontend then watches progress over Server-Sent Events, which the backend serves from the job row plus the log lines the worker mirrors through Redis (see observability).

This is why a long video does not block the HTTP request, and why one user's processing never slows another user's pages: the web server only does front-desk work. The Adjust Square submission still hands its slow photo uploads to an in-process background task (network waiting, no CPU; see Adjust Square).

Where to go next​