# nikhi20-900/calmspace architecture

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

- Interactive diagram: https://gitdiagram.com/nikhi20-900/calmspace
- Repository: https://github.com/nikhi20-900/calmspace

## Overview

Calmspace is a privacy-conscious student wellbeing companion. Students arrive through the landing page, submit a guided check-in, receive a backend-determined safety route and appropriate guidance or human-support contacts, then can review patterns, plan study breaks, manage support resources, and adjust privacy settings. The map preserves those product areas and the backend’s safety, guidance, directory, and persistence layers. Some page and service implementations were not sampled, so their internal connections are included only where the README or indexed source relationships support them.

Main entry points: [`backend/app/routers/checkin.py`](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/checkin.py) (Check-in endpoint), [`frontend/src/App.tsx`](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/App.tsx) (App shell), [`frontend/src/services/api.ts`](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/services/api.ts) (API client), [`backend/app/main.py`](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Student experience"]
end

subgraph group_frontend["Frontend features"]
  node_landing["Landing experience<br/>[LandingPage.tsx]"]
  node_app_shell["App shell<br/>[App.tsx]"]
  node_checkin_ui["Check-in form<br/>[CheckInPage.tsx]"]
  node_result_ui["Check-in result"]
  node_insights_ui["Wellbeing insights<br/>[InsightsPage.tsx]"]
  node_overview_ui["Student overview<br/>[OverviewPage.tsx]"]
  node_planner_ui["Study-life planner<br/>[PlannerPage.tsx]"]
  node_breather["Breather timer<br/>[BreatherTimer.tsx]"]
  node_support_ui["Support network"]
  node_settings_ui["Privacy settings<br/>[SettingsPage.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_backend["Backend services"]
  node_backend_app["FastAPI app<br/>[main.py]"]
  node_checkin_api["Check-in endpoint<br/>[checkin.py]"]
  node_insights_api["Insights endpoint<br/>[insights.py]"]
  node_planner_api["Planner endpoint<br/>[planner.py]"]
  node_support_api["Support and settings"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_analytics["Wellbeing analytics<br/>[analytics.py]"]
end

subgraph group_safety["Safety and guidance"]
  node_safety_eval["Safety evaluator"]
  node_ai_guidance["Supportive guidance<br/>[ai_guidance.py]"]
  node_ai_providers["AI provider adapters"]
end

subgraph group_state["Persistence and support"]
  node_storage[("Session storage<br/>[storage.py]")]
  node_support_directory["Support directory"]
end

node_student(("Student"))
node_human_support(("Human support"))

node_student -->|"visits"| node_landing
node_student -->|"submits check-in"| node_checkin_ui
node_student -->|"reviews patterns"| node_insights_ui
node_student -->|"plans routines"| node_planner_ui
node_student -->|"seeks support"| node_support_ui
node_app_shell -->|"routes to"| node_landing
node_app_shell -->|"routes to"| node_overview_ui
node_app_shell -->|"routes to"| node_checkin_ui
node_app_shell -->|"routes to"| node_result_ui
node_app_shell -->|"routes to"| node_insights_ui
node_app_shell -->|"routes to"| node_planner_ui
node_app_shell -->|"routes to"| node_support_ui
node_app_shell -->|"routes to"| node_settings_ui
node_checkin_ui -.->|"submits data"| node_api_client
node_result_ui -->|"loads result"| node_api_client
node_insights_ui -->|"requests insights"| node_api_client
node_planner_ui -->|"manages tasks"| node_api_client
node_planner_ui -->|"renders"| node_breather
node_api_client -->|"POST check-in"| node_checkin_api
node_api_client -->|"requests insights"| node_insights_api
node_api_client -->|"manages tasks"| node_planner_api
node_api_client -->|"manages settings"| node_support_api
node_backend_app -->|"registers route"| node_checkin_api
node_backend_app -->|"registers route"| node_insights_api
node_backend_app -->|"registers route"| node_planner_api
node_backend_app -->|"registers routes"| node_support_api
node_checkin_api -->|"validates payload"| node_schemas
node_checkin_api -->|"reads history"| node_storage
node_checkin_api -->|"evaluates risk"| node_safety_eval
node_checkin_api -->|"writes metrics"| node_storage
node_checkin_api -->|"requests guidance"| node_ai_guidance
node_checkin_api -->|"fetches contacts"| node_support_directory
node_safety_eval -->|"permits eligible routes"| node_ai_guidance
node_checkin_api -->|"returns escalation contacts"| node_human_support
node_ai_guidance -->|"selects provider"| node_ai_providers
node_insights_api -->|"computes summaries"| node_analytics
node_planner_api -->|"reads and writes tasks"| node_storage
node_support_api -->|"reads and writes settings"| node_storage
node_support_api -->|"serves contacts"| node_support_directory

click node_landing "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/LandingPage.tsx"
click node_app_shell "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/App.tsx"
click node_checkin_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/CheckInPage.tsx"
click node_result_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/CheckInResultPage.tsx"
click node_insights_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/InsightsPage.tsx"
click node_overview_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/OverviewPage.tsx"
click node_planner_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/PlannerPage.tsx"
click node_breather "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/components/planner/BreatherTimer.tsx"
click node_support_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/SupportNetworkPage.tsx"
click node_settings_ui "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/SettingsPage.tsx"
click node_api_client "https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/services/api.ts"
click node_backend_app "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/main.py"
click node_checkin_api "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/checkin.py"
click node_insights_api "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/insights.py"
click node_planner_api "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/planner.py"
click node_support_api "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/support_and_settings.py"
click node_schemas "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/models/schemas.py"
click node_safety_eval "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/safety_evaluator.py"
click node_ai_guidance "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/ai_guidance.py"
click node_ai_providers "https://github.com/nikhi20-900/calmspace/tree/main/backend/app/services/ai_providers"
click node_analytics "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/analytics.py"
click node_storage "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/storage.py"
click node_support_directory "https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/support_directory.py"

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_landing,node_app_shell,node_checkin_ui,node_result_ui,node_insights_ui,node_overview_ui,node_planner_ui,node_breather,node_support_ui,node_settings_ui,node_api_client toneAmber
class node_backend_app,node_checkin_api,node_insights_api,node_planner_api,node_support_api,node_schemas,node_analytics toneMint
class node_safety_eval,node_ai_guidance,node_ai_providers toneRose
class node_storage,node_support_directory,node_student,node_human_support toneIndigo
```

## Components

### Frontend features

- [Landing experience](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/LandingPage.tsx): `frontend/src/pages/LandingPage.tsx`
- [App shell](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Check-in form](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/CheckInPage.tsx): `frontend/src/pages/CheckInPage.tsx`
- [Check-in result](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/CheckInResultPage.tsx): `frontend/src/pages/CheckInResultPage.tsx`
- [Wellbeing insights](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/InsightsPage.tsx): `frontend/src/pages/InsightsPage.tsx`
- [Student overview](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/OverviewPage.tsx): `frontend/src/pages/OverviewPage.tsx`
- [Study-life planner](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/PlannerPage.tsx): `frontend/src/pages/PlannerPage.tsx`
- [Breather timer](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/components/planner/BreatherTimer.tsx): `frontend/src/components/planner/BreatherTimer.tsx`
- [Support network](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/SupportNetworkPage.tsx): `frontend/src/pages/SupportNetworkPage.tsx`
- [Privacy settings](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/pages/SettingsPage.tsx): `frontend/src/pages/SettingsPage.tsx`
- [API client](https://github.com/nikhi20-900/calmspace/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Backend services

- [FastAPI app](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/main.py): `backend/app/main.py`
- [Check-in endpoint](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/checkin.py): `backend/app/routers/checkin.py`
- [Insights endpoint](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/insights.py): `backend/app/routers/insights.py`
- [Planner endpoint](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/planner.py): `backend/app/routers/planner.py`
- [Support and settings](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/routers/support_and_settings.py): `backend/app/routers/support_and_settings.py`
- [API schemas](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`
- [Wellbeing analytics](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/analytics.py): `backend/app/services/analytics.py`

### Safety and guidance

- [Safety evaluator](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/safety_evaluator.py): `backend/app/services/safety_evaluator.py`
- [Supportive guidance](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/ai_guidance.py): `backend/app/services/ai_guidance.py`
- [AI provider adapters](https://github.com/nikhi20-900/calmspace/tree/main/backend/app/services/ai_providers): `backend/app/services/ai_providers`

### Persistence and support

- [Session storage](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/storage.py): `backend/app/services/storage.py`
- [Support directory](https://github.com/nikhi20-900/calmspace/blob/main/backend/app/services/support_directory.py): `backend/app/services/support_directory.py`

### Other components

- **Student**
- **Human support**

## Connections

- Student → Landing experience: visits
- Student → Check-in form: submits check-in
- Student → Wellbeing insights: reviews patterns
- Student → Study-life planner: plans routines
- Student → Support network: seeks support
- App shell → Landing experience: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Student overview: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Check-in form: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Check-in result: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Wellbeing insights: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Study-life planner: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Support network: routes to (evidence: `frontend/src/App.tsx`)
- App shell → Privacy settings: routes to (evidence: `frontend/src/App.tsx`)
- Check-in form → API client: submits data
- Check-in result → API client: loads result (evidence: `frontend/src/pages/CheckInResultPage.tsx`)
- Wellbeing insights → API client: requests insights (evidence: `frontend/src/pages/InsightsPage.tsx`)
- Study-life planner → API client: manages tasks (evidence: `frontend/src/pages/PlannerPage.tsx`)
- Study-life planner → Breather timer: renders (evidence: `frontend/src/pages/PlannerPage.tsx`)
- API client → Check-in endpoint: POST check-in (evidence: `frontend/src/services/api.ts`)
- API client → Insights endpoint: requests insights (evidence: `frontend/src/services/api.ts`)
- API client → Planner endpoint: manages tasks (evidence: `frontend/src/services/api.ts`)
- API client → Support and settings: manages settings (evidence: `frontend/src/services/api.ts`)
- FastAPI app → Check-in endpoint: registers route (evidence: `backend/app/main.py`)
- FastAPI app → Insights endpoint: registers route (evidence: `backend/app/main.py`)
- FastAPI app → Planner endpoint: registers route (evidence: `backend/app/main.py`)
- FastAPI app → Support and settings: registers routes (evidence: `backend/app/main.py`)
- Check-in endpoint → API schemas: validates payload (evidence: `backend/app/routers/checkin.py`)
- Check-in endpoint → Session storage: reads history (evidence: `backend/app/routers/checkin.py`)
- Check-in endpoint → Safety evaluator: evaluates risk (evidence: `backend/app/routers/checkin.py`)
- Check-in endpoint → Session storage: writes metrics (evidence: `backend/app/routers/checkin.py`)
- Check-in endpoint → Supportive guidance: requests guidance (evidence: `backend/app/routers/checkin.py`)
- Check-in endpoint → Support directory: fetches contacts (evidence: `backend/app/routers/checkin.py`)
- Safety evaluator → Supportive guidance: permits eligible routes (evidence: `backend/app/routers/checkin.py`)
- Check-in endpoint → Human support: returns escalation contacts
- Supportive guidance → AI provider adapters: selects provider (evidence: `backend/app/services/ai_guidance.py`)
- Insights endpoint → Wellbeing analytics: computes summaries (evidence: `backend/app/routers/insights.py`)
- Planner endpoint → Session storage: reads and writes tasks (evidence: `backend/app/routers/planner.py`)
- Support and settings → Session storage: reads and writes settings (evidence: `backend/app/routers/support_and_settings.py`)
- Support and settings → Support directory: serves contacts (evidence: `backend/app/routers/support_and_settings.py`)
