# nethras314/memora architecture

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

- Interactive diagram: https://gitdiagram.com/nethras314/memora
- Repository: https://github.com/nethras314/memora

## Overview

MEMORA supports patient and caregiver cognitive and daily-life assistance through web and mobile clients, with FastAPI services for patient records, memories, routines, cognitive exercises, voice, and caregiver insights. Clients authenticate, select a patient, and use those domain features; caregivers can review cognitive stability. The backend uses Supabase for persistence and Sarvam AI for regional speech. The README documents the overall integrations; several client and route implementations were not sampled, so their internal call paths are not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/nethras314/memora/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/core/database.py`](https://github.com/nethras314/memora/blob/main/backend/app/core/database.py) (Supabase connection), [`backend/app/api/routes/voice.py`](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/voice.py) (Voice endpoints), [`backend/app/models/schemas.py`](https://github.com/nethras314/memora/blob/main/backend/app/models/schemas.py) (Domain schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Patient and caregiver apps"]
  node_web["Web application<br/>[App.jsx]"]
  node_web_auth["Web authentication<br/>[AuthContext.jsx]"]
  node_web_features["Web care features"]
  node_web_voice["Web voice assistant"]
  node_web_api["Web API client<br/>[api.js]"]
  node_mobile["Mobile application<br/>[App.js]"]
  node_mobile_auth["Mobile authentication<br/>[auth.js]"]
  node_mobile_features["Mobile care screens"]
  node_mobile_api["Mobile API client<br/>[api.js]"]
end

subgraph group_api["Backend domain API"]
  node_backend_entry["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_patient_routes["Patient records<br/>[patients.py]"]
  node_memory_routes["Memory bank<br/>[memories.py]"]
  node_routine_routes["Routines and reminders<br/>[routines.py]"]
  node_cognitive_routes["Cognitive exercises<br/>[cognitive.py]"]
  node_voice_routes["Voice endpoints<br/>[voice.py]"]
  node_caregiver_routes["Caregiver insights<br/>[caregiver.py]"]
end

subgraph group_services["Backend services"]
  node_schemas["Domain schemas<br/>[schemas.py]"]
  node_dda["Difficulty and stability engine<br/>[dda_engine.py]"]
  node_questions["Question bank<br/>[question_bank.py]"]
  node_sarvam["Regional voice service<br/>[sarvam_service.py]"]
end

subgraph group_platform["Identity and persistence"]
  node_access["Patient access control<br/>[access.py]"]
  node_security["Authentication and roles<br/>[security.py]"]
  node_database["Supabase connection<br/>[database.py]"]
end

node_patient(("Patient or caregiver"))
node_supabase[("Supabase")]
node_sarvam_external["Sarvam AI"]

node_patient -->|"uses"| node_web
node_patient -->|"uses"| node_mobile
node_web -->|"provides auth"| node_web_auth
node_web -->|"renders"| node_web_features
node_web -->|"opens"| node_web_voice
node_web -->|"uses"| node_web_api
node_web_auth -->|"calls"| node_web_api
node_web_voice -->|"calls"| node_web_api
node_mobile -->|"provides auth"| node_mobile_auth
node_mobile -->|"routes screens"| node_mobile_features
node_mobile_auth -->|"calls"| node_mobile_api
node_web_api -->|"sends REST requests"| node_backend_entry
node_mobile_api -.->|"sends API requests"| node_backend_entry
node_backend_entry -->|"registers routes"| node_auth_routes
node_backend_entry -->|"registers routes"| node_patient_routes
node_backend_entry -->|"registers routes"| node_memory_routes
node_backend_entry -->|"registers routes"| node_routine_routes
node_backend_entry -->|"registers routes"| node_cognitive_routes
node_backend_entry -->|"registers routes"| node_voice_routes
node_backend_entry -->|"registers routes"| node_caregiver_routes
node_auth_routes -->|"uses auth"| node_security
node_auth_routes -->|"reads and writes"| node_database
node_patient_routes -->|"checks access"| node_access
node_patient_routes -->|"reads and writes"| node_database
node_memory_routes -->|"reads and writes"| node_database
node_routine_routes -->|"reads and writes"| node_database
node_cognitive_routes -->|"adapts difficulty"| node_dda
node_cognitive_routes -->|"loads questions"| node_questions
node_caregiver_routes -->|"calculates stability"| node_dda
node_caregiver_routes -->|"checks access"| node_access
node_voice_routes -->|"uses voice service"| node_sarvam
node_voice_routes -->|"uses routine data"| node_routine_routes
node_voice_routes -->|"uses memory data"| node_memory_routes
node_voice_routes -->|"uses patient data"| node_patient_routes
node_sarvam -->|"connects to"| node_sarvam_external
node_database -->|"connects to"| node_supabase
node_auth_routes -->|"validates payloads"| node_schemas
node_patient_routes -->|"validates payloads"| node_schemas
node_memory_routes -->|"validates payloads"| node_schemas
node_routine_routes -->|"validates payloads"| node_schemas
node_cognitive_routes -->|"validates payloads"| node_schemas
node_voice_routes -->|"validates payloads"| node_schemas
node_caregiver_routes -->|"validates payloads"| node_schemas
node_access -->|"queries patients"| node_database
node_security -->|"checks Supabase identity"| node_database

click node_web "https://github.com/nethras314/memora/blob/main/frontend/src/App.jsx"
click node_web_auth "https://github.com/nethras314/memora/blob/main/frontend/src/context/AuthContext.jsx"
click node_web_features "https://github.com/nethras314/memora/tree/main/frontend/src/pages"
click node_web_voice "https://github.com/nethras314/memora/blob/main/frontend/src/components/VoiceAssistantModal.jsx"
click node_web_api "https://github.com/nethras314/memora/blob/main/frontend/src/services/api.js"
click node_mobile "https://github.com/nethras314/memora/blob/main/mobile/App.js"
click node_mobile_auth "https://github.com/nethras314/memora/blob/main/mobile/src/lib/auth.js"
click node_mobile_features "https://github.com/nethras314/memora/tree/main/mobile/src/screens"
click node_mobile_api "https://github.com/nethras314/memora/blob/main/mobile/src/lib/api.js"
click node_backend_entry "https://github.com/nethras314/memora/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/auth.py"
click node_patient_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/patients.py"
click node_memory_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/memories.py"
click node_routine_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/routines.py"
click node_cognitive_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/cognitive.py"
click node_voice_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/voice.py"
click node_caregiver_routes "https://github.com/nethras314/memora/blob/main/backend/app/api/routes/caregiver.py"
click node_schemas "https://github.com/nethras314/memora/blob/main/backend/app/models/schemas.py"
click node_dda "https://github.com/nethras314/memora/blob/main/backend/app/services/dda_engine.py"
click node_questions "https://github.com/nethras314/memora/blob/main/backend/app/services/question_bank.py"
click node_sarvam "https://github.com/nethras314/memora/blob/main/backend/app/services/sarvam_service.py"
click node_access "https://github.com/nethras314/memora/blob/main/backend/app/core/access.py"
click node_security "https://github.com/nethras314/memora/blob/main/backend/app/core/security.py"
click node_database "https://github.com/nethras314/memora/blob/main/backend/app/core/database.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_web,node_web_auth,node_web_features,node_web_voice,node_web_api,node_mobile,node_mobile_auth,node_mobile_features,node_mobile_api toneBlue
class node_backend_entry,node_auth_routes,node_patient_routes,node_memory_routes,node_routine_routes,node_cognitive_routes,node_voice_routes,node_caregiver_routes,node_supabase toneAmber
class node_schemas,node_dda,node_questions,node_sarvam toneMint
class node_access,node_security,node_database toneRose
class node_patient,node_sarvam_external toneIndigo
```

