# saurabh27kashyap/time architecture

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

- Interactive diagram: https://gitdiagram.com/saurabh27kashyap/time
- Repository: https://github.com/saurabh27kashyap/time

## Overview

#### Purpose and runtime

Memento is a TypeScript/React life-planning application: it visualizes remaining life in weeks, tracks life aspects and time thieves, supports dated “horizons” (goals), and provides an AI coach to turn goals into plans. It runs as a TanStack Start SSR application with a Node 22+ server runtime, Vite build pipeline, Tailwind v4, and shadcn/ui primitives.

Key startup and routing surfaces:
- `src/start.ts`
- `src/server.ts`
- `src/router.tsx`
- `src/routes/__root.tsx`

#### Route-level application shell

TanStack file routes define the product’s primary pages and API boundary. The root route supplies the shared application shell; route generation is represented by `src/routeTree.gen.ts`.

Primary user entry points:
- Dashboard/life overview: `src/routes/index.tsx`
- AI coach: `src/routes/coach.tsx`
- Goal horizon planning: `src/routes/horizon.tsx`
- Per-aspect detail: `src/routes/aspects.$aspect.tsx`
- Time-thief tracking and settings: `src/routes/time-thieves.tsx`, `src/routes/settings.tsx`

#### Client state and life-domain model

The application’s central client-side state is managed in `src/lib/store.tsx`. Domain modules separate calculations and typed concepts for life timeline, aspects, horizons, and distracting activities:
- `src/lib/life.ts`
- `src/lib/aspects.ts`
- `src/lib/horizon.ts`
- `src/lib/thieves.ts`

UI routes and components consume this shared model to derive calendar/life-grid views, remaining-week statistics, goals, and category-specific planning. This is a client-state boundary: the supplied tree shows no database, persistence adapter, or authentication layer.

#### Life visualization and dashboard composition

The dashboard composes timeline-oriented visual components around the life model. Its main presentation stages are:
1. Establish calendar/life anchors.
2. Render near-term and whole-life week grids.
3. Show current metrics and live countdown.
4. Surface goals and coaching guidance.

Core components:
- `src/components/CalendarAnchors.tsx`
- `src/components/NearTermGrid.tsx`
- `src/components/WeeksGrid.tsx`
- `src/components/LiveTicker.tsx`
- `src/components/StatsStrip.tsx`
- `src/components/GoalCard.tsx`

#### Horizon planning workflow

Horizons are dated planning objects, represented in the domain layer and managed through dedicated creation, card, and timeline views. Users can create a horizon, inspect its timeline, and relate it to life aspects and coach-generated plans.

Relevant boundaries:
- Horizon model/calculation: `src/lib/horizon.ts`
- Horizon page: `src/routes/horizon.tsx`
- Creation and visualization: `src/components/HorizonCreator.tsx`, `src/components/HorizonCard.tsx`, `src/components/HorizonTimeline.tsx`

#### AI coach and server API boundary

AI functionality is server-only. The chat route receives coach requests, assembles structured user/life context, invokes AI tools/functions, and returns generated coaching or plans. Browser components should interact through the API route rather than import the provider directly.

Core paths:
- HTTP endpoint: `src/routes/api/chat.ts`
- Provider and Groq credential access: `src/lib/ai-provider.server.ts`
- Context construction: `src/lib/coach-context.ts`
- Coach tools/functions: `src/lib/coach.functions.ts`
- Coach UI: `src/components/CoachMessage.tsx`, `src/routes/coach.tsx`

Groq is the sole identified external service, accessed via Vercel AI SDK. `GROQ_API_KEY` remains server-side; absent configuration degrades only AI features.

#### Cross-cutting interaction and failure handling

Navigation is organized through the application sidebar, while onboarding initializes or guides the user into the life-planning experience. Error capture/page modules provide a distinct failure-handling boundary for route or application errors.

- `src/components/AppSidebar.tsx`
- `src/components/Onboarding.tsx`
- `src/lib/error-capture.ts`
- `src/lib/error-page.ts`

