# alex-wang101/vibeboard architecture

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

- Interactive diagram: https://gitdiagram.com/alex-wang101/vibeboard
- Repository: https://github.com/alex-wang101/vibeboard

## Overview

1. **Monorepo shape**
   - The repository is split into four deployable parts: `frontend/` (product app), `backend/` (Express API), `landing/` (marketing site), and `shared/` (common types/utilities).
   - The main product architecture is a **frontend + backend + Supabase + GitHub** system; the landing site is mostly separate.

2. **Frontend boundary**
   - `frontend/` is a Next.js app that owns the user experience: authentication, project management, and the interactive architecture canvas.
   - It uses React/React Flow for visualization, Zustand for canvas state, and a large set of UI primitives from shadcn-style components.
   - Key UI areas are `app/projects/*` for project flows and `components/canvas/*` for the graph editor.

3. **Authentication and session flow**
   - GitHub OAuth is handled in the frontend via NextAuth (`app/api/auth/[...nextauth]/route.ts`).
   - The README indicates that after sign-in, the user is upserted into Supabase and their GitHub access token is stored encrypted; the raw token is never exposed to the browser.
   - The frontend relies on session cookies and an API proxy rather than directly calling the backend with sensitive credentials.

4. **Backend boundary**
   - `backend/` is a separate Express service that contains the server-side integration logic.
   - Its public routes are organized by domain: `projects`, `scanner`, `github`, and `architecture`.
   - A GitHub-auth middleware sits in front of trusted routes, implying the backend expects a verified user identity forwarded from the frontend proxy.

5. **Proxy/BFF pattern**
   - The frontend has `app/api/proxy/[...path]/route.ts`, which acts as a backend-for-frontend bridge.
   - This proxy reads the authenticated session server-side and forwards a trusted user identifier to the Express API.
   - This is the main trust boundary: the browser talks to Next.js; Next.js talks to Express on behalf of the user.

6. **GitHub integration and scanning pipeline**
   - Backend services in `backend/src/services/` include `github.ts`, `scanner.ts`, and `classifier.ts`.
   - The flow is: resolve the user’s GitHub identity, fetch/decrypt the stored token from Supabase, interact with GitHub/Octokit, clone or inspect repositories, and scan source code with `ts-morph`.
   - The output of that pipeline is an architecture model rather than raw source listings.

7. **Architecture model and shared contract**
   - The central data contract is the `ArchitectureGraph` type, shared between frontend and backend via `shared/`.
   - This graph represents hierarchical nodes such as pages, components, API routes, services, folders/files, and dependency edges between them.
   - Because the same model is used for scanned repositories and blank-canvas design, it is the core object to show in any system diagram.

8. **Persistence layer**
   - Supabase/Postgres is the main persistent store.
   - Backend storage is abstracted behind `backend/src/storage/*`, with both a `supabase-store` and an in-memory store, suggesting the app can run with either persistent or ephemeral storage.
   - Frontend migrations show the persisted entities likely include users, waitlist entries, projects, and project scans/architectures.

9. **Project lifecycle**
   - The frontend’s project pages support creating and browsing projects, and each project can be associated with a repo scan or a hand-authored architecture board.
   - Components like `repo-picker`, `contributor-picker`, and `architecture-tree-widget` indicate project metadata, repo selection, and collaborator management are first-class concepts.
   - The backend routes likely supply CRUD and scan operations for these projects.

10. **Canvas/editor subsystem**
   - The canvas is a substantial client-side subsystem built on React Flow.
   - It includes node types for files, folders, and infrastructure, plus custom edges, breadcrumb navigation, hover previews, palettes, and detail panels.
   - This subsystem consumes the `ArchitectureGraph` and renders/edit it interactively.

11. **Storage of secrets and user identity**
   - `shared/src/crypto.ts` and the README point to AES-256-GCM encryption for access tokens.
   - Supabase is therefore not just an app database; it also acts as the secure token store used by backend GitHub operations.
   - The backend is the only place that decrypts and uses those tokens.

12. **Landing site**
   - `landing/` is a separate Next.js application for marketing and waitlist capture.
   - It is not part of the core architecture editing/scanning path, but it is a distinct public-facing surface with its own deployable runtime.

13. **What to draw as the main architecture**
   - The most important diagram should show: user browser → Next.js frontend/auth/proxy → Express backend → Supabase + GitHub.
   - Inside the frontend, separate the auth/session layer from the canvas/project UI.
   - Inside the backend, separate route handling from services (GitHub/scanner/classifier) and from storage.
   - Treat `shared/` as a compile-time contract layer that keeps the frontend and backend on the same `ArchitectureGraph` schema.

