# sreejasadhu/keystoneapp architecture

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

- Interactive diagram: https://gitdiagram.com/sreejasadhu/keystoneapp
- Repository: https://github.com/sreejasadhu/keystoneapp

## Overview

KeyStone is a care-coordination platform connecting patients, therapists, and caregivers, with administrative oversight. Its user workflow spans account access and verification, therapist discovery and booking, session management and payment, then follow-ups, reflections, check-ins, and progress tracking. Caregiver links and messaging support continued care; analytics and verification tools support clinicians and administrators. The server mounts these capabilities as API routes over Prisma-backed data, with calendar and payment integrations. Source excerpts confirm only selected client-to-API and service calls, so uncertain wiring is omitted.

Main entry points: [`server/src/index.ts`](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/index.ts) (HTTP application), [`server/src/lib/prisma.ts`](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/lib/prisma.ts) (Application database), [`server/src/routes/sessions.routes.ts`](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/sessions.routes.ts) (Sessions), [`client/src/main.tsx`](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/main.tsx) (Client entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_client_entry["Client entry<br/>[main.tsx]"]
  node_app["App shell<br/>[App.tsx]"]
  node_router["Page router<br/>[index.tsx]"]
  node_session_ui["Session detail<br/>[SessionDetail.tsx]"]
  node_dashboard_ui["Care dashboards<br/>[Dashboard.tsx]"]
  node_booking_ui["Booking flow<br/>[BookSession.tsx]"]
  node_auth_state["Auth state<br/>[useAuthStore.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_server["API and domain"]
  node_server_app["HTTP application<br/>[index.ts]"]
  node_auth_routes["Authentication<br/>[auth.routes.ts]"]
  node_verification_routes["Verification"]
  node_session_routes["Sessions<br/>[sessions.routes.ts]"]
  node_caregiver_routes["Caregiver access"]
  node_care_routes["Care activities"]
  node_admin_routes["Admin oversight"]
  node_session_job["Session generator"]
  node_streak_service["Streak tracking<br/>[streakService.ts]"]
end

subgraph group_state["Platform data"]
  node_database[("Application database<br/>[prisma.ts]")]
end

subgraph group_integrations["External services"]
  node_calendar_service["Google Calendar<br/>[googleCalendar.ts]"]
  node_payment_service["Razorpay payments<br/>[razorpayService.ts]"]
end

node_patient(("Patient"))
node_therapist(("Therapist"))
node_caregiver(("Caregiver"))
node_admin(("Administrator"))
node_google_calendar["Google Calendar"]
node_razorpay["Razorpay"]

node_patient -->|"uses"| node_client_entry
node_therapist -->|"uses"| node_client_entry
node_caregiver -->|"uses"| node_client_entry
node_admin -->|"uses"| node_client_entry
node_client_entry -->|"renders"| node_app
node_app -->|"routes"| node_router
node_session_ui -->|"requests session data"| node_api_client
node_api_client -->|"sends API requests"| node_server_app
node_server_app -->|"mounts auth"| node_auth_routes
node_server_app -->|"mounts sessions"| node_session_routes
node_server_app -->|"mounts verification"| node_verification_routes
node_server_app -->|"mounts caregiver"| node_caregiver_routes
node_server_app -->|"mounts care routes"| node_care_routes
node_server_app -->|"mounts admin routes"| node_admin_routes
node_server_app -->|"starts recurring job"| node_session_job
node_auth_routes -->|"reads and writes"| node_database
node_verification_routes -->|"reads and writes"| node_database
node_session_routes -->|"reads and writes"| node_database
node_caregiver_routes -->|"reads and writes"| node_database
node_admin_routes -->|"queries metrics"| node_database
node_session_job -->|"creates sessions"| node_database
node_session_routes -->|"syncs session events"| node_calendar_service
node_session_routes -->|"requests refunds"| node_payment_service
node_session_routes -->|"updates streaks"| node_streak_service
node_calendar_service -.->|"syncs events"| node_google_calendar
node_payment_service -.->|"processes payments"| node_razorpay
node_streak_service -->|"reads and updates"| node_database

click node_client_entry "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/main.tsx"
click node_app "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/App.tsx"
click node_router "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/router/index.tsx"
click node_session_ui "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/pages/SessionDetail.tsx"
click node_dashboard_ui "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/pages/Dashboard.tsx"
click node_booking_ui "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/pages/BookSession.tsx"
click node_auth_state "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/store/useAuthStore.ts"
click node_api_client "https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/lib/api.ts"
click node_server_app "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/index.ts"
click node_auth_routes "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/auth.routes.ts"
click node_verification_routes "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/verification.routes.ts"
click node_session_routes "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/sessions.routes.ts"
click node_caregiver_routes "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/caregiver.routes.ts"
click node_care_routes "https://github.com/sreejasadhu/keystoneapp/tree/main/server/src/routes"
click node_admin_routes "https://github.com/sreejasadhu/keystoneapp/tree/main/server/src/routes"
click node_session_job "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/jobs/sessionGenerator.ts"
click node_streak_service "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/services/streakService.ts"
click node_database "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/lib/prisma.ts"
click node_calendar_service "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/services/googleCalendar.ts"
click node_payment_service "https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/services/razorpayService.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_client_entry,node_app,node_router,node_session_ui,node_dashboard_ui,node_booking_ui,node_auth_state,node_api_client toneBlue
class node_server_app,node_auth_routes,node_verification_routes,node_session_routes,node_caregiver_routes,node_care_routes,node_admin_routes,node_session_job,node_streak_service toneAmber
class node_database,node_therapist toneMint
class node_calendar_service,node_payment_service toneRose
class node_patient,node_caregiver,node_admin,node_google_calendar,node_razorpay toneIndigo
```

## Components

### Web application

- [Client entry](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/main.tsx): `client/src/main.tsx`
- [App shell](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Page router](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/router/index.tsx): `client/src/router/index.tsx`
- [Session detail](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/pages/SessionDetail.tsx): `client/src/pages/SessionDetail.tsx`
- [Care dashboards](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/pages/Dashboard.tsx): `client/src/pages/Dashboard.tsx`
- [Booking flow](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/pages/BookSession.tsx): `client/src/pages/BookSession.tsx`
- [Auth state](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/store/useAuthStore.ts): `client/src/store/useAuthStore.ts`
- [API client](https://github.com/sreejasadhu/keystoneapp/blob/main/client/src/lib/api.ts): `client/src/lib/api.ts`

### API and domain

- [HTTP application](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/index.ts): `server/src/index.ts`
- [Authentication](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/auth.routes.ts): `server/src/routes/auth.routes.ts`
- [Verification](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/verification.routes.ts): `server/src/routes/verification.routes.ts`
- [Sessions](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/sessions.routes.ts): `server/src/routes/sessions.routes.ts`
- [Caregiver access](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/routes/caregiver.routes.ts): `server/src/routes/caregiver.routes.ts`
- [Care activities](https://github.com/sreejasadhu/keystoneapp/tree/main/server/src/routes): `server/src/routes`
- [Admin oversight](https://github.com/sreejasadhu/keystoneapp/tree/main/server/src/routes): `server/src/routes`
- [Session generator](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/jobs/sessionGenerator.ts): `server/src/jobs/sessionGenerator.ts`
- [Streak tracking](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/services/streakService.ts): `server/src/services/streakService.ts`

### Platform data

- [Application database](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/lib/prisma.ts): `server/src/lib/prisma.ts`

### External services

- [Google Calendar](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/services/googleCalendar.ts): `server/src/services/googleCalendar.ts`
- [Razorpay payments](https://github.com/sreejasadhu/keystoneapp/blob/main/server/src/services/razorpayService.ts): `server/src/services/razorpayService.ts`

### Other components

- **Patient**
- **Therapist**
- **Caregiver**
- **Administrator**
- **Google Calendar**
- **Razorpay**

## Connections

- Patient → Client entry: uses
- Therapist → Client entry: uses
- Caregiver → Client entry: uses
- Administrator → Client entry: uses
- Client entry → App shell: renders
- App shell → Page router: routes
- Session detail → API client: requests session data
- API client → HTTP application: sends API requests
- HTTP application → Authentication: mounts auth
- HTTP application → Sessions: mounts sessions
- HTTP application → Verification: mounts verification
- HTTP application → Caregiver access: mounts caregiver
- HTTP application → Care activities: mounts care routes
- HTTP application → Admin oversight: mounts admin routes
- HTTP application → Session generator: starts recurring job
- Authentication → Application database: reads and writes
- Verification → Application database: reads and writes
- Sessions → Application database: reads and writes
- Caregiver access → Application database: reads and writes
- Admin oversight → Application database: queries metrics
- Session generator → Application database: creates sessions
- Sessions → Google Calendar: syncs session events
- Sessions → Razorpay payments: requests refunds
- Sessions → Streak tracking: updates streaks
- Google Calendar → Google Calendar: syncs events
- Razorpay payments → Razorpay: processes payments
- Streak tracking → Application database: reads and updates
