# kushsharma260910/planpilot architecture

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

- Interactive diagram: https://gitdiagram.com/kushsharma260910/planpilot
- Repository: https://github.com/kushsharma260910/planpilot

## Overview

1. **What this repo is**
   - PlanPilot is a single-page React application built with Vite and TypeScript.
   - It appears to be a planning/workflow product centered on “charters,” projects, tasks, analytics, and behavior/burnout guidance.

2. **Top-level application shape**
   - The app is mostly client-side UI with route-based pages under `src/pages`.
   - There is no custom backend server in this repo; persistence and auth are delegated to Supabase.

3. **Routing and page boundaries**
   - The main user-facing surfaces are:
     - `LandingPage` for marketing/entry
     - `Auth` for sign-in/onboarding
     - `DashboardPage` as the authenticated home
     - `CharterPage` for charter creation/review/display
     - `TasksPage` and `AnalyticsPage` for operational views
     - `NotFound` for fallback routing
   - `Index.tsx` likely handles the root route and initial redirect behavior.

4. **Authenticated app shell**
   - `DashboardLayout` and `NavLink` suggest a shared shell for authenticated sections.
   - This is the main UI boundary between public pages and the product workspace.
   - Navigation likely switches between dashboard, tasks, analytics, and charter-related screens without leaving the SPA.

5. **Core product workflow**
   - The charter flow is a central domain:
     - `CharterWizard` gathers inputs
     - `CharterReview` validates or confirms the draft
     - `CharterDisplay` renders the final charter
   - `ProjectDialog`, `TagInput`, and `SuggestionChips` support project metadata entry and guided input.

6. **Decision support / domain logic**
   - `behavior-engine.ts` and `BurnoutIndicator.tsx` indicate a lightweight domain engine that scores or interprets user/project signals.
   - `charter-generator.ts` likely transforms collected inputs into a structured charter.
   - This logic sits in `src/lib`, separate from presentation components, so the UI can stay mostly declarative.

7. **Export and document generation**
   - `charter-pdf.ts` suggests a browser-side or client-triggered PDF export path for charters.
   - This is a distinct output boundary: data is assembled in the app, then rendered into a downloadable document.

8. **Data layer and backend integration**
   - `src/integrations/supabase/client.ts` is the main backend client entry point.
   - `src/integrations/supabase/types.ts` indicates generated typed schema usage, so UI and lib code likely rely on Supabase table types.
   - The `supabase/migrations` directory shows the data model is managed as database migrations rather than local mocks.

9. **Authentication boundary**
   - `src/lib/auth.tsx` centralizes auth-related state or helpers.
   - `Auth.tsx` is the user-facing entry point, while the Supabase client handles identity/session persistence.
   - This keeps auth concerns separate from the rest of the workspace UI.

10. **UI system**
   - The app uses a component library pattern similar to shadcn/ui: `src/components/ui/*`.
   - Tailwind is present via `tailwind.config.ts` and `postcss.config.js`, so styling is utility-driven.
   - Shared primitives like dialogs, tabs, inputs, tables, and toasts are reused across the product screens.

11. **State, feedback, and responsiveness**
   - Custom hooks such as `use-toast.ts` and `use-mobile.tsx` provide app-wide interaction support.
   - Toasts and dialogs are the main ephemeral UI feedback mechanisms.
   - Responsive behavior is handled in the client rather than through separate device-specific apps.

12. **Testing and quality gates**
   - The repo includes both unit-style tests (`src/test`, Vitest config) and browser/E2E setup (`playwright.config.ts`, `playwright-fixture.ts`).
   - This implies the architecture is tested at two levels: isolated logic/components and end-to-end user flows.

13. **Static assets and entrypoints**
   - `index.html`, `src/main.tsx`, and `src/index.css` form the browser bootstrap path.
   - `public/robots.txt` and the `public` folder are the only notable static asset surface.

14. **How to draw the architecture**
   - A clear diagram would show:
     - Browser SPA on the left
     - Route-level pages at the center
     - Shared UI/components and domain libs beneath them
     - Supabase auth/database on the right as the external backend
     - PDF/export as a secondary output path
     - Test tooling as a separate quality lane around the app, not part of runtime