Main entry points: [`src/routes/__root.tsx`](https://github.com/saurabh27kashyap/time/blob/main/src/routes/__root.tsx) (Application shell), [`src/lib/store.tsx`](https://github.com/saurabh27kashyap/time/blob/main/src/lib/store.tsx) (Life planning state), [`src/routes/index.tsx`](https://github.com/saurabh27kashyap/time/blob/main/src/routes/index.tsx) (Life dashboard), [`src/routes/api/chat.ts`](https://github.com/saurabh27kashyap/time/blob/main/src/routes/api/chat.ts) (Coach chat API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["SSR runtime &amp; routing"]
  node_start{{"Application startup<br/>TanStack Start entry<br/>[start.ts]"}}
  node_server{{"Node SSR server<br/>server runtime<br/>[server.ts]"}}
  node_router["Router<br/>[router.tsx]"]
  node_root_route["Application shell<br/>root route<br/>[__root.tsx]"]
  node_route_tree["Generated route tree<br/>route manifest<br/>[routeTree.gen.ts]"]
  node_errors["Error handling<br/>failure boundary<br/>[error-capture.ts]"]
end

subgraph group_client["Client life planning"]
  node_sidebar_onboarding["Navigation &amp; onboarding<br/>shared UI<br/>[AppSidebar.tsx]"]
  node_dashboard["Life dashboard<br/>primary route<br/>[index.tsx]"]
  node_life_visuals["Life timeline visuals<br/>dashboard components<br/>[WeeksGrid.tsx]"]
  node_goal_card["Goal cards<br/>dashboard component<br/>[GoalCard.tsx]"]
  node_state[("Life planning state<br/>client state<br/>[store.tsx]")]
  node_life_domain["Life &amp; aspects model<br/>domain calculations<br/>[life.ts]"]
  node_horizon_domain["Horizon model<br/>domain calculations<br/>[horizon.ts]"]
  node_thieves_domain["Time-thief model<br/>domain calculations<br/>[thieves.ts]"]
  node_planning_routes["Planning routes<br/>product routes<br/>[horizon.tsx]"]
  node_horizon_ui["Horizon workflow UI<br/>planning components<br/>[HorizonCreator.tsx]"]
end

subgraph group_ai["AI coach"]
  node_coach_route["Coach page<br/>product route<br/>[coach.tsx]"]
  node_coach_ui["Coach messages<br/>chat UI<br/>[CoachMessage.tsx]"]
  node_chat_api{{"Coach chat API<br/>server API route<br/>[chat.ts]"}}
  node_coach_context["Coach context<br/>context builder<br/>[coach-context.ts]"]
  node_coach_tools["Coach tools<br/>AI functions<br/>[coach.functions.ts]"]
  node_groq_provider{{"Groq provider<br/>AI provider adapter"}}
end

node_start -->|"starts"| node_server
node_server -->|"serves SSR requests"| node_router
node_router -->|"uses"| node_route_tree
node_route_tree -->|"resolves routes"| node_root_route
node_root_route -->|"hosts"| node_sidebar_onboarding
node_root_route -->|"renders"| node_dashboard
node_root_route -->|"renders"| node_planning_routes
node_root_route -->|"renders"| node_coach_route
node_root_route -.->|"handles failures with"| node_errors
node_dashboard -->|"composes"| node_life_visuals
node_dashboard -->|"surfaces"| node_goal_card
node_dashboard -->|"reads"| node_state
node_life_visuals -->|"derives timeline from"| node_life_domain
node_state -->|"manages"| node_life_domain
node_state -->|"manages"| node_horizon_domain
node_state -->|"manages"| node_thieves_domain
node_planning_routes -->|"hosts horizon planning"| node_horizon_ui
node_horizon_ui -->|"creates and visualizes"| node_horizon_domain
node_planning_routes -->|"reads and updates"| node_state
node_coach_route -->|"renders"| node_coach_ui
node_coach_route -->|"sends coach requests"| node_chat_api
node_chat_api -->|"assembles context"| node_coach_context
node_chat_api -->|"invokes tools"| node_coach_tools
node_chat_api -->|"generates coaching with"| node_groq_provider
node_coach_context -.->|"uses life data"| node_life_domain
node_coach_context -.->|"uses goals"| node_horizon_domain

click node_start "https://github.com/saurabh27kashyap/time/blob/main/src/start.ts"
click node_server "https://github.com/saurabh27kashyap/time/blob/main/src/server.ts"
click node_router "https://github.com/saurabh27kashyap/time/blob/main/src/router.tsx"
click node_root_route "https://github.com/saurabh27kashyap/time/blob/main/src/routes/__root.tsx"
click node_route_tree "https://github.com/saurabh27kashyap/time/blob/main/src/routeTree.gen.ts"
click node_sidebar_onboarding "https://github.com/saurabh27kashyap/time/blob/main/src/components/AppSidebar.tsx"
click node_dashboard "https://github.com/saurabh27kashyap/time/blob/main/src/routes/index.tsx"
click node_life_visuals "https://github.com/saurabh27kashyap/time/blob/main/src/components/WeeksGrid.tsx"
click node_goal_card "https://github.com/saurabh27kashyap/time/blob/main/src/components/GoalCard.tsx"
click node_state "https://github.com/saurabh27kashyap/time/blob/main/src/lib/store.tsx"
click node_life_domain "https://github.com/saurabh27kashyap/time/blob/main/src/lib/life.ts"
click node_horizon_domain "https://github.com/saurabh27kashyap/time/blob/main/src/lib/horizon.ts"
click node_thieves_domain "https://github.com/saurabh27kashyap/time/blob/main/src/lib/thieves.ts"
click node_planning_routes "https://github.com/saurabh27kashyap/time/blob/main/src/routes/horizon.tsx"
click node_horizon_ui "https://github.com/saurabh27kashyap/time/blob/main/src/components/HorizonCreator.tsx"
click node_coach_route "https://github.com/saurabh27kashyap/time/blob/main/src/routes/coach.tsx"
click node_coach_ui "https://github.com/saurabh27kashyap/time/blob/main/src/components/CoachMessage.tsx"
click node_chat_api "https://github.com/saurabh27kashyap/time/blob/main/src/routes/api/chat.ts"
click node_coach_context "https://github.com/saurabh27kashyap/time/blob/main/src/lib/coach-context.ts"
click node_coach_tools "https://github.com/saurabh27kashyap/time/blob/main/src/lib/coach.functions.ts"
click node_groq_provider "https://github.com/saurabh27kashyap/time/blob/main/src/lib/ai-provider.server.ts"
click node_errors "https://github.com/saurabh27kashyap/time/blob/main/src/lib/error-capture.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_start,node_server,node_router,node_root_route,node_route_tree,node_errors toneBlue
class node_sidebar_onboarding,node_dashboard,node_life_visuals,node_goal_card,node_state,node_life_domain,node_horizon_domain,node_thieves_domain,node_planning_routes,node_horizon_ui toneAmber
class node_coach_route,node_coach_ui,node_chat_api,node_coach_context,node_coach_tools,node_groq_provider toneMint
```

## Components

### SSR runtime & routing

- [Application startup](https://github.com/saurabh27kashyap/time/blob/main/src/start.ts): TanStack Start entry · `src/start.ts`
- [Node SSR server](https://github.com/saurabh27kashyap/time/blob/main/src/server.ts): server runtime · `src/server.ts`
- [Router](https://github.com/saurabh27kashyap/time/blob/main/src/router.tsx): TanStack router · `src/router.tsx`
- [Application shell](https://github.com/saurabh27kashyap/time/blob/main/src/routes/__root.tsx): root route · Shared shell for all product routes. · `src/routes/__root.tsx`
- [Generated route tree](https://github.com/saurabh27kashyap/time/blob/main/src/routeTree.gen.ts): route manifest · `src/routeTree.gen.ts`
- [Error handling](https://github.com/saurabh27kashyap/time/blob/main/src/lib/error-capture.ts): failure boundary · Captures and renders route or application failures. · `src/lib/error-capture.ts`

### Client life planning

- [Navigation & onboarding](https://github.com/saurabh27kashyap/time/blob/main/src/components/AppSidebar.tsx): shared UI · `src/components/AppSidebar.tsx`
- [Life dashboard](https://github.com/saurabh27kashyap/time/blob/main/src/routes/index.tsx): primary route · `src/routes/index.tsx`
- [Life timeline visuals](https://github.com/saurabh27kashyap/time/blob/main/src/components/WeeksGrid.tsx): dashboard components · Anchors, week grids, live ticker, and statistics. · `src/components/WeeksGrid.tsx`
- [Goal cards](https://github.com/saurabh27kashyap/time/blob/main/src/components/GoalCard.tsx): dashboard component · `src/components/GoalCard.tsx`
- [Life planning state](https://github.com/saurabh27kashyap/time/blob/main/src/lib/store.tsx): client state · Central in-memory state boundary; no persistence or auth layer is identified. · `src/lib/store.tsx`
- [Life & aspects model](https://github.com/saurabh27kashyap/time/blob/main/src/lib/life.ts): domain calculations · Timeline calculations and life-aspect concepts. · `src/lib/life.ts`
- [Horizon model](https://github.com/saurabh27kashyap/time/blob/main/src/lib/horizon.ts): domain calculations · `src/lib/horizon.ts`
- [Time-thief model](https://github.com/saurabh27kashyap/time/blob/main/src/lib/thieves.ts): domain calculations · `src/lib/thieves.ts`
- [Planning routes](https://github.com/saurabh27kashyap/time/blob/main/src/routes/horizon.tsx): product routes · Horizon, aspect detail, time-thief, and settings pages. · `src/routes/horizon.tsx`
- [Horizon workflow UI](https://github.com/saurabh27kashyap/time/blob/main/src/components/HorizonCreator.tsx): planning components · Creation, cards, and timeline visualization. · `src/components/HorizonCreator.tsx`

### AI coach

- [Coach page](https://github.com/saurabh27kashyap/time/blob/main/src/routes/coach.tsx): product route · `src/routes/coach.tsx`
- [Coach messages](https://github.com/saurabh27kashyap/time/blob/main/src/components/CoachMessage.tsx): chat UI · `src/components/CoachMessage.tsx`
- [Coach chat API](https://github.com/saurabh27kashyap/time/blob/main/src/routes/api/chat.ts): server API route · Server-only boundary for coaching requests and generated plans. · `src/routes/api/chat.ts`
- [Coach context](https://github.com/saurabh27kashyap/time/blob/main/src/lib/coach-context.ts): context builder · `src/lib/coach-context.ts`
- [Coach tools](https://github.com/saurabh27kashyap/time/blob/main/src/lib/coach.functions.ts): AI functions · `src/lib/coach.functions.ts`
- [Groq provider](https://github.com/saurabh27kashyap/time/blob/main/src/lib/ai-provider.server.ts): AI provider adapter · Uses server-side GROQ_API_KEY via Vercel AI SDK. · `src/lib/ai-provider.server.ts`

## Connections

- Application startup → Node SSR server: starts
- Node SSR server → Router: serves SSR requests
- Router → Generated route tree: uses
- Generated route tree → Application shell: resolves routes
- Application shell → Navigation & onboarding: hosts
- Application shell → Life dashboard: renders
- Application shell → Planning routes: renders
- Application shell → Coach page: renders
- Application shell → Error handling: handles failures with
- Life dashboard → Life timeline visuals: composes
- Life dashboard → Goal cards: surfaces
- Life dashboard → Life planning state: reads
- Life timeline visuals → Life & aspects model: derives timeline from
- Life planning state → Life & aspects model: manages
- Life planning state → Horizon model: manages
- Life planning state → Time-thief model: manages
- Planning routes → Horizon workflow UI: hosts horizon planning
- Horizon workflow UI → Horizon model: creates and visualizes
- Planning routes → Life planning state: reads and updates
- Coach page → Coach messages: renders
- Coach page → Coach chat API: sends coach requests · Browser access stays behind the API boundary.
- Coach chat API → Coach context: assembles context
- Coach chat API → Coach tools: invokes tools
- Coach chat API → Groq provider: generates coaching with
- Coach context → Life & aspects model: uses life data
- Coach context → Horizon model: uses goals
