# kaemiii-ss/smaran architecture

> Architecture diagram of the GitHub repository kaemiii-ss/smaran, 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/kaemiii-ss/smaran
- Repository: https://github.com/kaemiii-ss/smaran

## Overview

Smaran is a memory-care companion combining patient and caregiver experiences, an AI chat service, routines, and cognitive games. The evidenced game workflow covers launching a game, generating or playing a round, and tracking completion; backend examples show authenticated requests reaching chat or routine handlers and persisting results. The tree also indicates broader care, account, and game capabilities. Several frontend and backend subsystems were not sampled, so those are represented conservatively without asserted call relationships.

Main entry points: [`frontend/src/game_5/src/App.jsx`](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/App.jsx) (Recall game app), [`backend/src/routes`](https://github.com/kaemiii-ss/smaran/tree/main/backend/src/routes) (API routes), [`Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx`](https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx) (Rhythm gameplay), [`Games/bubble_digits_game/src/components/games/ColorNumberMatchGame.jsx`](https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/components/games/ColorNumberMatchGame.jsx) (Color number match)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_care["Care Platform"]
  node_frontend["Care frontend"]
  node_dashboards["Care dashboards"]
  node_gamecatalog["Games catalog<br/>[GamesCatalog.jsx]"]
end

subgraph group_api["Backend Services"]
  node_api_routes["API routes"]
  node_auth["Authentication<br/>[auth.controller.js]"]
  node_users[("User records<br/>[user.model.js]")]
  node_care_links[("Caregiver links")]
  node_routine_handler["Routine handlers"]
  node_routines[("Routine records<br/>[routine.model.js]")]
  node_chat_handler["Chat handlers"]
  node_chat_sessions[("Chat sessions")]
  node_gemini["Gemini service<br/>[gemini.service.js]"]
  node_other_services["Other care APIs"]
end

subgraph group_games["Cognitive Games"]
  node_recall_app["Recall game app<br/>[App.jsx]"]
  node_recall_board["Card board<br/>[GameBoard.jsx]"]
  node_recall_shell["Game shell<br/>[GameShell.jsx]"]
  node_recall_feedback["Game feedback"]
  node_recall_confetti["Win celebration<br/>[ConfettiCanvas.jsx]"]
  node_bubble_app["Bubble game app<br/>[App.jsx]"]
  node_color_match["Color number match"]
  node_rhythm_hook["Rhythm gameplay<br/>[useRhythmGame.jsx]"]
  node_name_game["Name game<br/>[App.jsx]"]
end

subgraph group_gamecore["Game Mechanics"]
  node_recall_levels["Level definitions<br/>[levels.js]"]
  node_pairs_engine["Pair deck engine<br/>[usePairsEngine.js]"]
  node_recall_tracker["Progress tracker<br/>[useTracker.js]"]
  node_bubble_audio["Audio engine<br/>[audioEngine.js]"]
  node_bubble_cognition["Cognitive engine<br/>[cognitiveEngine.js]"]
  node_bubble_voice["Voice engine<br/>[voiceEngine.js]"]
  node_rhythm_audio["Rhythm audio<br/>[useAudioEngine.jsx]"]
  node_rhythm_voice["Rhythm voice"]
  node_rhythm_nodes["Rhythm nodes<br/>[nodes.js]"]
  node_rhythm_language["Language context"]
end

node_person(("Patient or caregiver"))
node_ai_service["Gemini AI"]

node_person -.->|"uses"| node_frontend
node_frontend -.->|"offers"| node_dashboards
node_frontend -.->|"offers"| node_gamecatalog
node_api_routes -.->|"routes auth"| node_auth
node_auth -->|"reads and writes"| node_users
node_auth -->|"creates link"| node_care_links
node_api_routes -->|"routes routines"| node_routine_handler
node_routine_handler -->|"reads and writes"| node_routines
node_api_routes -->|"routes chat"| node_chat_handler
node_chat_handler -->|"reads and writes"| node_chat_sessions
node_chat_handler -->|"requests reply"| node_gemini
node_gemini -->|"generates reply"| node_ai_service
node_api_routes -.->|"routes other APIs"| node_other_services
node_recall_app -->|"builds deck"| node_pairs_engine
node_pairs_engine -->|"reads levels"| node_recall_levels
node_recall_app -->|"renders board"| node_recall_board
node_recall_app -->|"renders in shell"| node_recall_shell
node_recall_app -->|"tracks play"| node_recall_tracker
node_recall_app -->|"shows feedback"| node_recall_feedback
node_recall_app -->|"shows celebration"| node_recall_confetti
node_bubble_app -->|"launches game"| node_color_match
node_color_match -.->|"uses audio"| node_bubble_audio
node_color_match -.->|"uses cognition"| node_bubble_cognition
node_color_match -.->|"uses voice"| node_bubble_voice
node_rhythm_hook -->|"plays tones"| node_rhythm_audio
node_rhythm_hook -->|"speaks prompts"| node_rhythm_voice
node_rhythm_hook -->|"selects nodes"| node_rhythm_nodes
node_rhythm_hook -->|"reads language"| node_rhythm_language
node_name_game -.->|"embedded in platform"| node_frontend

click node_frontend "https://github.com/kaemiii-ss/smaran/tree/main/frontend/src"
click node_dashboards "https://github.com/kaemiii-ss/smaran/tree/main/frontend/src/pages"
click node_gamecatalog "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/pages/GamesCatalog.jsx"
click node_api_routes "https://github.com/kaemiii-ss/smaran/tree/main/backend/src/routes"
click node_auth "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/controllers/auth.controller.js"
click node_users "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/user.model.js"
click node_care_links "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/patientCaregiver.model.js"
click node_routine_handler "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/controllers/routine.controller.js"
click node_routines "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/routine.model.js"
click node_chat_handler "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/controllers/gemini.controller.js"
click node_chat_sessions "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/chatbotSession.model.js"
click node_gemini "https://github.com/kaemiii-ss/smaran/blob/main/backend/src/gemini/gemini.service.js"
click node_other_services "https://github.com/kaemiii-ss/smaran/tree/main/backend/src/controllers"
click node_recall_app "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/App.jsx"
click node_recall_board "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/GameBoard.jsx"
click node_recall_shell "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/GameShell.jsx"
click node_recall_levels "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/config/levels.js"
click node_pairs_engine "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/hooks/usePairsEngine.js"
click node_recall_tracker "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/hooks/useTracker.js"
click node_recall_feedback "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/FeedbackOverlay.jsx"
click node_recall_confetti "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/ConfettiCanvas.jsx"
click node_bubble_app "https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/App.jsx"
click node_color_match "https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/components/games/ColorNumberMatchGame.jsx"
click node_bubble_audio "https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/lib/audioEngine.js"
click node_bubble_cognition "https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/lib/cognitiveEngine.js"
click node_bubble_voice "https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/lib/voiceEngine.js"
click node_rhythm_hook "https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx"
click node_rhythm_audio "https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useAudioEngine.jsx"
click node_rhythm_voice "https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useVoiceFeedback.jsx"
click node_rhythm_nodes "https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/lib/nodes.js"
click node_rhythm_language "https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/lib/LanguageContext.jsx"
click node_name_game "https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/name_game/App.jsx"

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_frontend,node_dashboards,node_gamecatalog toneBlue
class node_api_routes,node_auth,node_users,node_care_links,node_routine_handler,node_routines,node_chat_handler,node_chat_sessions,node_gemini,node_other_services toneAmber
class node_recall_app,node_recall_board,node_recall_shell,node_recall_feedback,node_recall_confetti,node_bubble_app,node_color_match,node_rhythm_hook,node_name_game toneMint
class node_recall_levels,node_pairs_engine,node_recall_tracker,node_bubble_audio,node_bubble_cognition,node_bubble_voice,node_rhythm_audio,node_rhythm_voice,node_rhythm_nodes,node_rhythm_language toneRose
class node_person,node_ai_service toneIndigo
```

## Components

### Care Platform

- [Care frontend](https://github.com/kaemiii-ss/smaran/tree/main/frontend/src): `frontend/src`
- [Care dashboards](https://github.com/kaemiii-ss/smaran/tree/main/frontend/src/pages): `frontend/src/pages`
- [Games catalog](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/pages/GamesCatalog.jsx): `frontend/src/pages/GamesCatalog.jsx`

### Backend Services

- [API routes](https://github.com/kaemiii-ss/smaran/tree/main/backend/src/routes): `backend/src/routes`
- [Authentication](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [User records](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/user.model.js): `backend/src/models/user.model.js`
- [Caregiver links](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/patientCaregiver.model.js): `backend/src/models/patientCaregiver.model.js`
- [Routine handlers](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/controllers/routine.controller.js): `backend/src/controllers/routine.controller.js`
- [Routine records](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/routine.model.js): `backend/src/models/routine.model.js`
- [Chat handlers](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/controllers/gemini.controller.js): `backend/src/controllers/gemini.controller.js`
- [Chat sessions](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/models/chatbotSession.model.js): `backend/src/models/chatbotSession.model.js`
- [Gemini service](https://github.com/kaemiii-ss/smaran/blob/main/backend/src/gemini/gemini.service.js): `backend/src/gemini/gemini.service.js`
- [Other care APIs](https://github.com/kaemiii-ss/smaran/tree/main/backend/src/controllers): `backend/src/controllers`

### Cognitive Games

- [Recall game app](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/App.jsx): `frontend/src/game_5/src/App.jsx`
- [Card board](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/GameBoard.jsx): `frontend/src/game_5/src/components/GameBoard.jsx`
- [Game shell](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/GameShell.jsx): `frontend/src/game_5/src/components/GameShell.jsx`
- [Game feedback](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/FeedbackOverlay.jsx): `frontend/src/game_5/src/components/FeedbackOverlay.jsx`
- [Win celebration](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/components/ConfettiCanvas.jsx): `frontend/src/game_5/src/components/ConfettiCanvas.jsx`
- [Bubble game app](https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/App.jsx): `Games/bubble_digits_game/src/App.jsx`
- [Color number match](https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/components/games/ColorNumberMatchGame.jsx): `Games/bubble_digits_game/src/components/games/ColorNumberMatchGame.jsx`
- [Rhythm gameplay](https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx): `Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx`
- [Name game](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/name_game/App.jsx): `frontend/src/name_game/App.jsx`

### Game Mechanics

- [Level definitions](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/config/levels.js): `frontend/src/game_5/src/config/levels.js`
- [Pair deck engine](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/hooks/usePairsEngine.js): `frontend/src/game_5/src/hooks/usePairsEngine.js`
- [Progress tracker](https://github.com/kaemiii-ss/smaran/blob/main/frontend/src/game_5/src/hooks/useTracker.js): `frontend/src/game_5/src/hooks/useTracker.js`
- [Audio engine](https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/lib/audioEngine.js): `Games/bubble_digits_game/src/lib/audioEngine.js`
- [Cognitive engine](https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/lib/cognitiveEngine.js): `Games/bubble_digits_game/src/lib/cognitiveEngine.js`
- [Voice engine](https://github.com/kaemiii-ss/smaran/blob/main/Games/bubble_digits_game/src/lib/voiceEngine.js): `Games/bubble_digits_game/src/lib/voiceEngine.js`
- [Rhythm audio](https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useAudioEngine.jsx): `Games/follow_the_rhythm/src/hooks/useAudioEngine.jsx`
- [Rhythm voice](https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/hooks/useVoiceFeedback.jsx): `Games/follow_the_rhythm/src/hooks/useVoiceFeedback.jsx`
- [Rhythm nodes](https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/lib/nodes.js): `Games/follow_the_rhythm/src/lib/nodes.js`
- [Language context](https://github.com/kaemiii-ss/smaran/blob/main/Games/follow_the_rhythm/src/lib/LanguageContext.jsx): `Games/follow_the_rhythm/src/lib/LanguageContext.jsx`

### Other components

- **Patient or caregiver**
- **Gemini AI**

## Connections

- Patient or caregiver → Care frontend: uses
- Care frontend → Care dashboards: offers
- Care frontend → Games catalog: offers
- API routes → Authentication: routes auth
- Authentication → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.js`)
- Authentication → Caregiver links: creates link (evidence: `backend/src/controllers/auth.controller.js`)
- API routes → Routine handlers: routes routines (evidence: `backend/src/routes/routine.routes.js`)
- Routine handlers → Routine records: reads and writes (evidence: `backend/src/controllers/routine.controller.js`)
- API routes → Chat handlers: routes chat (evidence: `backend/src/routes/gemini.routes.js`)
- Chat handlers → Chat sessions: reads and writes (evidence: `backend/src/controllers/gemini.controller.js`)
- Chat handlers → Gemini service: requests reply (evidence: `backend/src/controllers/gemini.controller.js`)
- Gemini service → Gemini AI: generates reply (evidence: `backend/src/gemini/gemini.service.js`)
- API routes → Other care APIs: routes other APIs (evidence: `backend/src/routes/routine.routes.js`)
- Recall game app → Pair deck engine: builds deck (evidence: `frontend/src/game_5/src/App.jsx`)
- Pair deck engine → Level definitions: reads levels (evidence: `frontend/src/game_5/src/hooks/usePairsEngine.js`)
- Recall game app → Card board: renders board (evidence: `frontend/src/game_5/src/App.jsx`)
- Recall game app → Game shell: renders in shell (evidence: `frontend/src/game_5/src/App.jsx`)
- Recall game app → Progress tracker: tracks play (evidence: `frontend/src/game_5/src/App.jsx`)
- Recall game app → Game feedback: shows feedback (evidence: `frontend/src/game_5/src/App.jsx`)
- Recall game app → Win celebration: shows celebration (evidence: `frontend/src/game_5/src/App.jsx`)
- Bubble game app → Color number match: launches game (evidence: `Games/bubble_digits_game/src/App.jsx`)
- Color number match → Audio engine: uses audio
- Color number match → Cognitive engine: uses cognition
- Color number match → Voice engine: uses voice
- Rhythm gameplay → Rhythm audio: plays tones (evidence: `Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx`)
- Rhythm gameplay → Rhythm voice: speaks prompts (evidence: `Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx`)
- Rhythm gameplay → Rhythm nodes: selects nodes (evidence: `Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx`)
- Rhythm gameplay → Language context: reads language (evidence: `Games/follow_the_rhythm/src/hooks/useRhythmGame.jsx`)
- Name game → Care frontend: embedded in platform (evidence: `frontend/src/name_game/App.jsx`)
