ComuniTEA is organised as a feature-driven Expo application. The codebase separates domain logic into self-contained feature modules underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElthonJohan/comunitea/llms.txt
Use this file to discover all available pages before exploring further.
features/, while shared infrastructure — Supabase client, constants, Zustand stores, React contexts, and reusable components — lives at the root level. Navigation is handled entirely by Expo Router’s file-based routing, and all global runtime state is managed through a layered combination of Zustand stores (for lightweight, persisted client state) and React Context providers (for auth, child profile, timers, theming, and network status). The Supabase backend provides authentication, a PostgreSQL database, object storage for custom pictogram images, and a set of Deno-based Edge Functions for AI and TTS features.
Directory Structure
Feature Modules
Each subdirectory offeatures/ is a self-contained domain module that exposes a public API through its index.ts. Screens in app/ import only from these public surfaces — never directly from a sibling feature’s internals.
| Module | Path | What it exports and does |
|---|---|---|
| tablero | features/tablero/ | useTablero, useFrase, tablero data, and voice-frase utilities. Owns the pictogram board state: which categories are active, which pictograms are visible, and how pictogram selections flow into the sentence strip. Also exports buildMergedBoard for combining base vocabulary with custom pictograms. |
| vocabulario | features/vocabulario/ | Vocabulary definitions (Vocabulary, VocabularyData), the pictogram asset catalog, and hooks for custom pictograms (useCustomPictograms), pictogram history (usePictogramHistory), disabled pictograms (useDisabledPictograms), sentence history (useSentenceHistory), guided activities (useActivities), AI Magic Expand (useMagicExpand), AI adaptation (useAIAdaptation), and the child team (useChildTeam). The central source of truth for all pictogram content. |
| ejercicios | features/ejercicios/ | Exercise definitions and data for G2 and G3 levels. Provides hooks for tracking per-exercise completion state and session progress, consumed by the nested exercise routes. |
| perfil | features/perfil/ | Hooks for session reporting (useReport), usage statistics (useStats), and daily routine tracking (useRutinas). Feeds data to the report.tsx screen and the perfil.tsx tab. |
| tutorial | features/tutorial/ | Tutorial step state (useTutorialState, useTutorialBasicState), voice asset loaders for G1/G2 and G3 audio clips, tutorial script data, and celebration asset helpers. Drives the guided first-run tutorial experience. |
Navigation
ComuniTEA uses Expo Router file-based routing. The route hierarchy has two levels: a root Stack navigator that handles auth-gated screens, and a nested Tabs navigator for the main app experience.Root Stack (app/_layout.tsx)
The root layout wraps the entire app in all React Context providers (in order from outermost to innermost: NetworkProvider → AppThemeProvider → AuthProvider → ChildProfileProvider → EditModeProvider → TimerProvider → ParentalProvider) and then renders a <Stack> with headerShown: false. The auth guard effect runs on every navigation event:
- Unauthenticated users visiting any protected route are redirected to
/login. - Authenticated users with no voice preference are sent to
/voice-selection. - Users who have not completed onboarding are sent to
/onboarding. - Users who have not finished the tutorial for their level are sent to
/tutorial. - All other authenticated users land in the main tabs at
/(tabs)/categorias.
| Stack Screen | Route | Purpose |
|---|---|---|
index | / | Splash/entry redirect |
login | /login | Email + password authentication |
voice-selection | /voice-selection | First-run neural voice picker |
(tabs) | /(tabs)/ | Main tab navigator (see below) |
onboarding | /onboarding | Child profile creation wizard |
tutorial | /tutorial | Interactive guided tutorial |
settings | /settings | App settings (parental gate) |
ejercicios | /ejercicios | Nested exercise navigator |
category/[id] | /category/:id | Dynamic sub-category pictogram grid |
sentences | /sentences | Saved sentence history |
report | /report | Session report for caregivers |
vocabulary-manager | /vocabulary-manager | Custom pictogram CRUD |
activity-editor | /activity-editor | Create / edit guided activities |
activity-run | /activity-run | Run a guided activity |
game | /game | Gamified pictogram matching mode |
team-manager | /team-manager | Multi-role caregiver/therapist team |
Tabs Navigator (app/(tabs)/_layout.tsx)
The tabs layout uses @react-navigation/bottom-tabs via Expo Router’s <Tabs> component. The active tint colour, tab bar background, and indicator dot colour are all driven by useTableroTheme() — a hook that reads from appThemeStore so the palette is consistent with the user’s chosen accent theme.
| Tab | Screen | Label |
|---|---|---|
| Tablero | (tabs)/tablero | Tablero |
| Ejercicios | (tabs)/ejercicios | Ejercicios |
| Perfil | (tabs)/perfil | Perfil |
(tabs)/index and (tabs)/categorias are registered as screens but have href: null, meaning they are accessible programmatically but do not appear as visible tab bar items. categorias is the default initial route in the tab navigator.State Management
ComuniTEA uses Zustand for all global client-side state that must survive across screen navigations and needs optional persistence toAsyncStorage. Each store is focused on a single concern and accessed via a dedicated hook.
| Store | File | Responsibility |
|---|---|---|
useSettingsStore | stores/settingsStore.ts | Persists the user’s voice profile selection (femenina | masculina). Reads/writes to AsyncStorage via a legacy-compatible adapter. |
useVocabularySentenceStore | stores/vocabularySentenceStore.ts | Holds the in-flight sentence strip state: the ordered array of VocabularyItem objects the child has tapped. Provides addToSentence, removeFromSentence, and clearSentence actions. |
useG2ProgressStore | stores/g2ProgressStore.ts | Tracks G2 exercise completion state, registered emotional responses, and assistance records across sessions. |
useG3ProgressStore | stores/g3ProgressStore.ts | Tracks G3 exercise and level completion state. |
useRutinasProgressStore | stores/rutinasProgressStore.ts | Tracks daily routine (rutinas) exercise completion state. |
useAppThemeStore | stores/appThemeStore.ts | Persists the selected accent palette (ThemeColor). Defaults to 'sage'. Consumed by AppThemeProvider and useTableroTheme. |
app/_layout.tsx:
AuthContext— Supabase auth session and user profileChildProfileContext— Active child profile data and levelEditModeContext— Parental gate lock/unlock stateTimerProvider— Visual timer state (shared across tablero and activity screens)ParentalContext— PIN-based parental settings gateNetworkContext— Online/offline connectivity status (powersNetworkBanner)AppThemeContext— Current resolved theme colours, fed fromappThemeStore
Backend: Supabase
The Supabase project (project_id = "comuniteav0") provides four backend services:
Authentication
Email/password auth via@supabase/supabase-js. Sessions are persisted to the device using expo-secure-store through the SecureStoreAdapter in lib/supabase.ts. Token auto-refresh is enabled with a 1-hour JWT expiry.
PostgreSQL Database
The schema is defined across migrations insupabase/migrations/. Core tables include:
usage_stats— session start/end events and pictogram interaction eventschild_profiles— child name, birth date, level (G1/G2/G3), and onboarding statecustom_pictograms— user-created pictogram records with Storage referencessentence_log— timestamped sentence strip history with TTL cleanupparental_settings— PIN hash and sensory configuration per usergame_sublevel_progress— per-child game sub-level stateguided_activities— caregiver-created activity templates and runs
Storage
A Supabase Storage bucket holds custom pictogram images uploaded by caregivers viaexpo-image-picker. Storage policies are managed in phase0_fix_storage_policies.sql. The vocabulary-manager screen handles uploads and links records to the custom_pictograms table.
Edge Functions
Four Deno-based Edge Functions are deployed undersupabase/functions/:
| Function | Trigger | What it does |
|---|---|---|
ai-expand | G3 tablero “Magic Expand” button | Accepts pictogram label array + vocabulary level + time of day; calls OpenAI to return a natural first-person Spanish sentence adapted to the child’s level (BASICO: 3–6 words, INTERMEDIO: 5–10 words, AVANZADO: up to 15 words) |
ai-insights | Caregiver report generation | Analyses session usage data and returns AI-generated suggestions for vocabulary gaps and therapeutic focus areas |
elevenlabs-tts | On-demand TTS synthesis | Calls the ElevenLabs API to synthesise speech for custom utterances not covered by bundled MP3 assets; requires ELEVENLABS_API_KEY secret |
delete-user-data | Account deletion flow | Cascades deletion of all user-owned rows and storage objects in compliance with data privacy requirements |
Audio System
ComuniTEA uses a three-tier audio fallback chain:assets/audio/tutorial-g1-g2/ and assets/audio/tutorial-g3/ — each with both voice variants. Audio playback throughout the app uses expo-audio configured with playsInSilentMode: true and interruptionMode: 'mixWithOthers' so pictogram sounds play even when the device is muted or other audio is active.
TypeScript Path Aliases
Thetsconfig.json defines four path aliases to keep import statements clean across the codebase:
Tablero Feature
Communication board internals: pictogram grid, sentence strip, voice playback, and AI Magic Expand.
Exercises & Reports
Exercise structure, game mode sub-levels, and caregiver report generation.
Profile & Onboarding
Child profile setup, user group assignment, and the first-run onboarding flow.
Supabase Reference
Database schema tables, storage policies, and Edge Function API contracts.