# anuritik/builder-ai architecture

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

- Interactive diagram: https://gitdiagram.com/anuritik/builder-ai
- Repository: https://github.com/anuritik/builder-ai

## Overview

This is an AI-assisted React website builder: users sign in, describe a site, watch it generate, revise and edit its files, preview it, and publish it. The graph separates the browser experience, server request handling, project state, and AI generation/revision. It also includes the documented-by-code preview and publishing paths. Evidence is limited to the README (empty), SOURCE INDEX references, and excerpts; unsampled subsystem details and unsupported connections are omitted.

Main entry points: [`client/src/context/AppContext.jsx`](https://github.com/anuritik/builder-ai/blob/main/client/src/context/AppContext.jsx) (App state and actions), [`client/src/App.jsx`](https://github.com/anuritik/builder-ai/blob/main/client/src/App.jsx) (Page routing), [`client/src/pages/BuilderPage.jsx`](https://github.com/anuritik/builder-ai/blob/main/client/src/pages/BuilderPage.jsx) (Project builder), [`server/services/ai.js`](https://github.com/anuritik/builder-ai/blob/main/server/services/ai.js) (Generation and revision)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Builder interface"]
  node_routes_ui["Page routing<br/>[App.jsx]"]
  node_auth_ui["Sign in<br/>[AuthPage.jsx]"]
  node_home["Project home<br/>[HomePage.jsx]"]
  node_builder["Project builder<br/>[BuilderPage.jsx]"]
  node_chat_ui["Revision chat<br/>[ChatPanel.jsx]"]
  node_file_ui["File explorer<br/>[FileExplorer.jsx]"]
  node_preview_ui["Live editor preview<br/>[PreviewPanel.jsx]"]
  node_preview_page["Full preview<br/>[PreviewPage.jsx]"]
  node_full_preview["Preview renderer"]
  node_publish_ui["Public project page<br/>[PublishPage.jsx]"]
  node_context["App state and actions<br/>[AppContext.jsx]"]
  node_api["HTTP client<br/>[api.js]"]
end

subgraph group_server["Server workflows"]
  node_project_routes["Project endpoints<br/>[projectRoutes.js]"]
  node_auth_routes["Authentication endpoints<br/>[authRoutes.js]"]
  node_project_ctrl["Project workflow"]
  node_chat_ctrl["Revision workflow<br/>[chatController.js]"]
  node_auth_ctrl["Account workflow<br/>[authController.js]"]
  node_auth_mw["Session verification<br/>[authMiddleware.js]"]
end

subgraph group_ai["AI generation"]
  node_ai_service["Generation and revision<br/>[ai.js]"]
  node_prompts["AI prompts<br/>[prompts.js]"]
  node_validation["Code validation<br/>[codeValidator.js]"]
  node_diff["Patch operations<br/>[diff.js]"]
end

subgraph group_state["Project state"]
  node_project_model[("Project records<br/>[Project.js]")]
  node_user_model[("User records<br/>[User.js]")]
end

node_visitor(("User"))
node_database[("MongoDB")]
node_model_provider["AI model provider"]

node_visitor -->|"uses"| node_routes_ui
node_routes_ui -->|"routes to"| node_auth_ui
node_routes_ui -->|"routes to"| node_home
node_routes_ui -->|"routes to"| node_builder
node_routes_ui -->|"routes to"| node_preview_page
node_routes_ui -->|"routes to"| node_publish_ui
node_auth_ui -->|"uses actions"| node_context
node_home -->|"uses actions"| node_context
node_builder -->|"uses actions"| node_context
node_builder -->|"renders"| node_chat_ui
node_builder -->|"renders"| node_file_ui
node_builder -->|"renders"| node_preview_ui
node_preview_ui -->|"saves edits"| node_context
node_preview_page -->|"loads project"| node_context
node_preview_page -->|"renders"| node_full_preview
node_publish_ui -->|"renders"| node_full_preview
node_context -->|"calls"| node_api
node_context -->|"requests project API"| node_project_routes
node_project_routes -->|"protects routes"| node_auth_mw
node_project_routes -->|"dispatches"| node_project_ctrl
node_project_routes -->|"dispatches chat"| node_chat_ctrl
node_auth_routes -->|"dispatches"| node_auth_ctrl
node_auth_routes -->|"checks session"| node_auth_mw
node_project_ctrl -->|"reads and writes"| node_project_model
node_project_ctrl -->|"generates project"| node_ai_service
node_chat_ctrl -->|"reads and writes"| node_project_model
node_chat_ctrl -->|"requests revision"| node_ai_service
node_chat_ctrl -->|"applies operations"| node_diff
node_auth_ctrl -->|"uses accounts"| node_user_model
node_ai_service -->|"builds prompts"| node_prompts
node_ai_service -->|"validates code"| node_validation
node_ai_service -->|"calls model"| node_model_provider
node_project_model -.->|"persists records"| node_database
node_user_model -.->|"persists records"| node_database

click node_routes_ui "https://github.com/anuritik/builder-ai/blob/main/client/src/App.jsx"
click node_auth_ui "https://github.com/anuritik/builder-ai/blob/main/client/src/pages/AuthPage.jsx"
click node_home "https://github.com/anuritik/builder-ai/blob/main/client/src/pages/HomePage.jsx"
click node_builder "https://github.com/anuritik/builder-ai/blob/main/client/src/pages/BuilderPage.jsx"
click node_chat_ui "https://github.com/anuritik/builder-ai/blob/main/client/src/components/ChatPanel.jsx"
click node_file_ui "https://github.com/anuritik/builder-ai/blob/main/client/src/components/FileExplorer.jsx"
click node_preview_ui "https://github.com/anuritik/builder-ai/blob/main/client/src/components/PreviewPanel.jsx"
click node_preview_page "https://github.com/anuritik/builder-ai/blob/main/client/src/pages/PreviewPage.jsx"
click node_full_preview "https://github.com/anuritik/builder-ai/blob/main/client/src/components/FullPagePreview.jsx"
click node_publish_ui "https://github.com/anuritik/builder-ai/blob/main/client/src/pages/PublishPage.jsx"
click node_context "https://github.com/anuritik/builder-ai/blob/main/client/src/context/AppContext.jsx"
click node_api "https://github.com/anuritik/builder-ai/blob/main/client/src/api/api.js"
click node_project_routes "https://github.com/anuritik/builder-ai/blob/main/server/routes/projectRoutes.js"
click node_auth_routes "https://github.com/anuritik/builder-ai/blob/main/server/routes/authRoutes.js"
click node_project_ctrl "https://github.com/anuritik/builder-ai/blob/main/server/controllers/projectController.js"
click node_chat_ctrl "https://github.com/anuritik/builder-ai/blob/main/server/controllers/chatController.js"
click node_auth_ctrl "https://github.com/anuritik/builder-ai/blob/main/server/controllers/authController.js"
click node_auth_mw "https://github.com/anuritik/builder-ai/blob/main/server/middleware/authMiddleware.js"
click node_ai_service "https://github.com/anuritik/builder-ai/blob/main/server/services/ai.js"
click node_prompts "https://github.com/anuritik/builder-ai/blob/main/server/services/prompts.js"
click node_validation "https://github.com/anuritik/builder-ai/blob/main/server/services/codeValidator.js"
click node_diff "https://github.com/anuritik/builder-ai/blob/main/server/services/diff.js"
click node_project_model "https://github.com/anuritik/builder-ai/blob/main/server/models/Project.js"
click node_user_model "https://github.com/anuritik/builder-ai/blob/main/server/models/User.js"

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_routes_ui,node_auth_ui,node_home,node_builder,node_chat_ui,node_file_ui,node_preview_ui,node_preview_page,node_full_preview,node_publish_ui,node_context,node_api,node_visitor toneBlue
class node_project_routes,node_auth_routes,node_project_ctrl,node_chat_ctrl,node_auth_ctrl,node_auth_mw,node_database toneAmber
class node_ai_service,node_prompts,node_validation,node_diff toneMint
class node_project_model,node_user_model toneRose
class node_model_provider toneIndigo
```

## Components

### Builder interface

- [Page routing](https://github.com/anuritik/builder-ai/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Sign in](https://github.com/anuritik/builder-ai/blob/main/client/src/pages/AuthPage.jsx): `client/src/pages/AuthPage.jsx`
- [Project home](https://github.com/anuritik/builder-ai/blob/main/client/src/pages/HomePage.jsx): `client/src/pages/HomePage.jsx`
- [Project builder](https://github.com/anuritik/builder-ai/blob/main/client/src/pages/BuilderPage.jsx): `client/src/pages/BuilderPage.jsx`
- [Revision chat](https://github.com/anuritik/builder-ai/blob/main/client/src/components/ChatPanel.jsx): `client/src/components/ChatPanel.jsx`
- [File explorer](https://github.com/anuritik/builder-ai/blob/main/client/src/components/FileExplorer.jsx): `client/src/components/FileExplorer.jsx`
- [Live editor preview](https://github.com/anuritik/builder-ai/blob/main/client/src/components/PreviewPanel.jsx): `client/src/components/PreviewPanel.jsx`
- [Full preview](https://github.com/anuritik/builder-ai/blob/main/client/src/pages/PreviewPage.jsx): `client/src/pages/PreviewPage.jsx`
- [Preview renderer](https://github.com/anuritik/builder-ai/blob/main/client/src/components/FullPagePreview.jsx): `client/src/components/FullPagePreview.jsx`
- [Public project page](https://github.com/anuritik/builder-ai/blob/main/client/src/pages/PublishPage.jsx): `client/src/pages/PublishPage.jsx`
- [App state and actions](https://github.com/anuritik/builder-ai/blob/main/client/src/context/AppContext.jsx): `client/src/context/AppContext.jsx`
- [HTTP client](https://github.com/anuritik/builder-ai/blob/main/client/src/api/api.js): `client/src/api/api.js`

### Server workflows

- [Project endpoints](https://github.com/anuritik/builder-ai/blob/main/server/routes/projectRoutes.js): `server/routes/projectRoutes.js`
- [Authentication endpoints](https://github.com/anuritik/builder-ai/blob/main/server/routes/authRoutes.js): `server/routes/authRoutes.js`
- [Project workflow](https://github.com/anuritik/builder-ai/blob/main/server/controllers/projectController.js): `server/controllers/projectController.js`
- [Revision workflow](https://github.com/anuritik/builder-ai/blob/main/server/controllers/chatController.js): `server/controllers/chatController.js`
- [Account workflow](https://github.com/anuritik/builder-ai/blob/main/server/controllers/authController.js): `server/controllers/authController.js`
- [Session verification](https://github.com/anuritik/builder-ai/blob/main/server/middleware/authMiddleware.js): `server/middleware/authMiddleware.js`

### AI generation

- [Generation and revision](https://github.com/anuritik/builder-ai/blob/main/server/services/ai.js): `server/services/ai.js`
- [AI prompts](https://github.com/anuritik/builder-ai/blob/main/server/services/prompts.js): `server/services/prompts.js`
- [Code validation](https://github.com/anuritik/builder-ai/blob/main/server/services/codeValidator.js): `server/services/codeValidator.js`
- [Patch operations](https://github.com/anuritik/builder-ai/blob/main/server/services/diff.js): `server/services/diff.js`

### Project state

- [Project records](https://github.com/anuritik/builder-ai/blob/main/server/models/Project.js): `server/models/Project.js`
- [User records](https://github.com/anuritik/builder-ai/blob/main/server/models/User.js): `server/models/User.js`

### Other components

- **User**
- **MongoDB**
- **AI model provider**

## Connections

- User → Page routing: uses (evidence: `client/src/App.jsx`)
- Page routing → Sign in: routes to (evidence: `client/src/App.jsx`)
- Page routing → Project home: routes to (evidence: `client/src/App.jsx`)
- Page routing → Project builder: routes to (evidence: `client/src/App.jsx`)
- Page routing → Full preview: routes to (evidence: `client/src/App.jsx`)
- Page routing → Public project page: routes to (evidence: `client/src/App.jsx`)
- Sign in → App state and actions: uses actions (evidence: `client/src/pages/AuthPage.jsx`)
- Project home → App state and actions: uses actions (evidence: `client/src/pages/HomePage.jsx`)
- Project builder → App state and actions: uses actions (evidence: `client/src/pages/BuilderPage.jsx`)
- Project builder → Revision chat: renders (evidence: `client/src/pages/BuilderPage.jsx`)
- Project builder → File explorer: renders (evidence: `client/src/pages/BuilderPage.jsx`)
- Project builder → Live editor preview: renders (evidence: `client/src/pages/BuilderPage.jsx`)
- Live editor preview → App state and actions: saves edits (evidence: `client/src/components/PreviewPanel.jsx`)
- Full preview → App state and actions: loads project (evidence: `client/src/pages/PreviewPage.jsx`)
- Full preview → Preview renderer: renders (evidence: `client/src/pages/PreviewPage.jsx`)
- Public project page → Preview renderer: renders (evidence: `client/src/pages/PublishPage.jsx`)
- App state and actions → HTTP client: calls (evidence: `client/src/context/AppContext.jsx`)
- App state and actions → Project endpoints: requests project API (evidence: `client/src/context/AppContext.jsx`)
- Project endpoints → Session verification: protects routes (evidence: `server/routes/projectRoutes.js`)
- Project endpoints → Project workflow: dispatches (evidence: `server/routes/projectRoutes.js`)
- Project endpoints → Revision workflow: dispatches chat (evidence: `server/routes/projectRoutes.js`)
- Authentication endpoints → Account workflow: dispatches (evidence: `server/routes/authRoutes.js`)
- Authentication endpoints → Session verification: checks session (evidence: `server/routes/authRoutes.js`)
- Project workflow → Project records: reads and writes (evidence: `server/controllers/projectController.js`)
- Project workflow → Generation and revision: generates project (evidence: `server/controllers/projectController.js`)
- Revision workflow → Project records: reads and writes (evidence: `server/controllers/chatController.js`)
- Revision workflow → Generation and revision: requests revision (evidence: `server/controllers/chatController.js`)
- Revision workflow → Patch operations: applies operations (evidence: `server/controllers/chatController.js`)
- Account workflow → User records: uses accounts (evidence: `server/controllers/authController.js`)
- Generation and revision → AI prompts: builds prompts (evidence: `server/services/ai.js`)
- Generation and revision → Code validation: validates code (evidence: `server/services/ai.js`)
- Generation and revision → AI model provider: calls model (evidence: `server/services/ai.js`)
- Project records → MongoDB: persists records
- User records → MongoDB: persists records
