# kvgai-tech/kvgai-tech-starter-template architecture

> Architecture diagram of the GitHub repository kvgai-tech/kvgai-tech-starter-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kvgai-tech/kvgai-tech-starter-template
- Repository: https://github.com/kvgai-tech/kvgai-tech-starter-template

## Overview

This repository is a full-stack starter template: a browser-facing Next.js app, a private FastAPI service, and an ARQ background worker, with Redis and Supabase Postgres as shared infrastructure. The primary domain workflow is record creation: the API persists a record, enqueues processing through Redis, and the worker updates its status in Postgres. The web app also has login/session routes and dashboard, records, settings, and status pages; their detailed wiring is not shown in the excerpts. README documents the web-to-API proxy and deployment topology; unsampled UI and infrastructure relationships are not inferred.

Main entry points: [`api/app/shared/db.py`](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/db.py) (Database engine), [`web/src/app`](https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app) (Next.js app), [`api/app/main.py`](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/main.py) (FastAPI app), [`api/app/api/routes/records.py`](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/api/routes/records.py) (Record endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_web_app["Next.js app"]
  node_web_proxy["API proxy<br/>[route.ts]"]
  node_web_auth["Login and session"]
  node_web_pages["Product pages"]
end

subgraph group_api["API and records"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_api_routes["Health and info routes"]
  node_record_routes["Record endpoints<br/>[records.py]"]
  node_record_service["Record operations<br/>[record.py]"]
  node_record_schema["Record schemas<br/>[record.py]"]
  node_api_session["API DB session<br/>[session.py]"]
  node_api_settings["API settings<br/>[config.py]"]
end

subgraph group_worker["Background processing"]
  node_worker_runner["ARQ worker<br/>[worker.py]"]
  node_process_job["Record processing job<br/>[process_record.py]"]
  node_worker_settings["Worker settings<br/>[config.py]"]
end

subgraph group_infra["Shared infrastructure"]
  node_redis_pool["ARQ Redis pool<br/>[redis.py]"]
  node_db_engine["Database engine<br/>[db.py]"]
  node_url_config["Database URL handling<br/>[database_url.py]"]
  node_record_model["Record model<br/>[record.py]"]
  node_postgres[("Supabase Postgres")]
  node_redis["Redis"]
end

node_browser(("Browser user"))

node_browser -->|"uses"| node_web_app
node_web_app -->|"routes API requests"| node_web_proxy
node_web_app -.->|"provides auth routes"| node_web_auth
node_web_app -.->|"renders pages"| node_web_pages
node_web_proxy -->|"proxies requests"| node_api_app
node_api_app -->|"registers routes"| node_api_routes
node_api_app -->|"registers routes"| node_record_routes
node_api_app -->|"starts and closes"| node_redis_pool
node_record_routes -->|"calls"| node_record_service
node_record_routes -->|"requests session"| node_api_session
node_record_routes -->|"uses schemas"| node_record_schema
node_record_service -->|"queries and writes"| node_record_model
node_record_service -->|"enqueues job"| node_redis_pool
node_api_session -->|"creates session factory"| node_db_engine
node_db_engine -->|"normalizes connection"| node_url_config
node_db_engine -.->|"connects"| node_postgres
node_record_model -->|"uses Base"| node_db_engine
node_redis_pool -.->|"connects"| node_redis
node_worker_runner -->|"registers job"| node_process_job
node_worker_runner -->|"loads settings"| node_worker_settings
node_worker_runner -->|"consumes queued jobs"| node_redis
node_process_job -->|"loads shared model"| node_record_model
node_process_job -->|"reads and updates"| node_db_engine
node_process_job -.->|"updates record status"| node_postgres

click node_web_app "https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app"
click node_web_proxy "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/web/src/app/api/v1/%5B...path%5D/route.ts"
click node_web_auth "https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app/api/auth"
click node_web_pages "https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app"
click node_api_app "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/main.py"
click node_api_routes "https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/api/app/api/routes"
click node_record_routes "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/api/routes/records.py"
click node_record_service "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/services/record.py"
click node_record_schema "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/schemas/record.py"
click node_api_session "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/db/session.py"
click node_api_settings "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/core/config.py"
click node_redis_pool "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/core/redis.py"
click node_db_engine "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/db.py"
click node_url_config "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/database_url.py"
click node_record_model "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/models/record.py"
click node_worker_runner "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/worker/app/worker.py"
click node_process_job "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/worker/app/jobs/process_record.py"
click node_worker_settings "https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/worker/app/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_app,node_web_proxy,node_web_auth,node_web_pages,node_browser toneBlue
class node_api_app,node_api_routes,node_record_routes,node_record_service,node_record_schema,node_api_session,node_api_settings toneAmber
class node_worker_runner,node_process_job,node_worker_settings toneMint
class node_redis_pool,node_db_engine,node_url_config,node_record_model,node_postgres,node_redis toneRose
```

## Components

### Web application

- [Next.js app](https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app): `web/src/app`
- [API proxy](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/web/src/app/api/v1/%5B...path%5D/route.ts): `web/src/app/api/v1/[...path]/route.ts`
- [Login and session](https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app/api/auth): `web/src/app/api/auth`
- [Product pages](https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/web/src/app): `web/src/app`

### API and records

- [FastAPI app](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/main.py): `api/app/main.py`
- [Health and info routes](https://github.com/kvgai-tech/kvgai-tech-starter-template/tree/prod/api/app/api/routes): `api/app/api/routes`
- [Record endpoints](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/api/routes/records.py): `api/app/api/routes/records.py`
- [Record operations](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/services/record.py): `api/app/services/record.py`
- [Record schemas](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/schemas/record.py): `api/app/schemas/record.py`
- [API DB session](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/db/session.py): `api/app/db/session.py`
- [API settings](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/core/config.py): `api/app/core/config.py`

### Background processing

- [ARQ worker](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/worker/app/worker.py): `worker/app/worker.py`
- [Record processing job](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/worker/app/jobs/process_record.py): `worker/app/jobs/process_record.py`
- [Worker settings](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/worker/app/config.py): `worker/app/config.py`

### Shared infrastructure

- [ARQ Redis pool](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/core/redis.py): `api/app/core/redis.py`
- [Database engine](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/db.py): `api/app/shared/db.py`
- [Database URL handling](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/database_url.py): `api/app/shared/database_url.py`
- [Record model](https://github.com/kvgai-tech/kvgai-tech-starter-template/blob/prod/api/app/shared/models/record.py): `api/app/shared/models/record.py`
- **Supabase Postgres**
- **Redis**

### Other components

- **Browser user**

## Connections

- Browser user → Next.js app: uses
- Next.js app → API proxy: routes API requests
- Next.js app → Login and session: provides auth routes
- Next.js app → Product pages: renders pages
- API proxy → FastAPI app: proxies requests
- FastAPI app → Health and info routes: registers routes (evidence: `api/app/main.py`)
- FastAPI app → Record endpoints: registers routes (evidence: `api/app/main.py`)
- FastAPI app → ARQ Redis pool: starts and closes (evidence: `api/app/main.py`)
- Record endpoints → Record operations: calls (evidence: `api/app/api/routes/records.py`)
- Record endpoints → API DB session: requests session (evidence: `api/app/api/routes/records.py`)
- Record endpoints → Record schemas: uses schemas (evidence: `api/app/api/routes/records.py`)
- Record operations → Record model: queries and writes (evidence: `api/app/services/record.py`)
- Record operations → ARQ Redis pool: enqueues job (evidence: `api/app/services/record.py`)
- API DB session → Database engine: creates session factory (evidence: `api/app/db/session.py`)
- Database engine → Database URL handling: normalizes connection (evidence: `api/app/shared/db.py`)
- Database engine → Supabase Postgres: connects
- Record model → Database engine: uses Base (evidence: `api/app/shared/models/record.py`)
- ARQ Redis pool → Redis: connects
- ARQ worker → Record processing job: registers job (evidence: `worker/app/worker.py`)
- ARQ worker → Worker settings: loads settings (evidence: `worker/app/worker.py`)
- ARQ worker → Redis: consumes queued jobs
- Record processing job → Record model: loads shared model (evidence: `worker/app/jobs/process_record.py`)
- Record processing job → Database engine: reads and updates (evidence: `worker/app/jobs/process_record.py`)
- Record processing job → Supabase Postgres: updates record status
