# syedshahmeerali12/higgsfield-ai-clone architecture

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

- Interactive diagram: https://gitdiagram.com/syedshahmeerali12/higgsfield-ai-clone
- Repository: https://github.com/syedshahmeerali12/higgsfield-ai-clone

## Overview

Higgsfield AI Clone is a cinematic image/video generation app. Users browse Explore, register or sign in and complete onboarding, then submit image or video prompts; authenticated API routes enforce credits and limits, call generation providers, and persist jobs/assets for the Library and Explore feed. Video generation can submit to Replicate and finish as the client polls job status. The graph preserves documented pricing, auth, and onboarding capabilities; the separate Express service is scaffold infrastructure described as unwired. Relationships not directly visible in sampled source are omitted.

Main entry points: [`apps/web/src/app/api/generate/video/route.ts`](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/generate/video/route.ts) (Video generation API), [`apps/web/src/app/api/generate/image/route.ts`](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/generate/image/route.ts) (Image generation API), [`apps/web/src/lib/prisma.ts`](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/prisma.ts) (Postgres database), [`apps/web/src/app/api/jobs/[jobId]/route.ts`](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/jobs/%5BjobId%5D/route.ts) (Job status polling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Product experience"]
  node_webapp["App shell<br/>[layout.tsx]"]
  node_explore["Explore feed<br/>[route.ts]"]
  node_exploreui["Explore interface<br/>[feed.tsx]"]
  node_library["Generation library<br/>[page.tsx]"]
  node_pricing["Pricing plans<br/>[page.tsx]"]
end

subgraph group_identity["Identity and onboarding"]
  node_signup["Registration<br/>[route.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_onboardui["Onboarding flow"]
  node_onboardapi["Onboarding API<br/>[route.ts]"]
end

subgraph group_generation["Generation workflows"]
  node_imageui["Image studio<br/>[page.tsx]"]
  node_imageapi["Image generation API<br/>[route.ts]"]
  node_imageprovider["Image provider<br/>[image.ts]"]
  node_videoui["Video studio<br/>[video-studio.tsx]"]
  node_videoapi["Video generation API<br/>[route.ts]"]
  node_videoprovider["Video provider<br/>[video.ts]"]
  node_textprovider["Prompt enhancement<br/>[text.ts]"]
end

subgraph group_platform["Jobs and persistence"]
  node_statusapi["Job status polling<br/>[route.ts]"]
  node_joblogic["Job completion<br/>[jobs.ts]"]
  node_limits["Usage limits<br/>[rate-limit.ts]"]
  node_database[("Postgres database<br/>[prisma.ts]")]
end

node_creator(("Creator"))
node_api_scaffold["Unwired Express service<br/>[index.ts]"]

node_creator -->|"browses"| node_exploreui
node_exploreui -.->|"loads feed"| node_explore
node_creator -->|"registers"| node_signup
node_creator -->|"signs in"| node_auth
node_onboardui -.->|"submits profile"| node_onboardapi
node_creator -->|"completes"| node_onboardui
node_creator -->|"creates image"| node_imageui
node_imageui -->|"submits prompt"| node_imageapi
node_imageapi -->|"authenticates"| node_auth
node_imageapi -->|"checks limits"| node_limits
node_imageapi -->|"reads and writes"| node_database
node_imageapi -->|"generates image"| node_imageprovider
node_creator -->|"creates video"| node_videoui
node_videoui -.->|"submits prompt"| node_videoapi
node_videoapi -->|"authenticates"| node_auth
node_videoapi -->|"checks limits"| node_limits
node_videoapi -->|"creates and updates"| node_database
node_videoapi -->|"submits or generates"| node_videoprovider
node_videoapi -->|"enhances prompt"| node_textprovider
node_creator -->|"polls progress"| node_statusapi
node_statusapi -->|"reads and updates"| node_database
node_statusapi -->|"checks prediction"| node_videoprovider
node_statusapi -->|"completes or fails"| node_joblogic
node_explore -->|"reads public assets"| node_database
node_explore -->|"reads seed data"| node_database
node_creator -->|"views generations"| node_library

click node_webapp "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/layout.tsx"
click node_explore "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/explore/route.ts"
click node_exploreui "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/components/explore/feed.tsx"
click node_library "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/library/page.tsx"
click node_pricing "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/pricing/page.tsx"
click node_signup "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/auth/register/route.ts"
click node_auth "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/auth.ts"
click node_onboardui "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/components/onboarding/onboarding-flow.tsx"
click node_onboardapi "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/onboarding/route.ts"
click node_imageui "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/image/page.tsx"
click node_imageapi "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/generate/image/route.ts"
click node_imageprovider "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/providers/image.ts"
click node_videoui "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/components/generation/video-studio.tsx"
click node_videoapi "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/generate/video/route.ts"
click node_videoprovider "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/providers/video.ts"
click node_textprovider "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/providers/text.ts"
click node_statusapi "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/jobs/%5BjobId%5D/route.ts"
click node_joblogic "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/jobs.ts"
click node_limits "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/rate-limit.ts"
click node_database "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/prisma.ts"
click node_api_scaffold "https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/api/src/index.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_webapp,node_explore,node_exploreui,node_library,node_pricing toneBlue
class node_signup,node_auth,node_onboardui,node_onboardapi toneAmber
class node_imageui,node_imageapi,node_imageprovider,node_videoui,node_videoapi,node_videoprovider,node_textprovider toneMint
class node_statusapi,node_joblogic,node_limits,node_database toneRose
class node_creator toneIndigo
class node_api_scaffold toneTeal
```

## Components

### Product experience

- [App shell](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/layout.tsx): `apps/web/src/app/layout.tsx`
- [Explore feed](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/explore/route.ts): `apps/web/src/app/api/explore/route.ts`
- [Explore interface](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/components/explore/feed.tsx): `apps/web/src/components/explore/feed.tsx`
- [Generation library](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/library/page.tsx): `apps/web/src/app/library/page.tsx`
- [Pricing plans](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/pricing/page.tsx): `apps/web/src/app/pricing/page.tsx`

### Identity and onboarding

- [Registration](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/auth/register/route.ts): `apps/web/src/app/api/auth/register/route.ts`
- [Authentication](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/auth.ts): `apps/web/src/lib/auth.ts`
- [Onboarding flow](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/components/onboarding/onboarding-flow.tsx): `apps/web/src/components/onboarding/onboarding-flow.tsx`
- [Onboarding API](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/onboarding/route.ts): `apps/web/src/app/api/onboarding/route.ts`

### Generation workflows

- [Image studio](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/image/page.tsx): `apps/web/src/app/image/page.tsx`
- [Image generation API](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/generate/image/route.ts): `apps/web/src/app/api/generate/image/route.ts`
- [Image provider](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/providers/image.ts): `apps/web/src/lib/providers/image.ts`
- [Video studio](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/components/generation/video-studio.tsx): `apps/web/src/components/generation/video-studio.tsx`
- [Video generation API](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/generate/video/route.ts): `apps/web/src/app/api/generate/video/route.ts`
- [Video provider](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/providers/video.ts): `apps/web/src/lib/providers/video.ts`
- [Prompt enhancement](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/providers/text.ts): `apps/web/src/lib/providers/text.ts`

### Jobs and persistence

- [Job status polling](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/app/api/jobs/%5BjobId%5D/route.ts): `apps/web/src/app/api/jobs/[jobId]/route.ts`
- [Job completion](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/jobs.ts): `apps/web/src/lib/jobs.ts`
- [Usage limits](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/rate-limit.ts): `apps/web/src/lib/rate-limit.ts`
- [Postgres database](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/web/src/lib/prisma.ts): `apps/web/src/lib/prisma.ts`

### Other components

- **Creator**
- [Unwired Express service](https://github.com/syedshahmeerali12/higgsfield-ai-clone/blob/master/apps/api/src/index.ts): `apps/api/src/index.ts`

## Connections

- Creator → Explore interface: browses
- Explore interface → Explore feed: loads feed
- Creator → Registration: registers
- Creator → Authentication: signs in
- Onboarding flow → Onboarding API: submits profile
- Creator → Onboarding flow: completes
- Creator → Image studio: creates image (evidence: `apps/web/src/app/image/page.tsx`)
- Image studio → Image generation API: submits prompt (evidence: `apps/web/src/app/image/page.tsx`)
- Image generation API → Authentication: authenticates (evidence: `apps/web/src/app/api/generate/image/route.ts`)
- Image generation API → Usage limits: checks limits (evidence: `apps/web/src/app/api/generate/image/route.ts`)
- Image generation API → Postgres database: reads and writes (evidence: `apps/web/src/app/api/generate/image/route.ts`)
- Image generation API → Image provider: generates image (evidence: `apps/web/src/app/api/generate/image/route.ts`)
- Creator → Video studio: creates video
- Video studio → Video generation API: submits prompt
- Video generation API → Authentication: authenticates (evidence: `apps/web/src/app/api/generate/video/route.ts`)
- Video generation API → Usage limits: checks limits (evidence: `apps/web/src/app/api/generate/video/route.ts`)
- Video generation API → Postgres database: creates and updates (evidence: `apps/web/src/app/api/generate/video/route.ts`)
- Video generation API → Video provider: submits or generates (evidence: `apps/web/src/app/api/generate/video/route.ts`)
- Video generation API → Prompt enhancement: enhances prompt (evidence: `apps/web/src/app/api/generate/video/route.ts`)
- Creator → Job status polling: polls progress
- Job status polling → Postgres database: reads and updates (evidence: `apps/web/src/app/api/jobs/[jobId]/route.ts`)
- Job status polling → Video provider: checks prediction (evidence: `apps/web/src/app/api/jobs/[jobId]/route.ts`)
- Job status polling → Job completion: completes or fails (evidence: `apps/web/src/app/api/jobs/[jobId]/route.ts`)
- Explore feed → Postgres database: reads public assets (evidence: `apps/web/src/app/api/explore/route.ts`)
- Explore feed → Postgres database: reads seed data (evidence: `apps/web/src/app/api/explore/route.ts`)
- Creator → Generation library: views generations