Main entry points: [`src/pages/Index.tsx`](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/Index.tsx) (Router), [`src/pages/CharterPage.tsx`](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/CharterPage.tsx) (Charter), [`src/components/CharterWizard.tsx`](https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterWizard.tsx) (Wizard), [`src/components/ui`](https://github.com/kushsharma260910/planpilot/tree/main/src/components/ui) (UI Primitives)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_bootstrap(("Bootstrap<br/>vite entry<br/>[main.tsx]"))
  node_router["Router<br/>route switch<br/>[Index.tsx]"]
  node_appshell["App Shell<br/>spa shell<br/>[App.tsx]"]
  node_landing["Landing<br/>public page<br/>[LandingPage.tsx]"]
  node_authpage["Auth<br/>access page<br/>[Auth.tsx]"]
  node_notfound["Not Found<br/>fallback page<br/>[NotFound.tsx]"]
end

subgraph group_workspace["Workspace"]
  node_dashboard["Dashboard<br/>workspace page<br/>[DashboardPage.tsx]"]
  node_tasks["Tasks<br/>workspace page<br/>[TasksPage.tsx]"]
  node_analytics["Analytics<br/>workspace page<br/>[AnalyticsPage.tsx]"]
  node_layout["Layout<br/>nav shell"]
  node_navlink["Nav Link<br/>nav component<br/>[NavLink.tsx]"]
  node_ui["UI Primitives<br/>component kit"]
  node_hooks["Hooks"]
end

subgraph group_charter["Charter Flow"]
  node_charterpage["Charter<br/>workspace page<br/>[CharterPage.tsx]"]
  node_wizard["Wizard<br/>charter form<br/>[CharterWizard.tsx]"]
  node_review["Review<br/>charter check<br/>[CharterReview.tsx]"]
  node_display["Display<br/>charter view<br/>[CharterDisplay.tsx]"]
  node_projectdialog["Project Dialog<br/>entry dialog<br/>[ProjectDialog.tsx]"]
  node_taginput["Tag Input<br/>input helper<br/>[TagInput.tsx]"]
  node_chips["Suggestions<br/>input helper"]
end

subgraph group_domain["Domain Logic"]
  node_burnout["Burnout<br/>signal widget"]
  node_authlib["Auth Lib<br/>session logic<br/>[auth.tsx]"]
  node_behavior["Behavior Engine<br/>scoring logic<br/>[behavior-engine.ts]"]
  node_generator["Generator<br/>charter logic"]
  node_pdf["PDF Export<br/>export helper<br/>[charter-pdf.ts]"]
end

subgraph group_backend["Supabase"]
  node_supabaseclient["Supabase Client<br/>backend client<br/>[client.ts]"]
  node_supabasetypes["DB Types<br/>generated schema<br/>[types.ts]"]
  node_migrations[("Migrations<br/>db schema")]
end

subgraph group_quality["Quality"]
  node_vitest["Vitest<br/>unit tests"]
  node_playwright["Playwright<br/>e2e tests"]
end

node_bootstrap -->|"mounts"| node_router
node_router -->|"renders"| node_appshell
node_router -->|"route"| node_landing
node_router -->|"route"| node_authpage
node_router -->|"route"| node_dashboard
node_router -->|"route"| node_tasks
node_router -->|"route"| node_analytics
node_router -->|"route"| node_charterpage
node_router -->|"fallback"| node_notfound
node_dashboard -->|"uses"| node_layout
node_tasks -->|"uses"| node_layout
node_analytics -->|"uses"| node_layout
node_charterpage -->|"uses"| node_layout
node_layout -->|"nav"| node_navlink
node_charterpage -->|"flow"| node_wizard
node_charterpage -->|"flow"| node_review
node_charterpage -->|"flow"| node_display
node_wizard -->|"input"| node_projectdialog
node_wizard -->|"input"| node_taginput
node_wizard -->|"assist"| node_chips
node_wizard -->|"builds"| node_generator
node_review -->|"checks"| node_behavior
node_burnout -->|"reads"| node_behavior
node_display -->|"exports"| node_pdf
node_authpage -->|"uses"| node_authlib
node_dashboard -->|"guards"| node_authlib
node_charterpage -->|"guards"| node_authlib
node_authlib -->|"session"| node_supabaseclient
node_supabaseclient -->|"typed by"| node_supabasetypes
node_migrations -->|"defines"| node_supabasetypes
node_supabaseclient -->|"backed by"| node_migrations
node_dashboard -->|"shows"| node_burnout
node_landing -->|"uses"| node_ui
node_authpage -->|"uses"| node_ui
node_layout -->|"uses"| node_ui
node_wizard -->|"uses"| node_ui
node_review -->|"uses"| node_ui
node_display -->|"uses"| node_ui
node_hooks -->|"supports"| node_ui
node_vitest -->|"tests"| node_behavior
node_vitest -->|"tests"| node_generator
node_playwright -->|"drives"| node_router
node_playwright -->|"drives"| node_charterpage

click node_bootstrap "https://github.com/kushsharma260910/planpilot/blob/main/src/main.tsx"
click node_router "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/Index.tsx"
click node_appshell "https://github.com/kushsharma260910/planpilot/blob/main/src/App.tsx"
click node_landing "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/LandingPage.tsx"
click node_authpage "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/Auth.tsx"
click node_dashboard "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/DashboardPage.tsx"
click node_tasks "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/TasksPage.tsx"
click node_analytics "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/AnalyticsPage.tsx"
click node_charterpage "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/CharterPage.tsx"
click node_notfound "https://github.com/kushsharma260910/planpilot/blob/main/src/pages/NotFound.tsx"
click node_layout "https://github.com/kushsharma260910/planpilot/blob/main/src/components/DashboardLayout.tsx"
click node_navlink "https://github.com/kushsharma260910/planpilot/blob/main/src/components/NavLink.tsx"
click node_wizard "https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterWizard.tsx"
click node_review "https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterReview.tsx"
click node_display "https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterDisplay.tsx"
click node_projectdialog "https://github.com/kushsharma260910/planpilot/blob/main/src/components/ProjectDialog.tsx"
click node_taginput "https://github.com/kushsharma260910/planpilot/blob/main/src/components/TagInput.tsx"
click node_chips "https://github.com/kushsharma260910/planpilot/blob/main/src/components/SuggestionChips.tsx"
click node_burnout "https://github.com/kushsharma260910/planpilot/blob/main/src/components/BurnoutIndicator.tsx"
click node_authlib "https://github.com/kushsharma260910/planpilot/blob/main/src/lib/auth.tsx"
click node_behavior "https://github.com/kushsharma260910/planpilot/blob/main/src/lib/behavior-engine.ts"
click node_generator "https://github.com/kushsharma260910/planpilot/blob/main/src/lib/charter-generator.ts"
click node_pdf "https://github.com/kushsharma260910/planpilot/blob/main/src/lib/charter-pdf.ts"
click node_supabaseclient "https://github.com/kushsharma260910/planpilot/blob/main/src/integrations/supabase/client.ts"
click node_supabasetypes "https://github.com/kushsharma260910/planpilot/blob/main/src/integrations/supabase/types.ts"
click node_migrations "https://github.com/kushsharma260910/planpilot/tree/main/supabase/migrations"
click node_ui "https://github.com/kushsharma260910/planpilot/tree/main/src/components/ui"
click node_hooks "https://github.com/kushsharma260910/planpilot/tree/main/src/hooks"
click node_vitest "https://github.com/kushsharma260910/planpilot/tree/main/src/test"
click node_playwright "https://github.com/kushsharma260910/planpilot/blob/main/playwright.config.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_bootstrap,node_router,node_appshell,node_landing,node_authpage,node_notfound toneBlue
class node_dashboard,node_tasks,node_analytics,node_layout,node_navlink,node_ui,node_hooks toneAmber
class node_charterpage,node_wizard,node_review,node_display,node_projectdialog,node_taginput,node_chips toneMint
class node_burnout,node_authlib,node_behavior,node_generator,node_pdf toneRose
class node_supabaseclient,node_supabasetypes,node_migrations toneIndigo
class node_vitest,node_playwright toneTeal
```

## Components

### Runtime

Browser entry, routing, and top-level pages.

- [Bootstrap](https://github.com/kushsharma260910/planpilot/blob/main/src/main.tsx): vite entry · Browser entrypoint that mounts the app. · `src/main.tsx`
- [Router](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/Index.tsx): route switch · Root route selection and initial navigation. · `src/pages/Index.tsx`
- [App Shell](https://github.com/kushsharma260910/planpilot/blob/main/src/App.tsx): spa shell · Top-level application container and styling boundary. · `src/App.tsx`
- [Landing](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/LandingPage.tsx): public page · Marketing and entry surface for unauthenticated users. · `src/pages/LandingPage.tsx`
- [Auth](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/Auth.tsx): access page · Sign-in and onboarding entry point. · `src/pages/Auth.tsx`
- [Not Found](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/NotFound.tsx): fallback page · Route fallback for unknown paths. · `src/pages/NotFound.tsx`

### Workspace

Authenticated product surfaces and shared shell.

- [Dashboard](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/DashboardPage.tsx): workspace page · Authenticated home and workspace overview. · `src/pages/DashboardPage.tsx`
- [Tasks](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/TasksPage.tsx): workspace page · Operational task management view. · `src/pages/TasksPage.tsx`
- [Analytics](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/AnalyticsPage.tsx): workspace page · Metrics and insight view for the workspace. · `src/pages/AnalyticsPage.tsx`
- [Layout](https://github.com/kushsharma260910/planpilot/blob/main/src/components/DashboardLayout.tsx): nav shell · Shared authenticated layout and navigation container. · `src/components/DashboardLayout.tsx`
- [Nav Link](https://github.com/kushsharma260910/planpilot/blob/main/src/components/NavLink.tsx): nav component · Reusable navigation item for the shell. · `src/components/NavLink.tsx`
- [UI Primitives](https://github.com/kushsharma260910/planpilot/tree/main/src/components/ui): component kit · Shared reusable UI building blocks. · `src/components/ui`
- [Hooks](https://github.com/kushsharma260910/planpilot/tree/main/src/hooks): client hooks · App-wide helpers for mobile detection and toast state. · `src/hooks`

### Charter Flow

Guided charter creation, review, and rendering.

- [Charter](https://github.com/kushsharma260910/planpilot/blob/main/src/pages/CharterPage.tsx): workspace page · Charter creation, review, and display surface. · `src/pages/CharterPage.tsx`
- [Wizard](https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterWizard.tsx): charter form · Guided input flow for charter creation. · `src/components/CharterWizard.tsx`
- [Review](https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterReview.tsx): charter check · Draft validation and confirmation step. · `src/components/CharterReview.tsx`
- [Display](https://github.com/kushsharma260910/planpilot/blob/main/src/components/CharterDisplay.tsx): charter view · Final charter presentation and rendering. · `src/components/CharterDisplay.tsx`
- [Project Dialog](https://github.com/kushsharma260910/planpilot/blob/main/src/components/ProjectDialog.tsx): entry dialog · Project metadata entry and editing modal. · `src/components/ProjectDialog.tsx`
- [Tag Input](https://github.com/kushsharma260910/planpilot/blob/main/src/components/TagInput.tsx): input helper · Tag entry control used in charter setup. · `src/components/TagInput.tsx`
- [Suggestions](https://github.com/kushsharma260910/planpilot/blob/main/src/components/SuggestionChips.tsx): input helper · Guided suggestions for faster input. · `src/components/SuggestionChips.tsx`

### Domain Logic

Client-side business logic and export helpers.

- [Burnout](https://github.com/kushsharma260910/planpilot/blob/main/src/components/BurnoutIndicator.tsx): signal widget · Behavior and burnout indicator component. · `src/components/BurnoutIndicator.tsx`
- [Auth Lib](https://github.com/kushsharma260910/planpilot/blob/main/src/lib/auth.tsx): session logic · Central auth/session helpers and state. · `src/lib/auth.tsx`
- [Behavior Engine](https://github.com/kushsharma260910/planpilot/blob/main/src/lib/behavior-engine.ts): scoring logic · Interprets signals into behavior or burnout guidance. · `src/lib/behavior-engine.ts`
- [Generator](https://github.com/kushsharma260910/planpilot/blob/main/src/lib/charter-generator.ts): charter logic · Transforms collected inputs into a structured charter. · `src/lib/charter-generator.ts`
- [PDF Export](https://github.com/kushsharma260910/planpilot/blob/main/src/lib/charter-pdf.ts): export helper · Browser-side charter export and document generation. · `src/lib/charter-pdf.ts`

### Supabase

Authentication, typed data access, and database schema.

- [Supabase Client](https://github.com/kushsharma260910/planpilot/blob/main/src/integrations/supabase/client.ts): backend client · Primary Supabase entrypoint for auth and data access. · `src/integrations/supabase/client.ts`
- [DB Types](https://github.com/kushsharma260910/planpilot/blob/main/src/integrations/supabase/types.ts): generated schema · Typed Supabase schema bindings used by the app. · `src/integrations/supabase/types.ts`
- [Migrations](https://github.com/kushsharma260910/planpilot/tree/main/supabase/migrations): db schema · Database schema history managed in Supabase migrations. · `supabase/migrations`

### Quality

Unit and end-to-end test tooling.

- [Vitest](https://github.com/kushsharma260910/planpilot/tree/main/src/test): unit tests · Unit and component test harness. · `src/test`
- [Playwright](https://github.com/kushsharma260910/planpilot/blob/main/playwright.config.ts): e2e tests · Browser automation and end-to-end test setup. · `playwright.config.ts`

## Connections

- Bootstrap → Router: mounts · Bootstraps the SPA and hands control to routing.
- Router → App Shell: renders · Root routing feeds the application shell.
- Router → Landing: route · Public entry surface.
- Router → Auth: route · Authentication entry surface.
- Router → Dashboard: route · Authenticated workspace home.
- Router → Tasks: route · Task management surface.
- Router → Analytics: route · Analytics surface.
- Router → Charter: route · Charter workflow surface.
- Router → Not Found: fallback · Unknown route handling.
- Dashboard → Layout: uses · Dashboard is wrapped by the shared workspace shell.
- Tasks → Layout: uses · Tasks view uses the shared workspace shell.
- Analytics → Layout: uses · Analytics view uses the shared workspace shell.
- Charter → Layout: uses · Charter workspace uses the shared shell.
- Layout → Nav Link: nav · Layout composes reusable navigation links.
- Charter → Wizard: flow · Charter page starts with guided input.
- Charter → Review: flow · Charter page includes review and confirmation.
- Charter → Display: flow · Charter page ends with rendered output.
- Wizard → Project Dialog: input · Wizard opens project metadata dialogs.
- Wizard → Tag Input: input · Wizard collects tags through a dedicated control.
- Wizard → Suggestions: assist · Wizard offers guided suggestions.
- Wizard → Generator: builds · Wizard feeds charter generation logic.
- Review → Behavior Engine: checks · Review step consults behavior scoring and guidance.
- Burnout → Behavior Engine: reads · Burnout indicator visualizes scoring output.
- Display → PDF Export: exports · Final charter can be turned into a PDF artifact.
- Auth → Auth Lib: uses · Auth page relies on centralized auth helpers.
- Dashboard → Auth Lib: guards · Authenticated workspace depends on session state.
- Charter → Auth Lib: guards · Charter workflow depends on session state.
- Auth Lib → Supabase Client: session · Auth helpers are backed by Supabase authentication.
- Supabase Client → DB Types: typed by · Client uses generated database types.
- Migrations → DB Types: defines · Database schema underpins the generated types.
- Supabase Client → Migrations: backed by · Client talks to the schema managed in migrations.
- Dashboard → Burnout: shows · Dashboard can surface behavior/burnout signals.
- Landing → UI Primitives: uses · Public pages share the UI kit.
- Auth → UI Primitives: uses · Auth surfaces use shared primitives.
- Layout → UI Primitives: uses · Workspace shell is built from shared primitives.
- Wizard → UI Primitives: uses · Charter wizard is assembled from shared primitives.
- Review → UI Primitives: uses · Review step is assembled from shared primitives.
- Display → UI Primitives: uses · Display view is assembled from shared primitives.
- Hooks → UI Primitives: supports · Client hooks complement the component kit.
- Vitest → Behavior Engine: tests · Unit tests likely cover core decision logic.
- Vitest → Generator: tests · Unit tests likely cover charter generation.
- Playwright → Router: drives · E2E flows exercise route navigation.
- Playwright → Charter: drives · E2E flows cover the charter workflow.
