# jaikarans2003/okvevo-web architecture

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

- Interactive diagram: https://gitdiagram.com/jaikarans2003/okvevo-web
- Repository: https://github.com/jaikarans2003/okvevo-web

## Overview

OkVevo is an AI video-creation product, with Firebase-backed accounts, a chat-led Nia workflow, video generation, and subscription billing. The README describes the AI Studio stages and external agent/rendering services, but the supplied tree does not include the documented workspace or agent-service directories; those appear as external, documented systems rather than inferred local implementations. The graph also shows the sampled Next.js gateway and billing flows. Arrows are limited to README statements or relationships visible in the supplied excerpts and source index.

Main entry points: [`src/app/api/gateway/chat/completions/route.ts`](https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/gateway/chat/completions/route.ts) (Chat gateway), [`src/app/api/razorpay/update-subscription/route.ts`](https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/razorpay/update-subscription/route.ts) (Subscription routes), [`src/components/shared/AuthForm.tsx`](https://github.com/jaikarans2003/okvevo-web/blob/main/src/components/shared/AuthForm.tsx) (Sign-in UI), [`src/lib/gateway/debit.ts`](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/debit.ts) (Credit metering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_accounts["Accounts &amp; data"]
  node_auth_ui["Sign-in UI<br/>[AuthForm.tsx]"]
  node_auth_hook["Auth state<br/>[useAuth.ts]"]
  node_user_profiles[("User profiles<br/>[userService.ts]")]
  node_firebase_client["Firebase client<br/>[firebase.ts]"]
  node_firebase[("Firebase data &amp; assets<br/>[firebase-admin.ts]")]
end

subgraph group_creation["Video creation"]
  node_studio["Nia workspace<br/>[page.tsx]"]
  node_agent_service["Agent service"]
  node_llm["OpenRouter LLM"]
  node_render["Video rendering"]
end

subgraph group_gateway["AI gateway"]
  node_gateway_route["Chat gateway<br/>[route.ts]"]
  node_gateway_auth["Gateway auth<br/>[auth.ts]"]
  node_gateway_debit["Credit metering<br/>[debit.ts]"]
  node_gateway_pricing["Usage pricing<br/>[pricing.ts]"]
  node_gateway_sse["Stream responses<br/>[sse.ts]"]
end

subgraph group_billing["Billing"]
  node_subscription_ui["Subscription UI"]
  node_razorpay_routes["Subscription routes<br/>[route.ts]"]
  node_billing_sot["Billing state<br/>[userSoT.ts]"]
  node_plan_catalog["Plan catalog<br/>[razorpay.ts]"]
  node_webhook["Payment webhook<br/>[route.ts]"]
  node_credits["Credit balances<br/>[debit.ts]"]
end

node_creator(("Creator"))
node_razorpay["Razorpay"]

node_creator -->|"signs in"| node_auth_ui
node_auth_ui -->|"authenticates with"| node_firebase_client
node_auth_ui -->|"creates profiles"| node_user_profiles
node_auth_hook -->|"observes auth"| node_firebase_client
node_auth_hook -->|"loads profile"| node_user_profiles
node_creator -->|"describes video"| node_studio
node_studio -->|"proxies chat"| node_agent_service
node_agent_service -->|"streams responses"| node_llm
node_agent_service -->|"requests rendering"| node_render
node_agent_service -->|"stores assets"| node_firebase
node_creator -->|"sends chat"| node_gateway_route
node_gateway_route -->|"verifies identity"| node_gateway_auth
node_gateway_route -->|"meters usage"| node_gateway_debit
node_gateway_route -->|"prices usage"| node_gateway_pricing
node_gateway_route -->|"streams output"| node_gateway_sse
node_gateway_debit -->|"updates balances"| node_firebase
node_gateway_debit -->|"calculates charges"| node_gateway_pricing
node_creator -->|"manages plan"| node_subscription_ui
node_subscription_ui -.->|"requests changes"| node_razorpay_routes
node_razorpay_routes -->|"loads billing state"| node_billing_sot
node_razorpay_routes -->|"resolves plan"| node_plan_catalog
node_razorpay_routes -->|"updates subscription"| node_razorpay
node_razorpay -.->|"sends events"| node_webhook
node_webhook -->|"grants credits"| node_credits
node_webhook -->|"syncs subscription"| node_firebase

click node_auth_ui "https://github.com/jaikarans2003/okvevo-web/blob/main/src/components/shared/AuthForm.tsx"
click node_auth_hook "https://github.com/jaikarans2003/okvevo-web/blob/main/src/hooks/useAuth.ts"
click node_user_profiles "https://github.com/jaikarans2003/okvevo-web/blob/main/src/services/userService.ts"
click node_firebase_client "https://github.com/jaikarans2003/okvevo-web/blob/main/src/config/firebase.ts"
click node_studio "https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/nia/page.tsx"
click node_firebase "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/firebase-admin.ts"
click node_gateway_route "https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/gateway/chat/completions/route.ts"
click node_gateway_auth "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/auth.ts"
click node_gateway_debit "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/debit.ts"
click node_gateway_pricing "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/pricing.ts"
click node_gateway_sse "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/sse.ts"
click node_subscription_ui "https://github.com/jaikarans2003/okvevo-web/blob/main/src/components/shared/payment/RazorpayCheckout.tsx"
click node_razorpay_routes "https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/razorpay/update-subscription/route.ts"
click node_billing_sot "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/billing/userSoT.ts"
click node_plan_catalog "https://github.com/jaikarans2003/okvevo-web/blob/main/src/config/razorpay.ts"
click node_webhook "https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/razorpay/webhook/route.ts"
click node_credits "https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/debit.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_auth_ui,node_auth_hook,node_user_profiles,node_firebase_client,node_firebase toneBlue
class node_studio,node_agent_service,node_llm,node_render toneAmber
class node_gateway_route,node_gateway_auth,node_gateway_debit,node_gateway_pricing,node_gateway_sse toneMint
class node_subscription_ui,node_razorpay_routes,node_billing_sot,node_plan_catalog,node_webhook,node_credits toneRose
class node_creator,node_razorpay toneIndigo
```

## Components

### Accounts & data

- [Sign-in UI](https://github.com/jaikarans2003/okvevo-web/blob/main/src/components/shared/AuthForm.tsx): `src/components/shared/AuthForm.tsx`
- [Auth state](https://github.com/jaikarans2003/okvevo-web/blob/main/src/hooks/useAuth.ts): `src/hooks/useAuth.ts`
- [User profiles](https://github.com/jaikarans2003/okvevo-web/blob/main/src/services/userService.ts): `src/services/userService.ts`
- [Firebase client](https://github.com/jaikarans2003/okvevo-web/blob/main/src/config/firebase.ts): `src/config/firebase.ts`
- [Firebase data & assets](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/firebase-admin.ts): `src/lib/firebase-admin.ts`

### Video creation

- [Nia workspace](https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/nia/page.tsx): `src/app/nia/page.tsx`
- **Agent service**
- **OpenRouter LLM**
- **Video rendering**

### AI gateway

- [Chat gateway](https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/gateway/chat/completions/route.ts): `src/app/api/gateway/chat/completions/route.ts`
- [Gateway auth](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/auth.ts): `src/lib/gateway/auth.ts`
- [Credit metering](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/debit.ts): `src/lib/gateway/debit.ts`
- [Usage pricing](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/pricing.ts): `src/lib/gateway/pricing.ts`
- [Stream responses](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/sse.ts): `src/lib/gateway/sse.ts`

### Billing

- [Subscription UI](https://github.com/jaikarans2003/okvevo-web/blob/main/src/components/shared/payment/RazorpayCheckout.tsx): `src/components/shared/payment/RazorpayCheckout.tsx`
- [Subscription routes](https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/razorpay/update-subscription/route.ts): `src/app/api/razorpay/update-subscription/route.ts`
- [Billing state](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/billing/userSoT.ts): `src/lib/billing/userSoT.ts`
- [Plan catalog](https://github.com/jaikarans2003/okvevo-web/blob/main/src/config/razorpay.ts): `src/config/razorpay.ts`
- [Payment webhook](https://github.com/jaikarans2003/okvevo-web/blob/main/src/app/api/razorpay/webhook/route.ts): `src/app/api/razorpay/webhook/route.ts`
- [Credit balances](https://github.com/jaikarans2003/okvevo-web/blob/main/src/lib/gateway/debit.ts): `src/lib/gateway/debit.ts`

### Other components

- **Creator**
- **Razorpay**

## Connections

- Creator → Sign-in UI: signs in (evidence: `README.md`)
- Sign-in UI → Firebase client: authenticates with (evidence: `src/components/shared/AuthForm.tsx`)
- Sign-in UI → User profiles: creates profiles (evidence: `src/components/shared/AuthForm.tsx`)
- Auth state → Firebase client: observes auth (evidence: `src/hooks/useAuth.ts`)
- Auth state → User profiles: loads profile (evidence: `src/hooks/useAuth.ts`)
- Creator → Nia workspace: describes video (evidence: `README.md`)
- Nia workspace → Agent service: proxies chat (evidence: `README.md`)
- Agent service → OpenRouter LLM: streams responses (evidence: `README.md`)
- Agent service → Video rendering: requests rendering (evidence: `README.md`)
- Agent service → Firebase data & assets: stores assets (evidence: `README.md`)
- Creator → Chat gateway: sends chat (evidence: `src/app/api/gateway/chat/completions/route.ts`)
- Chat gateway → Gateway auth: verifies identity (evidence: `src/app/api/gateway/chat/completions/route.ts`)
- Chat gateway → Credit metering: meters usage (evidence: `src/app/api/gateway/chat/completions/route.ts`)
- Chat gateway → Usage pricing: prices usage (evidence: `src/app/api/gateway/chat/completions/route.ts`)
- Chat gateway → Stream responses: streams output (evidence: `src/app/api/gateway/chat/completions/route.ts`)
- Credit metering → Firebase data & assets: updates balances (evidence: `src/lib/gateway/debit.ts`)
- Credit metering → Usage pricing: calculates charges (evidence: `src/lib/gateway/debit.ts`)
- Creator → Subscription UI: manages plan (evidence: `README.md`)
- Subscription UI → Subscription routes: requests changes
- Subscription routes → Billing state: loads billing state (evidence: `src/app/api/razorpay/update-subscription/route.ts`)
- Subscription routes → Plan catalog: resolves plan (evidence: `src/app/api/razorpay/update-subscription/route.ts`)
- Subscription routes → Razorpay: updates subscription (evidence: `src/app/api/razorpay/update-subscription/route.ts`)
- Razorpay → Payment webhook: sends events
- Payment webhook → Credit balances: grants credits (evidence: `src/app/api/razorpay/webhook/route.ts`)
- Payment webhook → Firebase data & assets: syncs subscription (evidence: `src/app/api/razorpay/webhook/route.ts`)
