# arthur-rmota/comunica architecture

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

- Interactive diagram: https://gitdiagram.com/arthur-rmota/comunica
- Repository: https://github.com/arthur-rmota/comunica

## Overview

ComuniCA is an offline-first augmentative and alternative communication web app. A user navigates to communication categories, cards, quick phrases, or emergency phrases; selecting a communication item can produce spoken output. Caregivers can personalize content and routines, with PIN protection on management features. The graph combines the documented capabilities with relationships visible in the excerpts and SOURCE INDEX; unsampled page and service internals are represented at their exact paths, but their unverified calls are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/arthur-rmota/comunica/blob/main/src/App.tsx) (Application routes), [`src/database/db.ts`](https://github.com/arthur-rmota/comunica/blob/main/src/database/db.ts) (IndexedDB database), [`src/pages/routine/ManageRoutineActivitiesPage.tsx`](https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/ManageRoutineActivitiesPage.tsx) (Routine activities), [`src/components/profile/PinAccessPage.tsx`](https://github.com/arthur-rmota/comunica/blob/main/src/components/profile/PinAccessPage.tsx) (PIN access screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Communication experience"]
  node_router["Application routes<br/>[App.tsx]"]
  node_home["Home and categories<br/>[HomePage.tsx]"]
  node_cards["Communication cards"]
  node_card_model["Card presentation<br/>[CardItem.tsx]"]
  node_quick["Quick phrases"]
  node_favorites["Phrase favorites"]
  node_emergency["Emergency phrases<br/>[EmergencyPage.tsx]"]
  node_speech["Speech playback<br/>[speech.ts]"]
end

subgraph group_management["Personalization and safety"]
  node_card_admin["Category and card management"]
  node_phrase_admin["Phrase management"]
  node_emergency_admin["Emergency phrase management"]
  node_profile["Profile and PIN<br/>[ProfileContext.tsx]"]
  node_pin_access["PIN access screen<br/>[PinAccessPage.tsx]"]
  node_pin_form["PIN verification form"]
end

subgraph group_routine["Routines and agenda"]
  node_routine_admin["Routine sections"]
  node_activity_admin["Routine activities"]
  node_routine_service["Routine operations<br/>[routineService.ts]"]
  node_agenda["Agenda and routine use<br/>[AgendaPage.tsx]"]
end

subgraph group_platform["Local data and foundations"]
  node_seed["Initial data and migration<br/>[seed.ts]"]
  node_db[("IndexedDB database<br/>[db.ts]")]
  node_card_service["Card data service<br/>[cardService.ts]"]
  node_category_service["Category data service<br/>[categoryService.ts]"]
  node_phrase_service["Quick phrase data service"]
  node_emergency_service["Emergency phrase data service"]
end

node_user(("Communicator or caregiver"))
node_speech_api["Web Speech API"]

node_user -->|"opens app"| node_router
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_cards
node_router -->|"routes to"| node_quick
node_router -->|"routes to"| node_emergency
node_router -->|"routes to"| node_card_admin
node_router -->|"routes to"| node_phrase_admin
node_router -->|"routes to"| node_emergency_admin
node_router -->|"routes to"| node_routine_admin
node_router -->|"routes to"| node_activity_admin
node_router -->|"routes to"| node_agenda
node_router -->|"provides context"| node_profile
node_cards -.->|"presents cards"| node_card_model
node_quick -.->|"manages favorites"| node_favorites
node_user -->|"requests speech"| node_speech
node_speech -->|"uses"| node_speech_api
node_card_admin -->|"calls"| node_card_service
node_card_admin -->|"calls"| node_category_service
node_phrase_admin -->|"calls"| node_phrase_service
node_emergency_admin -->|"calls"| node_emergency_service
node_routine_admin -->|"calls"| node_routine_service
node_activity_admin -->|"calls"| node_routine_service
node_activity_admin -->|"loads cards"| node_card_service
node_activity_admin -->|"loads phrases"| node_phrase_service
node_routine_admin -->|"requires PIN"| node_pin_access
node_activity_admin -->|"requires PIN"| node_pin_access
node_pin_access -->|"reads PIN state"| node_profile
node_pin_access -->|"renders"| node_pin_form
node_profile -.->|"uses profile hook"| node_seed
node_seed -->|"seeds and migrates"| node_db
node_card_service -->|"reads and writes"| node_db
node_category_service -->|"reads and writes"| node_db
node_phrase_service -->|"reads and writes"| node_db
node_emergency_service -->|"reads and writes"| node_db
node_routine_service -->|"reads and writes"| node_db
node_favorites -->|"reads and writes"| node_db

click node_router "https://github.com/arthur-rmota/comunica/blob/main/src/App.tsx"
click node_home "https://github.com/arthur-rmota/comunica/blob/main/src/pages/home/HomePage.tsx"
click node_cards "https://github.com/arthur-rmota/comunica/blob/main/src/pages/categories/CategoryCardsPage.tsx"
click node_card_model "https://github.com/arthur-rmota/comunica/blob/main/src/components/common/CardItem.tsx"
click node_quick "https://github.com/arthur-rmota/comunica/blob/main/src/pages/phrases/QuickPhrasesPage.tsx"
click node_favorites "https://github.com/arthur-rmota/comunica/blob/main/src/services/quickPhraseFavoriteService.ts"
click node_emergency "https://github.com/arthur-rmota/comunica/blob/main/src/pages/emergency/EmergencyPage.tsx"
click node_speech "https://github.com/arthur-rmota/comunica/blob/main/src/utils/speech.ts"
click node_card_admin "https://github.com/arthur-rmota/comunica/blob/main/src/pages/categories/ManageCategoriesPage.tsx"
click node_phrase_admin "https://github.com/arthur-rmota/comunica/blob/main/src/pages/phrases/ManageQuickPhrasesPage.tsx"
click node_emergency_admin "https://github.com/arthur-rmota/comunica/blob/main/src/pages/emergency/ManageEmergencyPhrasesPage.tsx"
click node_profile "https://github.com/arthur-rmota/comunica/blob/main/src/contexts/ProfileContext.tsx"
click node_pin_access "https://github.com/arthur-rmota/comunica/blob/main/src/components/profile/PinAccessPage.tsx"
click node_pin_form "https://github.com/arthur-rmota/comunica/blob/main/src/components/profile/PinVerificationForm.tsx"
click node_routine_admin "https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/ManageRoutinePage.tsx"
click node_activity_admin "https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/ManageRoutineActivitiesPage.tsx"
click node_routine_service "https://github.com/arthur-rmota/comunica/blob/main/src/services/routineService.ts"
click node_agenda "https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/AgendaPage.tsx"
click node_seed "https://github.com/arthur-rmota/comunica/blob/main/src/database/seed.ts"
click node_db "https://github.com/arthur-rmota/comunica/blob/main/src/database/db.ts"
click node_card_service "https://github.com/arthur-rmota/comunica/blob/main/src/services/cardService.ts"
click node_category_service "https://github.com/arthur-rmota/comunica/blob/main/src/services/categoryService.ts"
click node_phrase_service "https://github.com/arthur-rmota/comunica/blob/main/src/services/quickPhraseService.ts"
click node_emergency_service "https://github.com/arthur-rmota/comunica/blob/main/src/services/emergencyPhraseService.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_router,node_home,node_cards,node_card_model,node_quick,node_favorites,node_emergency,node_speech toneBlue
class node_card_admin,node_phrase_admin,node_emergency_admin,node_profile,node_pin_access,node_pin_form toneAmber
class node_routine_admin,node_activity_admin,node_routine_service,node_agenda,node_speech_api toneMint
class node_seed,node_db,node_card_service,node_category_service,node_phrase_service,node_emergency_service toneRose
class node_user toneIndigo
```

## Components

### Communication experience

- [Application routes](https://github.com/arthur-rmota/comunica/blob/main/src/App.tsx): `src/App.tsx`
- [Home and categories](https://github.com/arthur-rmota/comunica/blob/main/src/pages/home/HomePage.tsx): `src/pages/home/HomePage.tsx`
- [Communication cards](https://github.com/arthur-rmota/comunica/blob/main/src/pages/categories/CategoryCardsPage.tsx): `src/pages/categories/CategoryCardsPage.tsx`
- [Card presentation](https://github.com/arthur-rmota/comunica/blob/main/src/components/common/CardItem.tsx): `src/components/common/CardItem.tsx`
- [Quick phrases](https://github.com/arthur-rmota/comunica/blob/main/src/pages/phrases/QuickPhrasesPage.tsx): `src/pages/phrases/QuickPhrasesPage.tsx`
- [Phrase favorites](https://github.com/arthur-rmota/comunica/blob/main/src/services/quickPhraseFavoriteService.ts): `src/services/quickPhraseFavoriteService.ts`
- [Emergency phrases](https://github.com/arthur-rmota/comunica/blob/main/src/pages/emergency/EmergencyPage.tsx): `src/pages/emergency/EmergencyPage.tsx`
- [Speech playback](https://github.com/arthur-rmota/comunica/blob/main/src/utils/speech.ts): `src/utils/speech.ts`

### Personalization and safety

- [Category and card management](https://github.com/arthur-rmota/comunica/blob/main/src/pages/categories/ManageCategoriesPage.tsx): `src/pages/categories/ManageCategoriesPage.tsx`
- [Phrase management](https://github.com/arthur-rmota/comunica/blob/main/src/pages/phrases/ManageQuickPhrasesPage.tsx): `src/pages/phrases/ManageQuickPhrasesPage.tsx`
- [Emergency phrase management](https://github.com/arthur-rmota/comunica/blob/main/src/pages/emergency/ManageEmergencyPhrasesPage.tsx): `src/pages/emergency/ManageEmergencyPhrasesPage.tsx`
- [Profile and PIN](https://github.com/arthur-rmota/comunica/blob/main/src/contexts/ProfileContext.tsx): `src/contexts/ProfileContext.tsx`
- [PIN access screen](https://github.com/arthur-rmota/comunica/blob/main/src/components/profile/PinAccessPage.tsx): `src/components/profile/PinAccessPage.tsx`
- [PIN verification form](https://github.com/arthur-rmota/comunica/blob/main/src/components/profile/PinVerificationForm.tsx): `src/components/profile/PinVerificationForm.tsx`

### Routines and agenda

- [Routine sections](https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/ManageRoutinePage.tsx): `src/pages/routine/ManageRoutinePage.tsx`
- [Routine activities](https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/ManageRoutineActivitiesPage.tsx): `src/pages/routine/ManageRoutineActivitiesPage.tsx`
- [Routine operations](https://github.com/arthur-rmota/comunica/blob/main/src/services/routineService.ts): `src/services/routineService.ts`
- [Agenda and routine use](https://github.com/arthur-rmota/comunica/blob/main/src/pages/routine/AgendaPage.tsx): `src/pages/routine/AgendaPage.tsx`

### Local data and foundations

- [Initial data and migration](https://github.com/arthur-rmota/comunica/blob/main/src/database/seed.ts): `src/database/seed.ts`
- [IndexedDB database](https://github.com/arthur-rmota/comunica/blob/main/src/database/db.ts): `src/database/db.ts`
- [Card data service](https://github.com/arthur-rmota/comunica/blob/main/src/services/cardService.ts): `src/services/cardService.ts`
- [Category data service](https://github.com/arthur-rmota/comunica/blob/main/src/services/categoryService.ts): `src/services/categoryService.ts`
- [Quick phrase data service](https://github.com/arthur-rmota/comunica/blob/main/src/services/quickPhraseService.ts): `src/services/quickPhraseService.ts`
- [Emergency phrase data service](https://github.com/arthur-rmota/comunica/blob/main/src/services/emergencyPhraseService.ts): `src/services/emergencyPhraseService.ts`

### Other components

- **Communicator or caregiver**
- **Web Speech API**

## Connections

- Communicator or caregiver → Application routes: opens app (evidence: `README.md`)
- Application routes → Home and categories: routes to (evidence: `src/App.tsx`)
- Application routes → Communication cards: routes to (evidence: `src/App.tsx`)
- Application routes → Quick phrases: routes to (evidence: `src/App.tsx`)
- Application routes → Emergency phrases: routes to (evidence: `src/App.tsx`)
- Application routes → Category and card management: routes to (evidence: `src/App.tsx`)
- Application routes → Phrase management: routes to (evidence: `src/App.tsx`)
- Application routes → Emergency phrase management: routes to (evidence: `src/App.tsx`)
- Application routes → Routine sections: routes to (evidence: `src/App.tsx`)
- Application routes → Routine activities: routes to (evidence: `src/App.tsx`)
- Application routes → Agenda and routine use: routes to (evidence: `src/App.tsx`)
- Application routes → Profile and PIN: provides context (evidence: `src/App.tsx`)
- Communication cards → Card presentation: presents cards
- Quick phrases → Phrase favorites: manages favorites
- Communicator or caregiver → Speech playback: requests speech (evidence: `README.md`)
- Speech playback → Web Speech API: uses (evidence: `README.md`)
- Category and card management → Card data service: calls
- Category and card management → Category data service: calls (evidence: `src/pages/categories/ManageCategoriesPage.tsx`)
- Phrase management → Quick phrase data service: calls (evidence: `src/pages/phrases/ManageQuickPhrasesPage.tsx`)
- Emergency phrase management → Emergency phrase data service: calls (evidence: `src/pages/emergency/ManageEmergencyPhrasesPage.tsx`)
- Routine sections → Routine operations: calls (evidence: `src/pages/routine/ManageRoutinePage.tsx`)
- Routine activities → Routine operations: calls (evidence: `src/pages/routine/ManageRoutineActivitiesPage.tsx`)
- Routine activities → Card data service: loads cards (evidence: `src/pages/routine/ManageRoutineActivitiesPage.tsx`)
- Routine activities → Quick phrase data service: loads phrases (evidence: `src/pages/routine/ManageRoutineActivitiesPage.tsx`)
- Routine sections → PIN access screen: requires PIN (evidence: `src/pages/routine/ManageRoutinePage.tsx`)
- Routine activities → PIN access screen: requires PIN (evidence: `src/pages/routine/ManageRoutineActivitiesPage.tsx`)
- PIN access screen → Profile and PIN: reads PIN state (evidence: `src/components/profile/PinAccessPage.tsx`)
- PIN access screen → PIN verification form: renders (evidence: `src/components/profile/PinAccessPage.tsx`)
- Profile and PIN → Initial data and migration: uses profile hook
- Initial data and migration → IndexedDB database: seeds and migrates (evidence: `src/database/seed.ts`)
- Card data service → IndexedDB database: reads and writes (evidence: `src/services/cardService.ts`)
- Category data service → IndexedDB database: reads and writes (evidence: `src/services/categoryService.ts`)
- Quick phrase data service → IndexedDB database: reads and writes (evidence: `src/services/quickPhraseService.ts`)
- Emergency phrase data service → IndexedDB database: reads and writes (evidence: `src/services/emergencyPhraseService.ts`)
- Routine operations → IndexedDB database: reads and writes (evidence: `src/services/routineService.ts`)
- Phrase favorites → IndexedDB database: reads and writes (evidence: `src/services/quickPhraseFavoriteService.ts`)
