# emiroshhh/mindpulse-by-northlight architecture

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

- Interactive diagram: https://gitdiagram.com/emiroshhh/mindpulse-by-northlight
- Repository: https://github.com/emiroshhh/mindpulse-by-northlight

## Overview

MindPulse is a guest-first AI study and self-growth workspace. Students use the dashboard or focused tools to describe a task, receive a safe AI response or structured plan, then save useful results locally as guests or to an account. Recovery Mode is a separate guided workflow with validated AI planning and a deterministic fallback. The README documents the six tools, Agent, feedback, account features, and localized public pages. Source excerpts substantiate chat, recovery, feedback, insights, safety, and event handling; other documented connections are shown as unverified where implementation was not sampled.

Main entry points: [`apps/web/app/api/recovery/route.ts`](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/recovery/route.ts) (Recovery endpoint), [`apps/web/app/api/chat/route.ts`](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/chat/route.ts) (Chat endpoint), [`apps/web/lib/server/auth.ts`](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/auth.ts) (Session and account services), [`apps/web/lib/server/events.ts`](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/events.ts) (Aggregate event store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_dashboard["Workspace dashboard<br/>[dashboard-app.tsx]"]
  node_toolpages["Six AI tools"]
  node_recoveryui["Recovery interface<br/>[recovery-flow.tsx]"]
  node_chatui["Chat panel<br/>[chat-panel.tsx]"]
  node_authui["Account forms<br/>[auth-form.tsx]"]
  node_marketing["Localized public pages"]
end

subgraph group_flows["Product workflows"]
  node_chatapi["Chat endpoint<br/>[route.ts]"]
  node_recoveryapi["Recovery endpoint<br/>[route.ts]"]
  node_agentapi["Agent endpoint<br/>[route.ts]"]
  node_authapi["Account endpoints<br/>[route.ts]"]
  node_feedbackapi["Feedback endpoint<br/>[route.ts]"]
  node_insightsapi["Insights endpoint<br/>[route.ts]"]
  node_eventsapi["Beta events endpoint<br/>[route.ts]"]
end

subgraph group_shared["Shared domain logic"]
  node_safety["Safety screening<br/>[index.ts]"]
  node_recoverylogic["Recovery planning<br/>[recovery.ts]"]
  node_exercises["Exercises and tools<br/>[exercises.ts]"]
end

subgraph group_platform["Safety and persistence"]
  node_provider["AI provider layer<br/>[ai-provider.ts]"]
  node_auth["Session and account services<br/>[auth.ts]"]
  node_usage["Usage and capacity<br/>[usage.ts]"]
  node_events["Aggregate event store<br/>[events.ts]"]
  node_localstore["Guest local state<br/>[local-store.ts]"]
end

subgraph group_mobile["Mobile experience"]
  node_mobilechat["Mobile chat<br/>[chat.tsx]"]
  node_mobilestate["Mobile local state<br/>[state.tsx]"]
  node_mobilecheckin["Mood check-in<br/>[index.tsx]"]
end

node_student(("Student"))
node_d1[("Cloudflare D1")]
node_gemini{{"Gemini AI"}}
node_deepseek{{"DeepSeek AI"}}

node_student -->|"opens workspace"| node_dashboard
node_student -->|"selects a tool"| node_toolpages
node_student -->|"starts recovery"| node_recoveryui
node_dashboard -.->|"offers chat"| node_chatui
node_chatui -.->|"submits message"| node_chatapi
node_toolpages -.->|"sends tool request"| node_chatapi
node_recoveryui -.->|"submits missed work"| node_recoveryapi
node_authui -.->|"submits credentials"| node_authapi
node_chatapi -->|"screens input and output"| node_safety
node_chatapi -->|"reserves quota"| node_usage
node_chatapi -->|"requests reply"| node_provider
node_chatapi -->|"resolves user and database"| node_auth
node_chatapi -->|"records outcome"| node_events
node_recoveryapi -->|"screens request and reply"| node_safety
node_recoveryapi -->|"validates or falls back"| node_recoverylogic
node_recoveryapi -->|"requests plan"| node_provider
node_recoveryapi -->|"reserves or refunds quota"| node_usage
node_recoveryapi -->|"resolves user and saves plan"| node_auth
node_recoveryapi -->|"records outcome"| node_events
node_feedbackapi -->|"screens suggestion"| node_safety
node_feedbackapi -->|"writes submission"| node_auth
node_feedbackapi -->|"records feedback"| node_events
node_insightsapi -->|"reads account aggregates"| node_auth
node_eventsapi -->|"records allowlisted event"| node_events
node_authapi -.->|"creates account session"| node_auth
node_auth -.->|"reads and writes"| node_d1
node_events -->|"increments daily counters"| node_d1
node_provider -->|"uses by default"| node_gemini
node_provider -.->|"supports optionally"| node_deepseek
node_dashboard -.->|"saves guest progress"| node_localstore
node_student -->|"records mood"| node_mobilecheckin
node_mobilecheckin -->|"adds mood"| node_mobilestate
node_mobilechat -.->|"uses local state"| node_mobilestate
node_mobilechat -.->|"uses shared package"| node_exercises

click node_dashboard "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/dashboard-app.tsx"
click node_toolpages "https://github.com/emiroshhh/mindpulse-by-northlight/tree/main/apps/web/app"
click node_recoveryui "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/recovery/recovery-flow.tsx"
click node_chatui "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/mindpulse/chat-panel.tsx"
click node_authui "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/auth-form.tsx"
click node_marketing "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/mindpulse/localized-public-page.tsx"
click node_chatapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/chat/route.ts"
click node_recoveryapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/recovery/route.ts"
click node_agentapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/agent/route.ts"
click node_authapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/auth/signup/route.ts"
click node_feedbackapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/feedback/route.ts"
click node_insightsapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/insights/route.ts"
click node_eventsapi "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/events/route.ts"
click node_safety "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/packages/shared/src/safety/index.ts"
click node_recoverylogic "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/packages/shared/src/recovery.ts"
click node_exercises "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/packages/shared/src/exercises.ts"
click node_provider "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/ai-provider.ts"
click node_auth "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/auth.ts"
click node_usage "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/usage.ts"
click node_events "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/events.ts"
click node_localstore "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/mindpulse/local-store.ts"
click node_mobilechat "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/mobile/app/(tabs)/chat.tsx"
click node_mobilestate "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/mobile/lib/state.tsx"
click node_mobilecheckin "https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/mobile/app/(tabs)/index.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_dashboard,node_toolpages,node_recoveryui,node_chatui,node_authui,node_marketing toneBlue
class node_chatapi,node_recoveryapi,node_agentapi,node_authapi,node_feedbackapi,node_insightsapi,node_eventsapi,node_d1 toneAmber
class node_safety,node_recoverylogic,node_exercises toneMint
class node_provider,node_auth,node_usage,node_events,node_localstore toneRose
class node_mobilechat,node_mobilestate,node_mobilecheckin,node_student,node_gemini,node_deepseek toneIndigo
```

## Components

### Web experience

- [Workspace dashboard](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/dashboard-app.tsx): `apps/web/components/dashboard-app.tsx`
- [Six AI tools](https://github.com/emiroshhh/mindpulse-by-northlight/tree/main/apps/web/app): `apps/web/app`
- [Recovery interface](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/recovery/recovery-flow.tsx): `apps/web/components/recovery/recovery-flow.tsx`
- [Chat panel](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/mindpulse/chat-panel.tsx): `apps/web/components/mindpulse/chat-panel.tsx`
- [Account forms](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/auth-form.tsx): `apps/web/components/auth-form.tsx`
- [Localized public pages](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/components/mindpulse/localized-public-page.tsx): `apps/web/components/mindpulse/localized-public-page.tsx`

### Product workflows

- [Chat endpoint](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/chat/route.ts): `apps/web/app/api/chat/route.ts`
- [Recovery endpoint](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/recovery/route.ts): `apps/web/app/api/recovery/route.ts`
- [Agent endpoint](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/agent/route.ts): `apps/web/app/api/agent/route.ts`
- [Account endpoints](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/auth/signup/route.ts): `apps/web/app/api/auth/signup/route.ts`
- [Feedback endpoint](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/feedback/route.ts): `apps/web/app/api/feedback/route.ts`
- [Insights endpoint](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/insights/route.ts): `apps/web/app/api/insights/route.ts`
- [Beta events endpoint](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/app/api/events/route.ts): `apps/web/app/api/events/route.ts`

### Shared domain logic

- [Safety screening](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/packages/shared/src/safety/index.ts): `packages/shared/src/safety/index.ts`
- [Recovery planning](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/packages/shared/src/recovery.ts): `packages/shared/src/recovery.ts`
- [Exercises and tools](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/packages/shared/src/exercises.ts): `packages/shared/src/exercises.ts`

### Safety and persistence

- [AI provider layer](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/ai-provider.ts): `apps/web/lib/server/ai-provider.ts`
- [Session and account services](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/auth.ts): `apps/web/lib/server/auth.ts`
- [Usage and capacity](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/usage.ts): `apps/web/lib/server/usage.ts`
- [Aggregate event store](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/server/events.ts): `apps/web/lib/server/events.ts`
- [Guest local state](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/web/lib/mindpulse/local-store.ts): `apps/web/lib/mindpulse/local-store.ts`

### Mobile experience

- [Mobile chat](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/mobile/app/(tabs)/chat.tsx): `apps/mobile/app/(tabs)/chat.tsx`
- [Mobile local state](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/mobile/lib/state.tsx): `apps/mobile/lib/state.tsx`
- [Mood check-in](https://github.com/emiroshhh/mindpulse-by-northlight/blob/main/apps/mobile/app/(tabs)/index.tsx): `apps/mobile/app/(tabs)/index.tsx`

### Other components

- **Student**
- **Cloudflare D1**
- **Gemini AI**
- **DeepSeek AI**

## Connections

- Student → Workspace dashboard: opens workspace
- Student → Six AI tools: selects a tool
- Student → Recovery interface: starts recovery
- Workspace dashboard → Chat panel: offers chat
- Chat panel → Chat endpoint: submits message
- Six AI tools → Chat endpoint: sends tool request
- Recovery interface → Recovery endpoint: submits missed work
- Account forms → Account endpoints: submits credentials
- Chat endpoint → Safety screening: screens input and output (evidence: `apps/web/app/api/chat/route.ts`)
- Chat endpoint → Usage and capacity: reserves quota (evidence: `apps/web/app/api/chat/route.ts`)
- Chat endpoint → AI provider layer: requests reply (evidence: `apps/web/app/api/chat/route.ts`)
- Chat endpoint → Session and account services: resolves user and database (evidence: `apps/web/app/api/chat/route.ts`)
- Chat endpoint → Aggregate event store: records outcome (evidence: `apps/web/app/api/chat/route.ts`)
- Recovery endpoint → Safety screening: screens request and reply (evidence: `apps/web/app/api/recovery/route.ts`)
- Recovery endpoint → Recovery planning: validates or falls back (evidence: `apps/web/app/api/recovery/route.ts`)
- Recovery endpoint → AI provider layer: requests plan (evidence: `apps/web/app/api/recovery/route.ts`)
- Recovery endpoint → Usage and capacity: reserves or refunds quota (evidence: `apps/web/app/api/recovery/route.ts`)
- Recovery endpoint → Session and account services: resolves user and saves plan (evidence: `apps/web/app/api/recovery/route.ts`)
- Recovery endpoint → Aggregate event store: records outcome (evidence: `apps/web/app/api/recovery/route.ts`)
- Feedback endpoint → Safety screening: screens suggestion (evidence: `apps/web/app/api/feedback/route.ts`)
- Feedback endpoint → Session and account services: writes submission (evidence: `apps/web/app/api/feedback/route.ts`)
- Feedback endpoint → Aggregate event store: records feedback (evidence: `apps/web/app/api/feedback/route.ts`)
- Insights endpoint → Session and account services: reads account aggregates (evidence: `apps/web/app/api/insights/route.ts`)
- Beta events endpoint → Aggregate event store: records allowlisted event (evidence: `apps/web/app/api/events/route.ts`)
- Account endpoints → Session and account services: creates account session
- Session and account services → Cloudflare D1: reads and writes
- Aggregate event store → Cloudflare D1: increments daily counters (evidence: `apps/web/lib/server/events.ts`)
- AI provider layer → Gemini AI: uses by default
- AI provider layer → DeepSeek AI: supports optionally
- Workspace dashboard → Guest local state: saves guest progress
- Student → Mood check-in: records mood (evidence: `apps/mobile/app/(tabs)/index.tsx`)
- Mood check-in → Mobile local state: adds mood (evidence: `apps/mobile/app/(tabs)/index.tsx`)
- Mobile chat → Mobile local state: uses local state (evidence: `apps/mobile/app/(tabs)/chat.tsx`)
- Mobile chat → Exercises and tools: uses shared package (evidence: `apps/mobile/app/(tabs)/chat.tsx`)
