# mantavya2109/ai-ad-generator architecture

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

- Interactive diagram: https://gitdiagram.com/mantavya2109/ai-ad-generator
- Repository: https://github.com/mantavya2109/ai-ad-generator

## Overview

AiAdGenerator is a web app for turning uploaded product and model images into AI-generated ad images and videos. A user enters project details in the generator; the API authenticates the request, checks credits, stores uploads and project state, and invokes Google GenAI. Generated assets are persisted and can be viewed, managed, or published to the community. The README also identifies Clerk, Cloudinary, and PostgreSQL/Prisma as product integrations. Some client and server links are explicit in excerpts; unsampled subsystem relationships are omitted where not evidenced.

Main entry points: [`client/src/App.tsx`](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/App.tsx) (Routes and shell), [`client/src/configs/axios.ts`](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/configs/axios.ts) (HTTP client), [`server/routes/projectRoutes.ts`](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/routes/projectRoutes.ts) (Project routes), [`server/controllers/projectController.ts`](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/projectController.ts) (Project operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Routes and shell<br/>[App.tsx]"]
  node_generator["Ad generator<br/>[Generator.tsx]"]
  node_uploads["Image upload UI<br/>[UploadZone.tsx]"]
  node_mygen["My generations<br/>[MyGenerations.tsx]"]
  node_result["Generation results<br/>[Result.tsx]"]
  node_community["Community gallery<br/>[Community.tsx]"]
  node_card["Project card<br/>[ProjectCard.tsx]"]
  node_api_client["HTTP client<br/>[axios.ts]"]
end

subgraph group_api["API and identity"]
  node_server["Express API<br/>[server.ts]"]
  node_project_routes["Project routes<br/>[projectRoutes.ts]"]
  node_user_routes["User routes<br/>[userRoutes.ts]"]
  node_auth["Request protection<br/>[auth.ts]"]
  node_clerk["Clerk webhook<br/>[clerk.ts]"]
end

subgraph group_generation["Asset generation"]
  node_projects["Project operations"]
  node_ai["Google GenAI<br/>[ai.ts]"]
  node_storage[("Cloudinary")]
  node_uploads_middleware["Multipart uploads<br/>[multer.ts]"]
end

subgraph group_persistence["Project data"]
  node_users["User operations<br/>[userController.ts]"]
  node_database[("PostgreSQL via Prisma<br/>[prisma.ts]")]
end

node_user(("Creator"))

node_user -->|"uses"| node_app
node_app -->|"routes"| node_generator
node_app -->|"routes"| node_mygen
node_app -->|"routes"| node_result
node_app -->|"routes"| node_community
node_generator -->|"renders"| node_uploads
node_generator -->|"posts data"| node_api_client
node_mygen -->|"fetches projects"| node_api_client
node_mygen -->|"renders"| node_card
node_community -->|"fetches projects"| node_api_client
node_community -->|"renders"| node_card
node_result -->|"fetches result"| node_api_client
node_card -->|"manages projects"| node_api_client
node_server -->|"mounts"| node_project_routes
node_server -->|"mounts"| node_user_routes
node_project_routes -->|"parses files"| node_uploads_middleware
node_project_routes -->|"protects routes"| node_auth
node_user_routes -->|"protects routes"| node_auth
node_project_routes -->|"dispatches"| node_projects
node_user_routes -->|"dispatches"| node_users
node_projects -->|"generates assets"| node_ai
node_projects -->|"uploads assets"| node_storage
node_projects -->|"reads and writes"| node_database
node_users -->|"reads and writes"| node_database
node_clerk -->|"updates identity"| node_database

click node_app "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/App.tsx"
click node_generator "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/Generator.tsx"
click node_uploads "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/components/UploadZone.tsx"
click node_mygen "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/MyGenerations.tsx"
click node_result "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/Result.tsx"
click node_community "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/Community.tsx"
click node_card "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/components/ProjectCard.tsx"
click node_api_client "https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/configs/axios.ts"
click node_server "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/server.ts"
click node_project_routes "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/routes/projectRoutes.ts"
click node_user_routes "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/routes/userRoutes.ts"
click node_auth "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/middlewares/auth.ts"
click node_clerk "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/clerk.ts"
click node_projects "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/projectController.ts"
click node_ai "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/configs/ai.ts"
click node_uploads_middleware "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/configs/multer.ts"
click node_users "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/userController.ts"
click node_database "https://github.com/mantavya2109/ai-ad-generator/blob/main/server/configs/prisma.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_app,node_generator,node_uploads,node_mygen,node_result,node_community,node_card,node_api_client toneBlue
class node_server,node_project_routes,node_user_routes,node_auth,node_clerk toneAmber
class node_projects,node_ai,node_storage,node_uploads_middleware toneMint
class node_users,node_database toneRose
class node_user toneIndigo
```

## Components

### Web application

- [Routes and shell](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Ad generator](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/Generator.tsx): `client/src/pages/Generator.tsx`
- [Image upload UI](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/components/UploadZone.tsx): `client/src/components/UploadZone.tsx`
- [My generations](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/MyGenerations.tsx): `client/src/pages/MyGenerations.tsx`
- [Generation results](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/Result.tsx): `client/src/pages/Result.tsx`
- [Community gallery](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/pages/Community.tsx): `client/src/pages/Community.tsx`
- [Project card](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/components/ProjectCard.tsx): `client/src/components/ProjectCard.tsx`
- [HTTP client](https://github.com/mantavya2109/ai-ad-generator/blob/main/client/src/configs/axios.ts): `client/src/configs/axios.ts`

### API and identity

- [Express API](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/server.ts): `server/server.ts`
- [Project routes](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/routes/projectRoutes.ts): `server/routes/projectRoutes.ts`
- [User routes](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/routes/userRoutes.ts): `server/routes/userRoutes.ts`
- [Request protection](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/middlewares/auth.ts): `server/middlewares/auth.ts`
- [Clerk webhook](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/clerk.ts): `server/controllers/clerk.ts`

### Asset generation

- [Project operations](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/projectController.ts): `server/controllers/projectController.ts`
- [Google GenAI](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/configs/ai.ts): `server/configs/ai.ts`
- **Cloudinary**
- [Multipart uploads](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/configs/multer.ts): `server/configs/multer.ts`

### Project data

- [User operations](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/controllers/userController.ts): `server/controllers/userController.ts`
- [PostgreSQL via Prisma](https://github.com/mantavya2109/ai-ad-generator/blob/main/server/configs/prisma.ts): `server/configs/prisma.ts`

### Other components

- **Creator**

## Connections

- Creator → Routes and shell: uses (evidence: `client/src/App.tsx`)
- Routes and shell → Ad generator: routes (evidence: `client/src/App.tsx`)
- Routes and shell → My generations: routes (evidence: `client/src/App.tsx`)
- Routes and shell → Generation results: routes (evidence: `client/src/App.tsx`)
- Routes and shell → Community gallery: routes (evidence: `client/src/App.tsx`)
- Ad generator → Image upload UI: renders (evidence: `client/src/pages/Generator.tsx`)
- Ad generator → HTTP client: posts data (evidence: `client/src/pages/Generator.tsx`)
- My generations → HTTP client: fetches projects (evidence: `client/src/pages/MyGenerations.tsx`)
- My generations → Project card: renders (evidence: `client/src/pages/MyGenerations.tsx`)
- Community gallery → HTTP client: fetches projects (evidence: `client/src/pages/Community.tsx`)
- Community gallery → Project card: renders (evidence: `client/src/pages/Community.tsx`)
- Generation results → HTTP client: fetches result (evidence: `client/src/pages/Result.tsx`)
- Project card → HTTP client: manages projects (evidence: `client/src/components/ProjectCard.tsx`)
- Express API → Project routes: mounts (evidence: `server/server.ts`)
- Express API → User routes: mounts (evidence: `server/server.ts`)
- Project routes → Multipart uploads: parses files (evidence: `server/routes/projectRoutes.ts`)
- Project routes → Request protection: protects routes (evidence: `server/routes/projectRoutes.ts`)
- User routes → Request protection: protects routes (evidence: `server/routes/userRoutes.ts`)
- Project routes → Project operations: dispatches (evidence: `server/routes/projectRoutes.ts`)
- User routes → User operations: dispatches (evidence: `server/routes/userRoutes.ts`)
- Project operations → Google GenAI: generates assets (evidence: `server/controllers/projectController.ts`)
- Project operations → Cloudinary: uploads assets (evidence: `server/controllers/projectController.ts`)
- Project operations → PostgreSQL via Prisma: reads and writes (evidence: `server/controllers/projectController.ts`)
- User operations → PostgreSQL via Prisma: reads and writes (evidence: `server/controllers/userController.ts`)
- Clerk webhook → PostgreSQL via Prisma: updates identity (evidence: `server/controllers/clerk.ts`)
