# zayanit/postforge architecture

> Architecture diagram of the GitHub repository zayanit/postforge, 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/zayanit/postforge
- Repository: https://github.com/zayanit/postforge

## Overview

PostForge is a multi-brand SaaS for account access, brand and logo management, and securely managing per-brand OpenAI/Gemini credentials. Users sign in, manage brands, and add, validate, activate, or delete provider keys; brand deletion includes retryable remote cleanup. The graph separates the Next.js experience, FastAPI routes, domain services, and persistence/integrations. Brand Kit model, route, and storage modules exist in the tree, but the README says interviews are planned, not implemented; they are shown as backend groundwork, not as a live product workflow. Frontend-to-API wiring is not established by the sampled excerpts.

Main entry points: [`backend/app/main.py`](https://github.com/zayanit/postforge/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/services/brand_store.py`](https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_store.py) (Brand service), [`backend/app/routes/brands.py`](https://github.com/zayanit/postforge/blob/main/backend/app/routes/brands.py) (Brand routes), [`backend/app/routes/provider_keys.py`](https://github.com/zayanit/postforge/blob/main/backend/app/routes/provider_keys.py) (Key routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web_auth["Sign-in pages<br/>[page.tsx]"]
  node_web_brands["Brand pages<br/>[page.tsx]"]
  node_web_keys["Provider-key page<br/>[page.tsx]"]
  node_web_kit["Kit page<br/>[page.tsx]"]
end

subgraph group_api["API and identity"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_auth_route["Login route<br/>[auth.py]"]
  node_brand_route["Brand routes<br/>[brands.py]"]
  node_key_route["Key routes<br/>[provider_keys.py]"]
  node_kit_route["Kit routes<br/>[brand_kits.py]"]
  node_profile_route["Profile route<br/>[me.py]"]
  node_jwt_auth["JWT authentication<br/>[auth.py]"]
end

subgraph group_domain["Product services"]
  node_login_guard["Login guard<br/>[login_guard.py]"]
  node_brand_store["Brand service<br/>[brand_store.py]"]
  node_brand_deletion["Brand cleanup<br/>[brand_deletion.py]"]
  node_brand_storage["Logo storage<br/>[brand_storage.py]"]
  node_provider_store["Key lifecycle"]
  node_provider_validation["Key validation"]
  node_kit_store["Kit persistence<br/>[brand_kit_store.py]"]
  node_profile_store["Profile persistence<br/>[profile_store.py]"]
end

subgraph group_data["Persistence and integrations"]
  node_config["Settings and engine<br/>[config.py]"]
  node_brand_model["Brand model<br/>[brand.py]"]
  node_kit_model["Kit model<br/>[brand_kit.py]"]
  node_key_model["Key model<br/>[provider_key.py]"]
  node_profile_model["Profile model<br/>[profile.py]"]
  node_postgres[("PostgreSQL")]
  node_vault[("Supabase Vault")]
  node_storage["Supabase Storage"]
  node_supabase_auth["Supabase Auth"]
end

node_user(("User"))
node_providers["OpenAI / Gemini"]

node_user -->|"signs in"| node_web_auth
node_user -->|"manages brands"| node_web_brands
node_user -->|"manages keys"| node_web_keys
node_web_auth -.->|"API access"| node_api_app
node_web_brands -.->|"API access"| node_api_app
node_web_keys -.->|"API access"| node_api_app
node_web_kit -.->|"API access"| node_api_app
node_api_app -->|"registers"| node_auth_route
node_api_app -->|"registers"| node_brand_route
node_api_app -->|"registers"| node_key_route
node_api_app -->|"registers"| node_kit_route
node_api_app -->|"registers"| node_profile_route
node_auth_route -->|"checks attempts"| node_login_guard
node_auth_route -->|"exchanges credentials"| node_supabase_auth
node_jwt_auth -->|"fetches signing keys"| node_supabase_auth
node_brand_route -->|"authenticates"| node_jwt_auth
node_key_route -->|"authenticates"| node_jwt_auth
node_brand_route -->|"manages brands"| node_brand_store
node_brand_route -->|"deletes brands"| node_brand_deletion
node_brand_route -->|"manages logos"| node_brand_storage
node_key_route -->|"checks ownership"| node_brand_store
node_key_route -->|"manages keys"| node_provider_store
node_key_route -->|"validates keys"| node_provider_validation
node_kit_route -->|"checks brand"| node_brand_store
node_kit_route -->|"manages kit data"| node_kit_store
node_profile_route -->|"authenticates"| node_jwt_auth
node_profile_route -->|"loads profile"| node_profile_store
node_brand_store -->|"reads and writes"| node_postgres
node_brand_store -->|"builds records"| node_brand_model
node_brand_deletion -->|"coordinates cleanup"| node_brand_store
node_brand_deletion -->|"cleans assets"| node_brand_storage
node_brand_storage -->|"lists and deletes"| node_storage
node_provider_store -->|"reads and writes"| node_postgres
node_provider_store -->|"stores secrets"| node_vault
node_provider_store -->|"locks owned brand"| node_brand_store
node_provider_validation -.->|"checks credentials"| node_providers
node_kit_store -->|"reads and writes"| node_postgres
node_kit_store -->|"uses schema"| node_kit_model
node_kit_store -->|"checks brand"| node_brand_store
node_profile_store -.->|"reads and writes"| node_postgres
node_config -->|"configures engine"| node_postgres

click node_web_auth "https://github.com/zayanit/postforge/blob/main/frontend/app/(auth)/login/page.tsx"
click node_web_brands "https://github.com/zayanit/postforge/blob/main/frontend/app/(dashboard)/brands/page.tsx"
click node_web_keys "https://github.com/zayanit/postforge/blob/main/frontend/app/(dashboard)/brands/%5BbrandId%5D/keys/page.tsx"
click node_web_kit "https://github.com/zayanit/postforge/blob/main/frontend/app/(dashboard)/brands/%5BbrandId%5D/kit/page.tsx"
click node_api_app "https://github.com/zayanit/postforge/blob/main/backend/app/main.py"
click node_auth_route "https://github.com/zayanit/postforge/blob/main/backend/app/routes/auth.py"
click node_brand_route "https://github.com/zayanit/postforge/blob/main/backend/app/routes/brands.py"
click node_key_route "https://github.com/zayanit/postforge/blob/main/backend/app/routes/provider_keys.py"
click node_kit_route "https://github.com/zayanit/postforge/blob/main/backend/app/routes/brand_kits.py"
click node_profile_route "https://github.com/zayanit/postforge/blob/main/backend/app/routes/me.py"
click node_jwt_auth "https://github.com/zayanit/postforge/blob/main/backend/app/auth.py"
click node_login_guard "https://github.com/zayanit/postforge/blob/main/backend/app/services/login_guard.py"
click node_brand_store "https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_store.py"
click node_brand_deletion "https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_deletion.py"
click node_brand_storage "https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_storage.py"
click node_provider_store "https://github.com/zayanit/postforge/blob/main/backend/app/services/provider_key_store.py"
click node_provider_validation "https://github.com/zayanit/postforge/blob/main/backend/app/services/provider_validation.py"
click node_kit_store "https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_kit_store.py"
click node_profile_store "https://github.com/zayanit/postforge/blob/main/backend/app/services/profile_store.py"
click node_config "https://github.com/zayanit/postforge/blob/main/backend/app/config.py"
click node_brand_model "https://github.com/zayanit/postforge/blob/main/backend/app/models/brand.py"
click node_kit_model "https://github.com/zayanit/postforge/blob/main/backend/app/models/brand_kit.py"
click node_key_model "https://github.com/zayanit/postforge/blob/main/backend/app/models/provider_key.py"
click node_profile_model "https://github.com/zayanit/postforge/blob/main/backend/app/models/profile.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_auth,node_web_brands,node_web_keys,node_web_kit,node_user toneBlue
class node_api_app,node_auth_route,node_brand_route,node_key_route,node_kit_route,node_profile_route,node_jwt_auth toneAmber
class node_login_guard,node_brand_store,node_brand_deletion,node_brand_storage,node_provider_store,node_provider_validation,node_kit_store,node_profile_store toneMint
class node_config,node_brand_model,node_kit_model,node_key_model,node_profile_model,node_postgres,node_vault,node_storage,node_supabase_auth toneRose
class node_providers toneIndigo
```

## Components

### Web experience

- [Sign-in pages](https://github.com/zayanit/postforge/blob/main/frontend/app/(auth)/login/page.tsx): `frontend/app/(auth)/login/page.tsx`
- [Brand pages](https://github.com/zayanit/postforge/blob/main/frontend/app/(dashboard)/brands/page.tsx): `frontend/app/(dashboard)/brands/page.tsx`
- [Provider-key page](https://github.com/zayanit/postforge/blob/main/frontend/app/(dashboard)/brands/%5BbrandId%5D/keys/page.tsx): `frontend/app/(dashboard)/brands/[brandId]/keys/page.tsx`
- [Kit page](https://github.com/zayanit/postforge/blob/main/frontend/app/(dashboard)/brands/%5BbrandId%5D/kit/page.tsx): `frontend/app/(dashboard)/brands/[brandId]/kit/page.tsx`

### API and identity

- [FastAPI app](https://github.com/zayanit/postforge/blob/main/backend/app/main.py): `backend/app/main.py`
- [Login route](https://github.com/zayanit/postforge/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Brand routes](https://github.com/zayanit/postforge/blob/main/backend/app/routes/brands.py): `backend/app/routes/brands.py`
- [Key routes](https://github.com/zayanit/postforge/blob/main/backend/app/routes/provider_keys.py): `backend/app/routes/provider_keys.py`
- [Kit routes](https://github.com/zayanit/postforge/blob/main/backend/app/routes/brand_kits.py): `backend/app/routes/brand_kits.py`
- [Profile route](https://github.com/zayanit/postforge/blob/main/backend/app/routes/me.py): `backend/app/routes/me.py`
- [JWT authentication](https://github.com/zayanit/postforge/blob/main/backend/app/auth.py): `backend/app/auth.py`

### Product services

- [Login guard](https://github.com/zayanit/postforge/blob/main/backend/app/services/login_guard.py): `backend/app/services/login_guard.py`
- [Brand service](https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_store.py): `backend/app/services/brand_store.py`
- [Brand cleanup](https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_deletion.py): `backend/app/services/brand_deletion.py`
- [Logo storage](https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_storage.py): `backend/app/services/brand_storage.py`
- [Key lifecycle](https://github.com/zayanit/postforge/blob/main/backend/app/services/provider_key_store.py): `backend/app/services/provider_key_store.py`
- [Key validation](https://github.com/zayanit/postforge/blob/main/backend/app/services/provider_validation.py): `backend/app/services/provider_validation.py`
- [Kit persistence](https://github.com/zayanit/postforge/blob/main/backend/app/services/brand_kit_store.py): `backend/app/services/brand_kit_store.py`
- [Profile persistence](https://github.com/zayanit/postforge/blob/main/backend/app/services/profile_store.py): `backend/app/services/profile_store.py`

### Persistence and integrations

- [Settings and engine](https://github.com/zayanit/postforge/blob/main/backend/app/config.py): `backend/app/config.py`
- [Brand model](https://github.com/zayanit/postforge/blob/main/backend/app/models/brand.py): `backend/app/models/brand.py`
- [Kit model](https://github.com/zayanit/postforge/blob/main/backend/app/models/brand_kit.py): `backend/app/models/brand_kit.py`
- [Key model](https://github.com/zayanit/postforge/blob/main/backend/app/models/provider_key.py): `backend/app/models/provider_key.py`
- [Profile model](https://github.com/zayanit/postforge/blob/main/backend/app/models/profile.py): `backend/app/models/profile.py`
- **PostgreSQL**
- **Supabase Vault**
- **Supabase Storage**
- **Supabase Auth**

### Other components

- **User**
- **OpenAI / Gemini**

## Connections

- User → Sign-in pages: signs in (evidence: `README.md`)
- User → Brand pages: manages brands (evidence: `README.md`)
- User → Provider-key page: manages keys (evidence: `README.md`)
- Sign-in pages → FastAPI app: API access
- Brand pages → FastAPI app: API access
- Provider-key page → FastAPI app: API access
- Kit page → FastAPI app: API access
- FastAPI app → Login route: registers (evidence: `backend/app/main.py`)
- FastAPI app → Brand routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Key routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Kit routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Profile route: registers (evidence: `backend/app/main.py`)
- Login route → Login guard: checks attempts (evidence: `backend/app/routes/auth.py`)
- Login route → Supabase Auth: exchanges credentials (evidence: `backend/app/routes/auth.py`)
- JWT authentication → Supabase Auth: fetches signing keys (evidence: `backend/app/auth.py`)
- Brand routes → JWT authentication: authenticates (evidence: `backend/app/routes/brands.py`)
- Key routes → JWT authentication: authenticates (evidence: `backend/app/routes/provider_keys.py`)
- Brand routes → Brand service: manages brands (evidence: `backend/app/routes/brands.py`)
- Brand routes → Brand cleanup: deletes brands (evidence: `backend/app/routes/brands.py`)
- Brand routes → Logo storage: manages logos (evidence: `backend/app/routes/brands.py`)
- Key routes → Brand service: checks ownership (evidence: `backend/app/routes/provider_keys.py`)
- Key routes → Key lifecycle: manages keys (evidence: `backend/app/routes/provider_keys.py`)
- Key routes → Key validation: validates keys (evidence: `backend/app/routes/provider_keys.py`)
- Kit routes → Brand service: checks brand (evidence: `backend/app/routes/brand_kits.py`)
- Kit routes → Kit persistence: manages kit data (evidence: `backend/app/routes/brand_kits.py`)
- Profile route → JWT authentication: authenticates (evidence: `backend/app/routes/me.py`)
- Profile route → Profile persistence: loads profile (evidence: `backend/app/routes/me.py`)
- Brand service → PostgreSQL: reads and writes (evidence: `backend/app/services/brand_store.py`)
- Brand service → Brand model: builds records (evidence: `backend/app/services/brand_store.py`)
- Brand cleanup → Brand service: coordinates cleanup (evidence: `backend/app/services/brand_deletion.py`)
- Brand cleanup → Logo storage: cleans assets (evidence: `backend/app/services/brand_deletion.py`)
- Logo storage → Supabase Storage: lists and deletes (evidence: `backend/app/services/brand_storage.py`)
- Key lifecycle → PostgreSQL: reads and writes (evidence: `backend/app/services/provider_key_store.py`)
- Key lifecycle → Supabase Vault: stores secrets (evidence: `backend/app/services/provider_key_store.py`)
- Key lifecycle → Brand service: locks owned brand (evidence: `backend/app/services/provider_key_store.py`)
- Key validation → OpenAI / Gemini: checks credentials
- Kit persistence → PostgreSQL: reads and writes (evidence: `backend/app/services/brand_kit_store.py`)
- Kit persistence → Kit model: uses schema (evidence: `backend/app/services/brand_kit_store.py`)
- Kit persistence → Brand service: checks brand (evidence: `backend/app/services/brand_kit_store.py`)
- Profile persistence → PostgreSQL: reads and writes
- Settings and engine → PostgreSQL: configures engine (evidence: `backend/app/config.py`)
