# rohitdvv/swell architecture

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

- Interactive diagram: https://gitdiagram.com/rohitdvv/swell
- Repository: https://github.com/rohitdvv/swell
- Video tour (about a minute): https://gitdiagram.com/rohitdvv/swell/video

## Overview

Swell is a restaurant campaign-planning product: an operator uploads sales data and venue details, generates and edits a 30-day campaign, then publishes a shareable campaign artifact. The generator combines brand extraction, demand and local conditions, forecasting, offer strategy, copy, creative, and revenue projections. Published campaigns also provide intelligence, distribution assets, an owner-facing assistant, and measured-lift proof. Source excerpts show the generation entry point and orchestration, but not every API or UI implementation; README statements support the major product branches.

Main entry points: [`src/lib/orchestrator.ts`](https://github.com/rohitdvv/swell/blob/main/src/lib/orchestrator.ts) (Agent orchestration), [`src/app/api/generate/route.ts`](https://github.com/rohitdvv/swell/blob/main/src/app/api/generate/route.ts) (Generate endpoint), [`src/app/c/[slug]/page.tsx`](https://github.com/rohitdvv/swell/blob/main/src/app/c/%5Bslug%5D/page.tsx) (Public campaign), [`src/lib/db.ts`](https://github.com/rohitdvv/swell/blob/main/src/lib/db.ts) (Campaign database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Operator experience"]
  node_console["Brain Console<br/>[page.tsx]"]
  node_generator_api["Generate endpoint<br/>[route.ts]"]
  node_sales_ingest["Sales CSV ingest<br/>[csv.ts]"]
end

subgraph group_generation["Campaign generation"]
  node_orchestrator["Agent orchestration<br/>[orchestrator.ts]"]
  node_brand["Brand extraction<br/>[brand.ts]"]
  node_strategy_copy["Offers and copy<br/>[generator.ts]"]
  node_creative["Poster rendering<br/>[creative.ts]"]
end

subgraph group_intelligence["Context and forecasting"]
  node_marketplace["Demand signals<br/>[marketplace.ts]"]
  node_local_context["Weather and events<br/>[index.ts]"]
  node_geocoding["Venue geocoding<br/>[geo.ts]"]
  node_forecast["Sales forecasting<br/>[model.ts]"]
end

subgraph group_delivery["Campaign delivery"]
  node_campaign_artifact["Public campaign<br/>[page.tsx]"]
  node_campaign_board["Campaign editing<br/>[campaign-board.tsx]"]
  node_distribution["Ad kit and calendar<br/>[page.tsx]"]
  node_proof["Measured lift proof<br/>[proof.ts]"]
  node_proof_api["Proof submission<br/>[route.ts]"]
  node_assistant["Campaign assistant<br/>[assistant.ts]"]
  node_assistant_api["Assistant endpoint<br/>[route.ts]"]
end

subgraph group_platform["Identity and platform"]
  node_campaign_store[("Campaign database<br/>[db.ts]")]
  node_auth_billing["Account and plans<br/>[account.ts]"]
  node_authorization["Campaign access control<br/>[authz.ts]"]
  node_stripe["Stripe billing<br/>[stripe.ts]"]
end

node_operator(("Restaurant operator"))
node_visitor(("Campaign visitor"))

node_operator -->|"uses"| node_console
node_console -->|"uploads sales"| node_sales_ingest
node_console -->|"requests generation"| node_generator_api
node_generator_api -->|"runs agents"| node_orchestrator
node_generator_api -->|"persists campaign"| node_campaign_store
node_orchestrator -->|"extracts brand"| node_brand
node_orchestrator -->|"analyzes and writes"| node_strategy_copy
node_orchestrator -->|"reads demand"| node_marketplace
node_orchestrator -->|"geocodes venue"| node_geocoding
node_orchestrator -->|"gathers conditions"| node_local_context
node_orchestrator -->|"trains forecast"| node_forecast
node_generator_api -->|"prewarms posters"| node_creative
node_orchestrator -.->|"loads campaign data"| node_campaign_store
node_operator -->|"publishes campaign"| node_campaign_artifact
node_visitor -->|"views published"| node_campaign_artifact
node_campaign_artifact -->|"shows calendar"| node_campaign_board
node_campaign_board -->|"submits POS data"| node_proof_api
node_proof_api -->|"measures lift"| node_proof
node_proof_api -->|"stores proof"| node_campaign_store
node_campaign_artifact -->|"offers ad kit"| node_distribution
node_campaign_artifact -->|"asks questions"| node_assistant_api
node_assistant_api -->|"answers campaign questions"| node_assistant
node_assistant_api -->|"loads campaign"| node_campaign_store
node_assistant_api -->|"checks viewer"| node_authorization
node_operator -->|"signs in"| node_auth_billing
node_auth_billing -->|"mirrors account"| node_campaign_store
node_auth_billing -.->|"uses subscription billing"| node_stripe
node_generator_api -->|"checks account"| node_auth_billing
node_generator_api -->|"filters public response"| node_authorization

click node_console "https://github.com/rohitdvv/swell/blob/main/src/app/console/page.tsx"
click node_generator_api "https://github.com/rohitdvv/swell/blob/main/src/app/api/generate/route.ts"
click node_sales_ingest "https://github.com/rohitdvv/swell/blob/main/src/lib/csv.ts"
click node_orchestrator "https://github.com/rohitdvv/swell/blob/main/src/lib/orchestrator.ts"
click node_brand "https://github.com/rohitdvv/swell/blob/main/src/lib/brand.ts"
click node_strategy_copy "https://github.com/rohitdvv/swell/blob/main/src/lib/generator.ts"
click node_creative "https://github.com/rohitdvv/swell/blob/main/src/lib/creative.ts"
click node_marketplace "https://github.com/rohitdvv/swell/blob/main/src/lib/marketplace.ts"
click node_local_context "https://github.com/rohitdvv/swell/blob/main/src/lib/context/index.ts"
click node_geocoding "https://github.com/rohitdvv/swell/blob/main/src/lib/context/geo.ts"
click node_forecast "https://github.com/rohitdvv/swell/blob/main/src/lib/model.ts"
click node_campaign_store "https://github.com/rohitdvv/swell/blob/main/src/lib/db.ts"
click node_campaign_artifact "https://github.com/rohitdvv/swell/blob/main/src/app/c/%5Bslug%5D/page.tsx"
click node_campaign_board "https://github.com/rohitdvv/swell/blob/main/src/components/campaign-board.tsx"
click node_distribution "https://github.com/rohitdvv/swell/blob/main/src/app/c/%5Bslug%5D/brief/page.tsx"
click node_proof "https://github.com/rohitdvv/swell/blob/main/src/lib/proof.ts"
click node_proof_api "https://github.com/rohitdvv/swell/blob/main/src/app/api/campaigns/%5Bslug%5D/proof/route.ts"
click node_assistant "https://github.com/rohitdvv/swell/blob/main/src/lib/assistant.ts"
click node_assistant_api "https://github.com/rohitdvv/swell/blob/main/src/app/api/assistant/route.ts"
click node_auth_billing "https://github.com/rohitdvv/swell/blob/main/src/lib/billing/account.ts"
click node_authorization "https://github.com/rohitdvv/swell/blob/main/src/lib/authz.ts"
click node_stripe "https://github.com/rohitdvv/swell/blob/main/src/lib/billing/stripe.ts"

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_console,node_generator_api,node_sales_ingest toneBlue
class node_orchestrator,node_brand,node_strategy_copy,node_creative toneAmber
class node_marketplace,node_local_context,node_geocoding,node_forecast toneMint
class node_campaign_artifact,node_campaign_board,node_distribution,node_proof,node_proof_api,node_assistant,node_assistant_api toneRose
class node_campaign_store,node_auth_billing,node_authorization,node_stripe,node_operator,node_visitor toneIndigo
```

## Components

### Operator experience

- [Brain Console](https://github.com/rohitdvv/swell/blob/main/src/app/console/page.tsx): `src/app/console/page.tsx`
- [Generate endpoint](https://github.com/rohitdvv/swell/blob/main/src/app/api/generate/route.ts): `src/app/api/generate/route.ts`
- [Sales CSV ingest](https://github.com/rohitdvv/swell/blob/main/src/lib/csv.ts): `src/lib/csv.ts`

### Campaign generation

- [Agent orchestration](https://github.com/rohitdvv/swell/blob/main/src/lib/orchestrator.ts): `src/lib/orchestrator.ts`
- [Brand extraction](https://github.com/rohitdvv/swell/blob/main/src/lib/brand.ts): `src/lib/brand.ts`
- [Offers and copy](https://github.com/rohitdvv/swell/blob/main/src/lib/generator.ts): `src/lib/generator.ts`
- [Poster rendering](https://github.com/rohitdvv/swell/blob/main/src/lib/creative.ts): `src/lib/creative.ts`

### Context and forecasting

- [Demand signals](https://github.com/rohitdvv/swell/blob/main/src/lib/marketplace.ts): `src/lib/marketplace.ts`
- [Weather and events](https://github.com/rohitdvv/swell/blob/main/src/lib/context/index.ts): `src/lib/context/index.ts`
- [Venue geocoding](https://github.com/rohitdvv/swell/blob/main/src/lib/context/geo.ts): `src/lib/context/geo.ts`
- [Sales forecasting](https://github.com/rohitdvv/swell/blob/main/src/lib/model.ts): `src/lib/model.ts`

### Campaign delivery

- [Public campaign](https://github.com/rohitdvv/swell/blob/main/src/app/c/%5Bslug%5D/page.tsx): `src/app/c/[slug]/page.tsx`
- [Campaign editing](https://github.com/rohitdvv/swell/blob/main/src/components/campaign-board.tsx): `src/components/campaign-board.tsx`
- [Ad kit and calendar](https://github.com/rohitdvv/swell/blob/main/src/app/c/%5Bslug%5D/brief/page.tsx): `src/app/c/[slug]/brief/page.tsx`
- [Measured lift proof](https://github.com/rohitdvv/swell/blob/main/src/lib/proof.ts): `src/lib/proof.ts`
- [Proof submission](https://github.com/rohitdvv/swell/blob/main/src/app/api/campaigns/%5Bslug%5D/proof/route.ts): `src/app/api/campaigns/[slug]/proof/route.ts`
- [Campaign assistant](https://github.com/rohitdvv/swell/blob/main/src/lib/assistant.ts): `src/lib/assistant.ts`
- [Assistant endpoint](https://github.com/rohitdvv/swell/blob/main/src/app/api/assistant/route.ts): `src/app/api/assistant/route.ts`

### Identity and platform

- [Campaign database](https://github.com/rohitdvv/swell/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Account and plans](https://github.com/rohitdvv/swell/blob/main/src/lib/billing/account.ts): `src/lib/billing/account.ts`
- [Campaign access control](https://github.com/rohitdvv/swell/blob/main/src/lib/authz.ts): `src/lib/authz.ts`
- [Stripe billing](https://github.com/rohitdvv/swell/blob/main/src/lib/billing/stripe.ts): `src/lib/billing/stripe.ts`

### Other components

- **Restaurant operator**
- **Campaign visitor**

## Connections

- Restaurant operator → Brain Console: uses
- Brain Console → Sales CSV ingest: uploads sales
- Brain Console → Generate endpoint: requests generation
- Generate endpoint → Agent orchestration: runs agents (evidence: `src/app/api/generate/route.ts`)
- Generate endpoint → Campaign database: persists campaign (evidence: `src/app/api/generate/route.ts`)
- Agent orchestration → Brand extraction: extracts brand (evidence: `src/lib/orchestrator.ts`)
- Agent orchestration → Offers and copy: analyzes and writes (evidence: `src/lib/orchestrator.ts`)
- Agent orchestration → Demand signals: reads demand (evidence: `src/lib/orchestrator.ts`)
- Agent orchestration → Venue geocoding: geocodes venue (evidence: `src/lib/orchestrator.ts`)
- Agent orchestration → Weather and events: gathers conditions (evidence: `src/lib/orchestrator.ts`)
- Agent orchestration → Sales forecasting: trains forecast (evidence: `src/lib/orchestrator.ts`)
- Generate endpoint → Poster rendering: prewarms posters (evidence: `src/app/api/generate/route.ts`)
- Agent orchestration → Campaign database: loads campaign data (evidence: `src/lib/orchestrator.ts`)
- Restaurant operator → Public campaign: publishes campaign
- Campaign visitor → Public campaign: views published
- Public campaign → Campaign editing: shows calendar
- Campaign editing → Proof submission: submits POS data (evidence: `src/components/campaign-board.tsx`)
- Proof submission → Measured lift proof: measures lift (evidence: `src/app/api/campaigns/[slug]/proof/route.ts`)
- Proof submission → Campaign database: stores proof (evidence: `src/app/api/campaigns/[slug]/proof/route.ts`)
- Public campaign → Ad kit and calendar: offers ad kit
- Public campaign → Assistant endpoint: asks questions
- Assistant endpoint → Campaign assistant: answers campaign questions (evidence: `src/app/api/assistant/route.ts`)
- Assistant endpoint → Campaign database: loads campaign (evidence: `src/app/api/assistant/route.ts`)
- Assistant endpoint → Campaign access control: checks viewer (evidence: `src/app/api/assistant/route.ts`)
- Restaurant operator → Account and plans: signs in
- Account and plans → Campaign database: mirrors account (evidence: `src/lib/billing/account.ts`)
- Account and plans → Stripe billing: uses subscription billing
- Generate endpoint → Account and plans: checks account (evidence: `src/app/api/generate/route.ts`)
- Generate endpoint → Campaign access control: filters public response (evidence: `src/app/api/generate/route.ts`)
