# yashchat007/graphite architecture

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

- Interactive diagram: https://gitdiagram.com/yashchat007/graphite
- Repository: https://github.com/yashchat007/graphite

## Overview

Graphite is a task and focus application: users sign in, create and organize tasks through smart lists and natural-language quick add, then track focus time and sync account-scoped state across devices. The client persists task state locally; its sync engine exchanges documents with the server, which authorizes requests, merges updates, and stores per-user state in Redis. The README also documents installable offline PWA support. Several internal sync and UI connections are based on the SOURCE INDEX; unsampled API routing is left unverified.

Main entry points: [`src/App.tsx`](https://github.com/yashchat007/graphite/blob/main/src/App.tsx) (Dashboard shell), [`server/handler.ts`](https://github.com/yashchat007/graphite/blob/main/server/handler.ts) (Sync handler), [`src/lib/sync-client.ts`](https://github.com/yashchat007/graphite/blob/main/src/lib/sync-client.ts) (Sync client), [`src/store/useGraphiteStore.ts`](https://github.com/yashchat007/graphite/blob/main/src/store/useGraphiteStore.ts) (Task state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_entry["React entry<br/>[main.tsx]"]
  node_app["Dashboard shell<br/>[App.tsx]"]
  node_auth["Clerk sign-in<br/>[ClerkAuthGate.tsx]"]
  node_pwa["PWA worker<br/>[sw.js]"]
end

subgraph group_task["Task and focus"]
  node_taskui["Task lists<br/>[TaskCard.tsx]"]
  node_taskmodal["Task editor<br/>[TaskModal.tsx]"]
  node_quickadd["Quick add<br/>[QuickAdd.tsx]"]
  node_nlp["Natural-language parser<br/>[nlp-parser.ts]"]
  node_taskhooks["Smart-list filters<br/>[useVisibleTasks.ts]"]
  node_completed["Completed tasks"]
  node_focus["Focus timer<br/>[StopwatchCard.tsx]"]
  node_todaynote["Today note<br/>[TodayNote.tsx]"]
  node_state["Task state"]
  node_persist[("Local persistence<br/>[persist-storage.ts]")]
end

subgraph group_sync["Sync and storage"]
  node_syncengine["Sync engine<br/>[useSyncEngine.ts]"]
  node_syncclient["Sync client<br/>[sync-client.ts]"]
  node_document["Sync document<br/>[sync-document.ts]"]
  node_merge["Document merge<br/>[sync-merge.ts]"]
  node_synctypes["Sync types<br/>[sync-types.ts]"]
  node_note_merge["Note merge<br/>[today-note.ts]"]
end

subgraph group_server["Server services"]
  node_syncapi["Sync endpoint<br/>[sync.ts]"]
  node_handler["Sync handler<br/>[handler.ts]"]
  node_authz["Request authorization<br/>[auth.ts]"]
  node_rate["Rate limiting<br/>[rate-limit.ts]"]
  node_cleanup["Leak cleanup<br/>[leak-cleanup.ts]"]
  node_prune["Pruned state loading"]
  node_redis[("Redis storage<br/>[redis.ts]")]
end

node_user(("App user"))
node_clerk["Clerk identity"]

node_user -->|"opens app"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"gates dashboard"| node_auth
node_auth -->|"authenticates"| node_clerk
node_app -->|"renders"| node_taskui
node_app -->|"renders"| node_taskmodal
node_app -->|"renders"| node_quickadd
node_app -->|"renders"| node_focus
node_app -->|"renders"| node_todaynote
node_quickadd -->|"parses input"| node_nlp
node_taskui -->|"filters tasks"| node_taskhooks
node_taskui -->|"selects completed"| node_completed
node_taskui -->|"updates tasks"| node_state
node_taskmodal -->|"updates tasks"| node_state
node_focus -->|"reads timer state"| node_state
node_state -->|"persists locally"| node_persist
node_entry -->|"registers worker"| node_pwa
node_auth -->|"starts sync"| node_syncengine
node_syncengine -->|"fetches and pushes"| node_syncclient
node_syncclient -->|"reads and applies"| node_state
node_syncclient -->|"builds documents"| node_document
node_syncclient -->|"merges documents"| node_merge
node_merge -->|"merges note fields"| node_note_merge
node_handler -->|"normalizes and merges"| node_merge
node_handler -->|"authorizes request"| node_authz
node_handler -->|"checks limit"| node_rate
node_handler -->|"runs cleanup"| node_cleanup
node_handler -->|"loads state"| node_prune
node_handler -->|"reads and saves"| node_redis
node_syncclient -->|"requests /api/sync"| node_syncapi
node_syncapi -.->|"dispatches request"| node_handler

click node_entry "https://github.com/yashchat007/graphite/blob/main/src/main.tsx"
click node_app "https://github.com/yashchat007/graphite/blob/main/src/App.tsx"
click node_auth "https://github.com/yashchat007/graphite/blob/main/src/components/auth/ClerkAuthGate.tsx"
click node_pwa "https://github.com/yashchat007/graphite/blob/main/public/sw.js"
click node_taskui "https://github.com/yashchat007/graphite/blob/main/src/components/tasks/TaskCard.tsx"
click node_taskmodal "https://github.com/yashchat007/graphite/blob/main/src/components/modals/TaskModal.tsx"
click node_quickadd "https://github.com/yashchat007/graphite/blob/main/src/components/tasks/QuickAdd.tsx"
click node_nlp "https://github.com/yashchat007/graphite/blob/main/src/lib/nlp-parser.ts"
click node_taskhooks "https://github.com/yashchat007/graphite/blob/main/src/hooks/useVisibleTasks.ts"
click node_completed "https://github.com/yashchat007/graphite/blob/main/src/hooks/useCompletedTasks.ts"
click node_focus "https://github.com/yashchat007/graphite/blob/main/src/features/focus/StopwatchCard.tsx"
click node_todaynote "https://github.com/yashchat007/graphite/blob/main/src/features/tasks/TodayNote.tsx"
click node_state "https://github.com/yashchat007/graphite/blob/main/src/store/useGraphiteStore.ts"
click node_persist "https://github.com/yashchat007/graphite/blob/main/src/lib/persist-storage.ts"
click node_syncengine "https://github.com/yashchat007/graphite/blob/main/src/hooks/useSyncEngine.ts"
click node_syncclient "https://github.com/yashchat007/graphite/blob/main/src/lib/sync-client.ts"
click node_document "https://github.com/yashchat007/graphite/blob/main/src/lib/sync-document.ts"
click node_merge "https://github.com/yashchat007/graphite/blob/main/shared/sync-merge.ts"
click node_synctypes "https://github.com/yashchat007/graphite/blob/main/shared/sync-types.ts"
click node_note_merge "https://github.com/yashchat007/graphite/blob/main/shared/today-note.ts"
click node_syncapi "https://github.com/yashchat007/graphite/blob/main/api/sync.ts"
click node_handler "https://github.com/yashchat007/graphite/blob/main/server/handler.ts"
click node_authz "https://github.com/yashchat007/graphite/blob/main/server/auth.ts"
click node_rate "https://github.com/yashchat007/graphite/blob/main/server/rate-limit.ts"
click node_cleanup "https://github.com/yashchat007/graphite/blob/main/server/leak-cleanup.ts"
click node_prune "https://github.com/yashchat007/graphite/blob/main/server/load-pruned-state.ts"
click node_redis "https://github.com/yashchat007/graphite/blob/main/server/redis.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_entry,node_app,node_auth,node_pwa,node_user toneBlue
class node_taskui,node_taskmodal,node_quickadd,node_nlp,node_taskhooks,node_completed,node_focus,node_todaynote,node_state,node_persist toneAmber
class node_syncengine,node_syncclient,node_document,node_merge,node_synctypes,node_note_merge toneMint
class node_syncapi,node_handler,node_authz,node_rate,node_cleanup,node_prune,node_redis toneRose
class node_clerk toneIndigo
```

## Components

### Client experience

- [React entry](https://github.com/yashchat007/graphite/blob/main/src/main.tsx): `src/main.tsx`
- [Dashboard shell](https://github.com/yashchat007/graphite/blob/main/src/App.tsx): `src/App.tsx`
- [Clerk sign-in](https://github.com/yashchat007/graphite/blob/main/src/components/auth/ClerkAuthGate.tsx): `src/components/auth/ClerkAuthGate.tsx`
- [PWA worker](https://github.com/yashchat007/graphite/blob/main/public/sw.js): `public/sw.js`

### Task and focus

- [Task lists](https://github.com/yashchat007/graphite/blob/main/src/components/tasks/TaskCard.tsx): `src/components/tasks/TaskCard.tsx`
- [Task editor](https://github.com/yashchat007/graphite/blob/main/src/components/modals/TaskModal.tsx): `src/components/modals/TaskModal.tsx`
- [Quick add](https://github.com/yashchat007/graphite/blob/main/src/components/tasks/QuickAdd.tsx): `src/components/tasks/QuickAdd.tsx`
- [Natural-language parser](https://github.com/yashchat007/graphite/blob/main/src/lib/nlp-parser.ts): `src/lib/nlp-parser.ts`
- [Smart-list filters](https://github.com/yashchat007/graphite/blob/main/src/hooks/useVisibleTasks.ts): `src/hooks/useVisibleTasks.ts`
- [Completed tasks](https://github.com/yashchat007/graphite/blob/main/src/hooks/useCompletedTasks.ts): `src/hooks/useCompletedTasks.ts`
- [Focus timer](https://github.com/yashchat007/graphite/blob/main/src/features/focus/StopwatchCard.tsx): `src/features/focus/StopwatchCard.tsx`
- [Today note](https://github.com/yashchat007/graphite/blob/main/src/features/tasks/TodayNote.tsx): `src/features/tasks/TodayNote.tsx`
- [Task state](https://github.com/yashchat007/graphite/blob/main/src/store/useGraphiteStore.ts): `src/store/useGraphiteStore.ts`
- [Local persistence](https://github.com/yashchat007/graphite/blob/main/src/lib/persist-storage.ts): `src/lib/persist-storage.ts`

### Sync and storage

- [Sync engine](https://github.com/yashchat007/graphite/blob/main/src/hooks/useSyncEngine.ts): `src/hooks/useSyncEngine.ts`
- [Sync client](https://github.com/yashchat007/graphite/blob/main/src/lib/sync-client.ts): `src/lib/sync-client.ts`
- [Sync document](https://github.com/yashchat007/graphite/blob/main/src/lib/sync-document.ts): `src/lib/sync-document.ts`
- [Document merge](https://github.com/yashchat007/graphite/blob/main/shared/sync-merge.ts): `shared/sync-merge.ts`
- [Sync types](https://github.com/yashchat007/graphite/blob/main/shared/sync-types.ts): `shared/sync-types.ts`
- [Note merge](https://github.com/yashchat007/graphite/blob/main/shared/today-note.ts): `shared/today-note.ts`

### Server services

- [Sync endpoint](https://github.com/yashchat007/graphite/blob/main/api/sync.ts): `api/sync.ts`
- [Sync handler](https://github.com/yashchat007/graphite/blob/main/server/handler.ts): `server/handler.ts`
- [Request authorization](https://github.com/yashchat007/graphite/blob/main/server/auth.ts): `server/auth.ts`
- [Rate limiting](https://github.com/yashchat007/graphite/blob/main/server/rate-limit.ts): `server/rate-limit.ts`
- [Leak cleanup](https://github.com/yashchat007/graphite/blob/main/server/leak-cleanup.ts): `server/leak-cleanup.ts`
- [Pruned state loading](https://github.com/yashchat007/graphite/blob/main/server/load-pruned-state.ts): `server/load-pruned-state.ts`
- [Redis storage](https://github.com/yashchat007/graphite/blob/main/server/redis.ts): `server/redis.ts`

### Other components

- **App user**
- **Clerk identity**

## Connections

- App user → React entry: opens app (evidence: `src/main.tsx`)
- React entry → Dashboard shell: renders (evidence: `src/main.tsx`)
- Dashboard shell → Clerk sign-in: gates dashboard (evidence: `src/App.tsx`)
- Clerk sign-in → Clerk identity: authenticates (evidence: `src/components/auth/ClerkAuthGate.tsx`)
- Dashboard shell → Task lists: renders (evidence: `src/App.tsx`)
- Dashboard shell → Task editor: renders (evidence: `src/App.tsx`)
- Dashboard shell → Quick add: renders (evidence: `src/App.tsx`)
- Dashboard shell → Focus timer: renders (evidence: `src/App.tsx`)
- Dashboard shell → Today note: renders (evidence: `src/App.tsx`)
- Quick add → Natural-language parser: parses input
- Task lists → Smart-list filters: filters tasks (evidence: `src/components/tasks/TaskCard.tsx`)
- Task lists → Completed tasks: selects completed (evidence: `src/components/tasks/TaskCard.tsx`)
- Task lists → Task state: updates tasks (evidence: `src/components/tasks/TaskCard.tsx`)
- Task editor → Task state: updates tasks (evidence: `src/components/modals/TaskModal.tsx`)
- Focus timer → Task state: reads timer state (evidence: `src/features/focus/StopwatchCard.tsx`)
- Task state → Local persistence: persists locally (evidence: `src/store/useGraphiteStore.ts`)
- React entry → PWA worker: registers worker (evidence: `src/main.tsx`)
- Clerk sign-in → Sync engine: starts sync (evidence: `src/components/auth/ClerkAuthGate.tsx`)
- Sync engine → Sync client: fetches and pushes (evidence: `src/hooks/useSyncEngine.ts`)
- Sync client → Task state: reads and applies (evidence: `src/lib/sync-client.ts`)
- Sync client → Sync document: builds documents (evidence: `src/lib/sync-client.ts`)
- Sync client → Document merge: merges documents (evidence: `src/lib/sync-client.ts`)
- Document merge → Note merge: merges note fields (evidence: `shared/sync-merge.ts`)
- Sync handler → Document merge: normalizes and merges (evidence: `server/handler.ts`)
- Sync handler → Request authorization: authorizes request (evidence: `server/handler.ts`)
- Sync handler → Rate limiting: checks limit (evidence: `server/handler.ts`)
- Sync handler → Leak cleanup: runs cleanup (evidence: `server/handler.ts`)
- Sync handler → Pruned state loading: loads state (evidence: `server/handler.ts`)
- Sync handler → Redis storage: reads and saves (evidence: `server/handler.ts`)
- Sync client → Sync endpoint: requests /api/sync (evidence: `src/lib/sync-client.ts`)
- Sync endpoint → Sync handler: dispatches request
