# saabhashir07/x-code architecture

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

- Interactive diagram: https://gitdiagram.com/saabhashir07/x-code
- Repository: https://github.com/saabhashir07/x-code

## Overview

X Code presents itself as an AI project-architecture workspace, while its routes and editor also support a visual multi-page website builder. The principal workflow is authenticated users creating a project, using AI for planning or design changes, editing pages and themes, saving project data, and exporting a ZIP site. The graph includes advertised project-map, consistency, and documentation capabilities as product branches, but their runtime implementation is not visible in the sampled source. Some page and route wiring is inferred only from the tree, so uncertain call edges are omitted.

Main entry points: [`lib/supabase/server.ts`](https://github.com/saabhashir07/x-code/blob/main/lib/supabase/server.ts) (Supabase server client), [`components/editor/EditorLayout.tsx`](https://github.com/saabhashir07/x-code/blob/main/components/editor/EditorLayout.tsx) (Visual editor), [`app/api/ai/edit/route.ts`](https://github.com/saabhashir07/x-code/blob/main/app/api/ai/edit/route.ts) (AI design editor), [`app/api/ai/generate/route.ts`](https://github.com/saabhashir07/x-code/blob/main/app/api/ai/generate/route.ts) (AI project planner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Account and workspace"]
  node_auth_pages["Sign in and signup<br/>[page.tsx]"]
  node_onboarding["Onboarding<br/>[page.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_project_list["Project workspace<br/>[page.tsx]"]
  node_admin["Admin tools"]
end

subgraph group_author["Project authoring"]
  node_project_create["New project<br/>[page.tsx]"]
  node_project_detail["Project details<br/>[page.tsx]"]
  node_editor_page["Editor entry<br/>[page.tsx]"]
  node_editor["Visual editor<br/>[EditorLayout.tsx]"]
  node_panels["Editor panels<br/>[AIChat.tsx]"]
  node_theme["Theme settings<br/>[theme.ts]"]
end

subgraph group_ai["AI services"]
  node_ai_plan["AI project planner<br/>[route.ts]"]
  node_ai_edit["AI design editor<br/>[route.ts]"]
  node_ai_capabilities["Project map, checks, docs<br/>[Services.tsx]"]
end

subgraph group_persistence["Persistence and export"]
  node_save_project["Project save<br/>[route.ts]"]
  node_save_ai["AI project save<br/>[route.ts]"]
  node_save_generated["Generated project save<br/>[route.ts]"]
  node_export["Site ZIP export<br/>[route.ts]"]
  node_supabase_client["Supabase client<br/>[client.ts]"]
  node_supabase_server["Supabase server client<br/>[server.ts]"]
  node_proxy["Supabase proxy<br/>[route.ts]"]
end

node_user(("User"))
node_gemini{{"Gemini API"}}
node_supabase[("Supabase data and auth")]

node_user -->|"signs in"| node_auth_pages
node_user -->|"provides profile"| node_onboarding
node_onboarding -->|"upserts profile"| node_supabase_client
node_supabase_client -->|"auth and data"| node_supabase
node_user -->|"opens workspace"| node_dashboard
node_dashboard -->|"opens projects"| node_project_list
node_user -->|"starts project"| node_project_create
node_project_create -->|"requests plan"| node_ai_plan
node_ai_plan -->|"checks user"| node_supabase_server
node_ai_plan -->|"generates plan"| node_gemini
node_project_list -->|"opens project"| node_project_detail
node_project_detail -->|"opens editor"| node_editor_page
node_editor_page -->|"renders editor"| node_editor
node_editor -->|"renders panels"| node_panels
node_editor -->|"uses theme"| node_theme
node_editor -->|"requests design edit"| node_ai_edit
node_ai_edit -->|"checks user"| node_supabase_server
node_ai_edit -.->|"tries generation"| node_gemini
node_ai_edit -.->|"uses provider keys"| node_supabase
node_editor -->|"saves pages"| node_save_project
node_save_project -->|"checks user"| node_supabase_server
node_save_project -->|"updates project"| node_supabase
node_save_ai -->|"checks user"| node_supabase_server
node_save_ai -->|"updates project"| node_supabase
node_save_generated -->|"checks user"| node_supabase_server
node_save_generated -->|"updates project"| node_supabase
node_export -->|"checks user"| node_supabase_server
node_export -->|"reads project data"| node_supabase
node_user -->|"administers"| node_admin
node_ai_capabilities -.->|"advertises tools"| node_user
node_proxy -->|"forwards requests"| node_supabase

click node_auth_pages "https://github.com/saabhashir07/x-code/blob/main/app/login/page.tsx"
click node_onboarding "https://github.com/saabhashir07/x-code/blob/main/app/onboarding/page.tsx"
click node_dashboard "https://github.com/saabhashir07/x-code/blob/main/app/dashboard/page.tsx"
click node_project_list "https://github.com/saabhashir07/x-code/blob/main/app/dashboard/projects/page.tsx"
click node_admin "https://github.com/saabhashir07/x-code/tree/main/app/admin"
click node_project_create "https://github.com/saabhashir07/x-code/blob/main/app/dashboard/projects/new/page.tsx"
click node_project_detail "https://github.com/saabhashir07/x-code/blob/main/app/dashboard/projects/%5Bid%5D/page.tsx"
click node_editor_page "https://github.com/saabhashir07/x-code/blob/main/app/dashboard/editor/%5Bid%5D/page.tsx"
click node_editor "https://github.com/saabhashir07/x-code/blob/main/components/editor/EditorLayout.tsx"
click node_panels "https://github.com/saabhashir07/x-code/blob/main/components/editor/AIChat.tsx"
click node_theme "https://github.com/saabhashir07/x-code/blob/main/components/editor/theme.ts"
click node_ai_plan "https://github.com/saabhashir07/x-code/blob/main/app/api/ai/generate/route.ts"
click node_ai_edit "https://github.com/saabhashir07/x-code/blob/main/app/api/ai/edit/route.ts"
click node_ai_capabilities "https://github.com/saabhashir07/x-code/blob/main/components/Services.tsx"
click node_save_project "https://github.com/saabhashir07/x-code/blob/main/app/api/projects/save/route.ts"
click node_save_ai "https://github.com/saabhashir07/x-code/blob/main/app/api/ai/projects/save/route.ts"
click node_save_generated "https://github.com/saabhashir07/x-code/blob/main/app/api/ai/generate/projects/save/route.ts"
click node_export "https://github.com/saabhashir07/x-code/blob/main/app/api/projects/export/route.ts"
click node_supabase_client "https://github.com/saabhashir07/x-code/blob/main/lib/supabase/client.ts"
click node_supabase_server "https://github.com/saabhashir07/x-code/blob/main/lib/supabase/server.ts"
click node_proxy "https://github.com/saabhashir07/x-code/blob/main/app/api/proxy/%5B...path%5D/route.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_pages,node_onboarding,node_dashboard,node_project_list,node_admin,node_user toneBlue
class node_project_create,node_project_detail,node_editor_page,node_editor,node_panels,node_theme,node_supabase toneAmber
class node_ai_plan,node_ai_edit,node_ai_capabilities,node_gemini toneMint
class node_save_project,node_save_ai,node_save_generated,node_export,node_supabase_client,node_supabase_server,node_proxy toneRose
```

## Components

### Account and workspace

- [Sign in and signup](https://github.com/saabhashir07/x-code/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Onboarding](https://github.com/saabhashir07/x-code/blob/main/app/onboarding/page.tsx): `app/onboarding/page.tsx`
- [Dashboard](https://github.com/saabhashir07/x-code/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Project workspace](https://github.com/saabhashir07/x-code/blob/main/app/dashboard/projects/page.tsx): `app/dashboard/projects/page.tsx`
- [Admin tools](https://github.com/saabhashir07/x-code/tree/main/app/admin): `app/admin`

### Project authoring

- [New project](https://github.com/saabhashir07/x-code/blob/main/app/dashboard/projects/new/page.tsx): `app/dashboard/projects/new/page.tsx`
- [Project details](https://github.com/saabhashir07/x-code/blob/main/app/dashboard/projects/%5Bid%5D/page.tsx): `app/dashboard/projects/[id]/page.tsx`
- [Editor entry](https://github.com/saabhashir07/x-code/blob/main/app/dashboard/editor/%5Bid%5D/page.tsx): `app/dashboard/editor/[id]/page.tsx`
- [Visual editor](https://github.com/saabhashir07/x-code/blob/main/components/editor/EditorLayout.tsx): `components/editor/EditorLayout.tsx`
- [Editor panels](https://github.com/saabhashir07/x-code/blob/main/components/editor/AIChat.tsx): `components/editor/AIChat.tsx`
- [Theme settings](https://github.com/saabhashir07/x-code/blob/main/components/editor/theme.ts): `components/editor/theme.ts`

### AI services

- [AI project planner](https://github.com/saabhashir07/x-code/blob/main/app/api/ai/generate/route.ts): `app/api/ai/generate/route.ts`
- [AI design editor](https://github.com/saabhashir07/x-code/blob/main/app/api/ai/edit/route.ts): `app/api/ai/edit/route.ts`
- [Project map, checks, docs](https://github.com/saabhashir07/x-code/blob/main/components/Services.tsx): `components/Services.tsx`

### Persistence and export

- [Project save](https://github.com/saabhashir07/x-code/blob/main/app/api/projects/save/route.ts): `app/api/projects/save/route.ts`
- [AI project save](https://github.com/saabhashir07/x-code/blob/main/app/api/ai/projects/save/route.ts): `app/api/ai/projects/save/route.ts`
- [Generated project save](https://github.com/saabhashir07/x-code/blob/main/app/api/ai/generate/projects/save/route.ts): `app/api/ai/generate/projects/save/route.ts`
- [Site ZIP export](https://github.com/saabhashir07/x-code/blob/main/app/api/projects/export/route.ts): `app/api/projects/export/route.ts`
- [Supabase client](https://github.com/saabhashir07/x-code/blob/main/lib/supabase/client.ts): `lib/supabase/client.ts`
- [Supabase server client](https://github.com/saabhashir07/x-code/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`
- [Supabase proxy](https://github.com/saabhashir07/x-code/blob/main/app/api/proxy/%5B...path%5D/route.ts): `app/api/proxy/[...path]/route.ts`

### Other components

- **User**
- **Gemini API**
- **Supabase data and auth**

## Connections

- User → Sign in and signup: signs in
- User → Onboarding: provides profile
- Onboarding → Supabase client: upserts profile
- Supabase client → Supabase data and auth: auth and data
- User → Dashboard: opens workspace
- Dashboard → Project workspace: opens projects
- User → New project: starts project
- New project → AI project planner: requests plan
- AI project planner → Supabase server client: checks user
- AI project planner → Gemini API: generates plan
- Project workspace → Project details: opens project
- Project details → Editor entry: opens editor
- Editor entry → Visual editor: renders editor
- Visual editor → Editor panels: renders panels
- Visual editor → Theme settings: uses theme
- Visual editor → AI design editor: requests design edit
- AI design editor → Supabase server client: checks user
- AI design editor → Gemini API: tries generation
- AI design editor → Supabase data and auth: uses provider keys
- Visual editor → Project save: saves pages
- Project save → Supabase server client: checks user
- Project save → Supabase data and auth: updates project
- AI project save → Supabase server client: checks user
- AI project save → Supabase data and auth: updates project
- Generated project save → Supabase server client: checks user
- Generated project save → Supabase data and auth: updates project
- Site ZIP export → Supabase server client: checks user
- Site ZIP export → Supabase data and auth: reads project data
- User → Admin tools: administers
- Project map, checks, docs → User: advertises tools
- Supabase proxy → Supabase data and auth: forwards requests