## Components

### Patient and caregiver apps

- [Web application](https://github.com/nethras314/memora/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Web authentication](https://github.com/nethras314/memora/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Web care features](https://github.com/nethras314/memora/tree/main/frontend/src/pages): `frontend/src/pages`
- [Web voice assistant](https://github.com/nethras314/memora/blob/main/frontend/src/components/VoiceAssistantModal.jsx): `frontend/src/components/VoiceAssistantModal.jsx`
- [Web API client](https://github.com/nethras314/memora/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Mobile application](https://github.com/nethras314/memora/blob/main/mobile/App.js): `mobile/App.js`
- [Mobile authentication](https://github.com/nethras314/memora/blob/main/mobile/src/lib/auth.js): `mobile/src/lib/auth.js`
- [Mobile care screens](https://github.com/nethras314/memora/tree/main/mobile/src/screens): `mobile/src/screens`
- [Mobile API client](https://github.com/nethras314/memora/blob/main/mobile/src/lib/api.js): `mobile/src/lib/api.js`

### Backend domain API

- [FastAPI application](https://github.com/nethras314/memora/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [Patient records](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/patients.py): `backend/app/api/routes/patients.py`
- [Memory bank](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/memories.py): `backend/app/api/routes/memories.py`
- [Routines and reminders](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/routines.py): `backend/app/api/routes/routines.py`
- [Cognitive exercises](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/cognitive.py): `backend/app/api/routes/cognitive.py`
- [Voice endpoints](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/voice.py): `backend/app/api/routes/voice.py`
- [Caregiver insights](https://github.com/nethras314/memora/blob/main/backend/app/api/routes/caregiver.py): `backend/app/api/routes/caregiver.py`

### Backend services

- [Domain schemas](https://github.com/nethras314/memora/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`
- [Difficulty and stability engine](https://github.com/nethras314/memora/blob/main/backend/app/services/dda_engine.py): `backend/app/services/dda_engine.py`
- [Question bank](https://github.com/nethras314/memora/blob/main/backend/app/services/question_bank.py): `backend/app/services/question_bank.py`
- [Regional voice service](https://github.com/nethras314/memora/blob/main/backend/app/services/sarvam_service.py): `backend/app/services/sarvam_service.py`

### Identity and persistence

- [Patient access control](https://github.com/nethras314/memora/blob/main/backend/app/core/access.py): `backend/app/core/access.py`
- [Authentication and roles](https://github.com/nethras314/memora/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [Supabase connection](https://github.com/nethras314/memora/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Other components

- **Patient or caregiver**
- **Supabase**
- **Sarvam AI**

## Connections

- Patient or caregiver → Web application: uses (evidence: `README.md`)
- Patient or caregiver → Mobile application: uses (evidence: `README.md`)
- Web application → Web authentication: provides auth (evidence: `frontend/src/App.jsx`)
- Web application → Web care features: renders (evidence: `frontend/src/App.jsx`)
- Web application → Web voice assistant: opens (evidence: `frontend/src/App.jsx`)
- Web application → Web API client: uses (evidence: `frontend/src/App.jsx`)
- Web authentication → Web API client: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- Web voice assistant → Web API client: calls (evidence: `frontend/src/components/VoiceAssistantModal.jsx`)
- Mobile application → Mobile authentication: provides auth (evidence: `mobile/App.js`)
- Mobile application → Mobile care screens: routes screens (evidence: `mobile/App.js`)
- Mobile authentication → Mobile API client: calls (evidence: `mobile/src/lib/auth.js`)
- Web API client → FastAPI application: sends REST requests (evidence: `frontend/src/services/api.js`)
- Mobile API client → FastAPI application: sends API requests
- FastAPI application → Authentication routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Patient records: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Memory bank: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Routines and reminders: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Cognitive exercises: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Voice endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Caregiver insights: registers routes (evidence: `backend/app/main.py`)
- Authentication routes → Authentication and roles: uses auth (evidence: `backend/app/api/routes/auth.py`)
- Authentication routes → Supabase connection: reads and writes (evidence: `backend/app/api/routes/auth.py`)
- Patient records → Patient access control: checks access (evidence: `backend/app/api/routes/patients.py`)
- Patient records → Supabase connection: reads and writes (evidence: `backend/app/api/routes/patients.py`)
- Memory bank → Supabase connection: reads and writes (evidence: `backend/app/api/routes/memories.py`)
- Routines and reminders → Supabase connection: reads and writes (evidence: `backend/app/api/routes/routines.py`)
- Cognitive exercises → Difficulty and stability engine: adapts difficulty (evidence: `backend/app/api/routes/cognitive.py`)
- Cognitive exercises → Question bank: loads questions (evidence: `backend/app/api/routes/cognitive.py`)
- Caregiver insights → Difficulty and stability engine: calculates stability (evidence: `backend/app/api/routes/caregiver.py`)
- Caregiver insights → Patient access control: checks access (evidence: `backend/app/api/routes/caregiver.py`)
- Voice endpoints → Regional voice service: uses voice service (evidence: `backend/app/api/routes/voice.py`)
- Voice endpoints → Routines and reminders: uses routine data (evidence: `backend/app/api/routes/voice.py`)
- Voice endpoints → Memory bank: uses memory data (evidence: `backend/app/api/routes/voice.py`)
- Voice endpoints → Patient records: uses patient data (evidence: `backend/app/api/routes/voice.py`)
- Regional voice service → Sarvam AI: connects to (evidence: `README.md`)
- Supabase connection → Supabase: connects to (evidence: `backend/app/core/database.py`)
- Authentication routes → Domain schemas: validates payloads (evidence: `backend/app/api/routes/auth.py`)
- Patient records → Domain schemas: validates payloads (evidence: `backend/app/api/routes/patients.py`)
- Memory bank → Domain schemas: validates payloads (evidence: `backend/app/api/routes/memories.py`)
- Routines and reminders → Domain schemas: validates payloads (evidence: `backend/app/api/routes/routines.py`)
- Cognitive exercises → Domain schemas: validates payloads (evidence: `backend/app/api/routes/cognitive.py`)
- Voice endpoints → Domain schemas: validates payloads (evidence: `backend/app/api/routes/voice.py`)
- Caregiver insights → Domain schemas: validates payloads (evidence: `backend/app/api/routes/caregiver.py`)
- Patient access control → Supabase connection: queries patients (evidence: `backend/app/core/access.py`)
- Authentication and roles → Supabase connection: checks Supabase identity (evidence: `backend/app/core/security.py`)