Main entry points: [`frontend/app/page.tsx`](https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/page.tsx) (Product app), [`backend/src/index.ts`](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/index.ts) (API server), [`backend/src/services/github.ts`](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/github.ts) (GitHub service), [`backend/src/storage/supabase-store.ts`](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/storage/supabase-store.ts) (Storage layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_external["External"]
  node_user_browser(("User browser<br/>client"))
end

subgraph group_frontend["Frontend"]
  node_frontend_app["Product app<br/>nextjs app<br/>[page.tsx]"]
  node_frontend_auth_route["Auth route<br/>nextauth<br/>[route.ts]"]
  node_frontend_proxy_route["API proxy<br/>bff route<br/>[route.ts]"]
  node_frontend_auth_provider["Auth session<br/>session layer<br/>[auth-provider.tsx]"]
  node_frontend_projects_ui["Projects UI<br/>project shell<br/>[page.tsx]"]
  node_frontend_canvas["Canvas editor<br/>react flow editor"]
  node_frontend_canvas_store["Canvas state<br/>zustand store<br/>[canvas-store.ts]"]
  node_frontend_project_widgets["Project widgets<br/>ui components<br/>[repo-picker.tsx]"]
  node_frontend_graph_lib["Graph utils<br/>client contract"]
end

subgraph group_backend["Backend"]
  node_backend_entry["API server<br/>express app<br/>[index.ts]"]
  node_backend_github_auth["GitHub auth<br/>middleware<br/>[github-auth.ts]"]
  node_backend_projects_route["Projects route<br/>api route<br/>[projects.ts]"]
  node_backend_scanner_route["Scanner route<br/>api route<br/>[scanner.ts]"]
  node_backend_github_route["GitHub route<br/>api route<br/>[github.ts]"]
  node_backend_architecture_route["Architecture route<br/>api route<br/>[architecture.ts]"]
  node_backend_github_service["GitHub service<br/>integration service<br/>[github.ts]"]
  node_backend_scanner_service["Scanner service<br/>analysis pipeline<br/>[scanner.ts]"]
  node_backend_classifier_service["Classifier<br/>analysis service<br/>[classifier.ts]"]
  node_backend_storage[("Storage layer<br/>repo storage<br/>[supabase-store.ts]")]
  node_backend_supabase_lib["Supabase client<br/>db client<br/>[supabase.ts]"]
end

subgraph group_shared["Shared"]
  node_shared_contract["ArchitectureGraph<br/>shared schema<br/>[types.ts]"]
  node_shared_crypto["Crypto<br/>encryption util<br/>[crypto.ts]"]
end

subgraph group_landing["Landing"]
  node_landing_site["Landing site<br/>nextjs app<br/>[page.tsx]"]
end

node_user_browser -->|"uses"| node_frontend_app
node_frontend_app -->|"sign in"| node_frontend_auth_route
node_frontend_auth_route -.->|"identity"| node_backend_github_service
node_frontend_app -->|"api calls"| node_frontend_proxy_route
node_frontend_proxy_route -->|"forwards"| node_backend_entry
node_frontend_auth_provider -->|"session"| node_frontend_app
node_frontend_app -->|"projects"| node_frontend_projects_ui
node_frontend_projects_ui -->|"tools"| node_frontend_project_widgets
node_frontend_app -->|"edit"| node_frontend_canvas
node_frontend_canvas -->|"state"| node_frontend_canvas_store
node_frontend_canvas -->|"renders"| node_shared_contract
node_frontend_graph_lib -->|"uses"| node_shared_contract
node_frontend_graph_lib -->|"save"| node_frontend_proxy_route
node_backend_entry -->|"protects"| node_backend_github_auth
node_backend_entry -->|"mounts"| node_backend_projects_route
node_backend_entry -->|"mounts"| node_backend_scanner_route
node_backend_entry -->|"mounts"| node_backend_github_route
node_backend_entry -->|"mounts"| node_backend_architecture_route
node_backend_projects_route -->|"persists"| node_backend_storage
node_backend_architecture_route -->|"persists"| node_backend_storage
node_backend_github_route -->|"delegates"| node_backend_github_service
node_backend_scanner_route -->|"delegates"| node_backend_scanner_service
node_backend_scanner_service -->|"classifies"| node_backend_classifier_service
node_backend_scanner_service -->|"fetches repo"| node_backend_github_service
node_backend_github_service -->|"loads token"| node_backend_supabase_lib
node_backend_storage -->|"db"| node_backend_supabase_lib
node_backend_github_service -->|"decrypts"| node_shared_crypto
node_backend_storage -->|"stores graph"| node_shared_contract
node_frontend_app -.->|"separate site"| node_landing_site

click node_frontend_app "https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/page.tsx"
click node_frontend_auth_route "https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/api/auth/[...nextauth]/route.ts"
click node_frontend_proxy_route "https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/api/proxy/[...path]/route.ts"
click node_frontend_auth_provider "https://github.com/alex-wang101/vibeboard/blob/main/frontend/providers/auth-provider.tsx"
click node_frontend_projects_ui "https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/projects/page.tsx"
click node_frontend_canvas "https://github.com/alex-wang101/vibeboard/blob/main/frontend/components/canvas/architecture-canvas.tsx"
click node_frontend_canvas_store "https://github.com/alex-wang101/vibeboard/blob/main/frontend/stores/canvas-store.ts"
click node_frontend_project_widgets "https://github.com/alex-wang101/vibeboard/blob/main/frontend/components/projects/repo-picker.tsx"
click node_frontend_graph_lib "https://github.com/alex-wang101/vibeboard/blob/main/frontend/lib/architecture-graph.ts"
click node_backend_entry "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/index.ts"
click node_backend_github_auth "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/middleware/github-auth.ts"
click node_backend_projects_route "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/projects.ts"
click node_backend_scanner_route "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/scanner.ts"
click node_backend_github_route "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/github.ts"
click node_backend_architecture_route "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/architecture.ts"
click node_backend_github_service "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/github.ts"
click node_backend_scanner_service "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/scanner.ts"
click node_backend_classifier_service "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/classifier.ts"
click node_backend_storage "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/storage/supabase-store.ts"
click node_backend_supabase_lib "https://github.com/alex-wang101/vibeboard/blob/main/backend/src/lib/supabase.ts"
click node_shared_contract "https://github.com/alex-wang101/vibeboard/blob/main/shared/src/types.ts"
click node_shared_crypto "https://github.com/alex-wang101/vibeboard/blob/main/shared/src/crypto.ts"
click node_landing_site "https://github.com/alex-wang101/vibeboard/blob/main/landing/app/page.tsx"

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_user_browser toneBlue
class node_frontend_app,node_frontend_auth_route,node_frontend_proxy_route,node_frontend_auth_provider,node_frontend_projects_ui,node_frontend_canvas,node_frontend_canvas_store,node_frontend_project_widgets,node_frontend_graph_lib toneAmber
class node_backend_entry,node_backend_github_auth,node_backend_projects_route,node_backend_scanner_route,node_backend_github_route,node_backend_architecture_route,node_backend_github_service,node_backend_scanner_service,node_backend_classifier_service,node_backend_storage,node_backend_supabase_lib toneMint
class node_shared_contract,node_shared_crypto toneRose
class node_landing_site toneIndigo
```

## Components

### External

Users and third-party platforms outside the repo

- **User browser**: client · People using the product app and interacting with the canvas

### Frontend

Next.js product app and browser-side architecture editor

- [Product app](https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/page.tsx): nextjs app · Main Next.js application for authentication, projects, and editing · `frontend/app/page.tsx`
- [Auth route](https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/api/auth/[...nextauth]/route.ts): nextauth · GitHub OAuth session endpoint for sign-in and cookies · `frontend/app/api/auth/[...nextauth]/route.ts`
- [API proxy](https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/api/proxy/[...path]/route.ts): bff route · Server-side bridge that forwards authenticated requests to the backend · `frontend/app/api/proxy/[...path]/route.ts`
- [Auth session](https://github.com/alex-wang101/vibeboard/blob/main/frontend/providers/auth-provider.tsx): session layer · Client-side auth/session wiring used across the product app · `frontend/providers/auth-provider.tsx`
- [Projects UI](https://github.com/alex-wang101/vibeboard/blob/main/frontend/app/projects/page.tsx): project shell · Project list, creation, repo selection, and project detail pages · `frontend/app/projects/page.tsx`
- [Canvas editor](https://github.com/alex-wang101/vibeboard/blob/main/frontend/components/canvas/architecture-canvas.tsx): react flow editor · Interactive architecture canvas and related controls · `frontend/components/canvas/architecture-canvas.tsx`
- [Canvas state](https://github.com/alex-wang101/vibeboard/blob/main/frontend/stores/canvas-store.ts): zustand store · Client state for nodes, edges, selection, and editor interactions · `frontend/stores/canvas-store.ts`
- [Project widgets](https://github.com/alex-wang101/vibeboard/blob/main/frontend/components/projects/repo-picker.tsx): ui components · Repo picker, contributor picker, and architecture tree widgets · `frontend/components/projects/repo-picker.tsx`
- [Graph utils](https://github.com/alex-wang101/vibeboard/blob/main/frontend/lib/architecture-graph.ts): client contract · Frontend-side ArchitectureGraph helpers and save workflow · `frontend/lib/architecture-graph.ts`

### Backend

Express API and integration services

- [API server](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/index.ts): express app · Express service entrypoint that mounts all backend routes · `backend/src/index.ts`
- [GitHub auth](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/middleware/github-auth.ts): middleware · Trusted-route guard for requests forwarded from the frontend proxy · `backend/src/middleware/github-auth.ts`
- [Projects route](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/projects.ts): api route · Project CRUD and project-scoped operations · `backend/src/routes/projects.ts`
- [Scanner route](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/scanner.ts): api route · Repository scanning and architecture extraction endpoint · `backend/src/routes/scanner.ts`
- [GitHub route](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/github.ts): api route · GitHub identity and repository integration endpoint · `backend/src/routes/github.ts`
- [Architecture route](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/routes/architecture.ts): api route · Architecture model CRUD and retrieval endpoint · `backend/src/routes/architecture.ts`
- [GitHub service](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/github.ts): integration service · Resolves user identity, accesses Octokit, and works with stored tokens · `backend/src/services/github.ts`
- [Scanner service](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/scanner.ts): analysis pipeline · Clones or inspects repositories and scans source with ts-morph · `backend/src/services/scanner.ts`
- [Classifier](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/services/classifier.ts): analysis service · Classifies scanned files into architectural roles and hierarchies · `backend/src/services/classifier.ts`
- [Storage layer](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/storage/supabase-store.ts): repo storage · Abstracted persistence with Supabase and in-memory implementations · `backend/src/storage/supabase-store.ts`
- [Supabase client](https://github.com/alex-wang101/vibeboard/blob/main/backend/src/lib/supabase.ts): db client · Server-side Supabase connection and access helpers · `backend/src/lib/supabase.ts`

### Shared

Compile-time contract and cross-app utilities

- [ArchitectureGraph](https://github.com/alex-wang101/vibeboard/blob/main/shared/src/types.ts): shared schema · Shared data contract for scanned and hand-authored architecture graphs · `shared/src/types.ts`
- [Crypto](https://github.com/alex-wang101/vibeboard/blob/main/shared/src/crypto.ts): encryption util · AES-256-GCM helpers for protecting GitHub access tokens · `shared/src/crypto.ts`

### Landing

Separate marketing and waitlist site

- [Landing site](https://github.com/alex-wang101/vibeboard/blob/main/landing/app/page.tsx): nextjs app · Separate marketing and waitlist runtime · `landing/app/page.tsx`

## Connections

- User browser → Product app: uses · Users interact with the product app in the browser
- Product app → Auth route: sign in · OAuth session creation happens through NextAuth
- Auth route → GitHub service: identity · Auth flow establishes the GitHub-linked user identity
- Product app → API proxy: api calls · Browser requests go to the Next.js proxy rather than directly to the backend
- API proxy → API server: forwards · Proxy forwards trusted user context to the Express API
- Auth session → Product app: session · Provides authenticated session state to the product UI
- Product app → Projects UI: projects · Project pages drive creation, browsing, and collaboration flows
- Projects UI → Project widgets: tools · Project flows use repo selection and collaborator widgets
- Product app → Canvas editor: edit · The main product surface is the architecture canvas
- Canvas editor → Canvas state: state · Canvas interactions are managed in Zustand state
- Canvas editor → ArchitectureGraph: renders · Canvas consumes the shared ArchitectureGraph schema
- Graph utils → ArchitectureGraph: uses · Frontend helpers operate on the shared graph model
- Graph utils → API proxy: save · Persisting edits typically goes through the authenticated proxy
- API server → GitHub auth: protects · Trusted routes are guarded before reaching domain handlers
- API server → Projects route: mounts · Project CRUD is exposed through route handlers
- API server → Scanner route: mounts · Scanning operations are exposed through route handlers
- API server → GitHub route: mounts · GitHub-related backend operations are exposed through route handlers
- API server → Architecture route: mounts · Architecture data is served through dedicated routes
- Projects route → Storage layer: persists · Projects are stored through the backend storage abstraction
- Architecture route → Storage layer: persists · Architecture records are saved and loaded through storage
- GitHub route → GitHub service: delegates · Route handlers delegate GitHub operations to services
- Scanner route → Scanner service: delegates · Scan requests enter the repository analysis pipeline
- Scanner service → Classifier: classifies · Scan output is organized into architectural roles and hierarchy
- Scanner service → GitHub service: fetches repo · Scanner uses GitHub access to inspect repositories
- GitHub service → Supabase client: loads token · GitHub integration reads stored user credentials from Supabase
- Storage layer → Supabase client: db · Supabase-backed persistence is one storage implementation
- GitHub service → Crypto: decrypts · Stored GitHub access tokens are decrypted before use
- Storage layer → ArchitectureGraph: stores graph · Persisted scans and boards use the shared ArchitectureGraph schema
- Product app → Landing site: separate site · Marketing and waitlist pages are a distinct runtime from the product app
