How tefosc/mi-tesis-v1 works
1. System shape
- AcademIA is a mobile-first React Native app for UNC exam preparation.
- The architecture is centered on a client app that orchestrates learning flows, backed by Supabase/PostgreSQL for persistent data and Anthropic Claude for personalized tutor messages and study-plan generation.
2. Application shell
- App.js wires the global providers and root navigation.
- The shell is built around two cross-cutting contexts: AuthContext for session/user state and ThemeContext for design tokens and theme helpers.
- AppNavigator acts as the top-level gate: authenticated vs unauthenticated flows, with an animated splash/transition layer.
3. Navigation boundaries
- Navigation is split into:
- Auth stack for login/register/forgot password.
- Bottom-tab app for the main product areas: Home, Practice, Exams, Progress, Profile.
- Nested stacks per feature, so each module owns its own internal screen flow.
- This makes the UI architecture feature-based rather than screen-by-screen.
4. Core user journeys
- The main app paths are:
- Simulacros: exam listing → detail → timed take-exam → results.
- Práctica rápida: configurable practice session → results.
- Home: summary of progress, target career, countdown, and Markov-based intake gauge.
- Progress: accumulated stats and radar visualization.
- Profile: account, avatar, notification settings, and app info.
- These journeys all feed back into shared learning state.
5. Learning engine boundary
- The key domain logic lives in src/services/markovEngine.js.
- This module is intentionally pure: it computes states, transition matrices, and suggested progression without direct I/O.
- markovService.js wraps that engine with persistence to Supabase, so the architecture cleanly separates calculation from storage.
6. Markov-driven adaptation flow
- After an exam or practice session:
- answers are recorded,
- session performance is processed,
- the user-topic Markov state is updated,
- transition history is stored,
- career affinity is recalculated,
- downstream UI surfaces are refreshed.
- The learning state moves through four domain states: novato → aprendiendo → competente → experto.
7. Exam and practice subsystem
- examService.js manages the exam bank, sessions, answers, and results.
- The exam UI is built from specialized components like question cards, timers, navigation grids, result summaries, topic breakdowns, and grace-period overlays.
- Practice has a separate but related flow, allowing shorter sessions with different configuration and scoring behavior.
- These two subsystems share domain entities but differ in session semantics and UX.
8. AI and recommendation services
- tutorMessageService.js generates the post-session tutor message using Claude API.
- supabase/functions/generate-study-plan provides server-side generation for study plans, keeping AI-related orchestration out of the mobile client.
- reviewNotificationService.js turns learning state into a daily review reminder, so recommendations are not just visual but operational.
9. Backend data model
- Supabase is the system of record for:
- exam content: modules, topics, exams, questions, periods,
- user profile and exam date,
- exam/practice session history,
- Markov topic states and transition history,
- career predictions and their historical series,
- AI-generated study plans,
- milestone tracking.
- This schema is what binds the learning model, UI dashboards, and longitudinal thesis analysis together.
10. Local state, caching, and persistence
- AsyncStorage is used for session persistence, preferences, and lightweight cached state.
- cacheService.js adds a SWR-style in-memory cache with TTL to reduce repeated reads and keep screens responsive.
- This means the app uses a hybrid state model: local cache for immediate UX, Supabase for durable truth.
11. Notification, milestone, and celebration layer
- expo-notifications handles daily reminder scheduling.
- milestoneService.js detects learning milestones, which trigger celebration experiences.
- The celebration subsystem has its own overlay and particle components, so feedback is a separate presentation layer rather than embedded in feature screens.
12. Presentation system and shared UI
- Components are organized by domain: common, exam, home, progress, practice, tutor, celebration, notifications.
- theme/ provides colors, spacing, typography, and affinity zones used consistently across the app.
- This shared UI layer is important because many screens are variations of the same learning dashboard vocabulary: cards, gauges, chips, metrics, and overlays.
13. Tooling and data import pipeline
- supabase/migrations defines the backend schema evolution and RLS-related fixes.
- src/scripts/processExamData.js and root scripts/import-exam.js support importing the exam bank.
- Validation scripts in /scripts verify scoring, countdown logic, tutor behavior, and schema consistency, showing that data correctness is treated as part of the architecture.
14. Repo structure as architecture documentation
- The .planning/ tree is not runtime code, but it is a major architectural artifact: it captures roadmap phases, feature specs, validation, UAT, and debugging history.
- For a diagram, you can treat it as the project’s design and traceability layer, adjacent to the production app and backend.
15. High-level data flow to diagram
- User interaction starts in the React Native screens.
- Screen actions call feature services.
- Services read/write Supabase and update local cache.
- Session outcomes feed the Markov engine and career predictions.
- AI services generate tutor feedback and study plans.
- Notifications and celebrations close the loop by reinforcing the next learning action.
Main entry points: examService.js ExamSvc · TabNavigator.js Tabs · markovService.js MarkovSvc · StackNavigators.js Stacks
Components 28
App Shell
Root providers, navigation, and feature boundaries in the mobile client.
- App.js · Wires global providers and launches the navigation shell.
App.js - Auth · Holds session and user state across the app.
src/contexts/AuthContext.js - Theme · Provides tokens and theme helpers for consistent presentation.
src/contexts/ThemeContext.js - AppNav · Top-level gate between authenticated and unauthenticated flows.
src/navigation/AppNavigator.js - Stacks · Feature-owned stack navigation for auth and nested journeys.
src/navigation/StackNavigators.js - Tabs · Bottom-tab shell for the main product areas.
src/navigation/TabNavigator.js - Home · Summary dashboard for progress, target career, and intake gauge.
src/screens/home/HomeScreen.js - Exams · Exam listing and entry point to the timed exam flow.
src/screens/exam/ExamsScreen.js - Practice · Configurable rapid-practice entry and session start screen.
src/screens/practice/PracticeScreen.js - Progress · Longitudinal stats and radar visualization for learning progress.
src/screens/progress/ProgressScreen.js - Profile · Account, avatar, notifications, and app information screen.
src/screens/profile/ProfileScreen.js
Learning Core
Domain services that compute adaptation, sessions, milestones, and recommendations.
- ExamSvc · Manages exam bank, sessions, answers, and results.
src/services/examService.js - Markov · Pure state and transition logic for learning progression.
src/services/markovEngine.js - MarkovSvc · Wraps Markov calculations with Supabase persistence.
src/services/markovService.js - Tutor AI · Generates post-session tutor messages with Claude.
src/services/tutorMessageService.js - Milestones · Detects learning milestones and celebration triggers.
src/services/milestoneService.js - Review Reminders · Turns learning state into daily review notifications.
src/services/reviewNotificationService.js - Cache · In-memory TTL cache for responsive reads and SWR-style reuse.
src/services/cacheService.js
UI Domain
Shared presentation components organized by product area.
- Cards · Common card and metric vocabulary used across dashboards.
src/components/common/AppCard.js - Exam UI · Question cards, timers, navigation grid, results, and breakdowns.
src/components/exam/QuestionCard.js - Home UI · Home-specific chips, selectors, and countdown presentation.
src/components/home/HomeCompactHeader.js - Progress UI · Progress dashboard visualizations including the radar card.
src/components/progress/RadarCard.js - Celebration UI · Celebration overlay and particles for milestone feedback.
src/components/celebration/CelebrationOverlay.js
Backend & Ops
Supabase schema, edge functions, scripts, and planning artifacts.
- Supabase · Client connection setup for the backend system of record.
src/config/supabase.js - Study Plan Fn · Server-side AI orchestration for generating study plans.
supabase/functions/generate-study-plan/index.ts - Migrations · Supabase schema, RLS fixes, and seeded exam data.
supabase/migrations/01-foundation.sql - Import Exam · Loads and processes exam bank content into the data model.
scripts/import-exam.js - Planning · Roadmaps, validation notes, research, and architectural history.
.planning/PROJECT.md
Connections 36
- App.js → Auth: provides · The root app mounts authentication state.
- App.js → Theme: provides · The root app mounts theme state.
- App.js → AppNav: boots · App.js starts the navigation shell.
- AppNav → Stacks: routes · App-level gating delegates to stack flows.
- AppNav → Tabs: routes · Authenticated users enter the tabbed product shell.
- Stacks → Home: contains · Feature stacks host screen flows for product areas.
- Stacks → Exams: contains · Exam flow screens live inside nested stacks.
- Stacks → Practice: contains · Practice flow screens live inside nested stacks.
- Tabs → Home: opens · Home is one of the primary tab destinations.
- Tabs → Exams: opens · Exams is one of the primary tab destinations.
- Tabs → Practice: opens · Practice is one of the primary tab destinations.
- Tabs → Progress: opens · Progress is one of the primary tab destinations.
- Tabs → Profile: opens · Profile is one of the primary tab destinations.
- Exams → ExamSvc: uses · Exam screens orchestrate listing, attempts, and results.
- Practice → ExamSvc: uses · Practice reuses the session and scoring domain.
- ExamSvc → MarkovSvc: updates · Session outcomes update adaptive learning state.
- MarkovSvc → Markov: computes · Persistence layer delegates calculation to the pure engine.
- MarkovSvc → Supabase: persists · Adaptive state is stored in Supabase.
- ExamSvc → Supabase: persists · Questions, sessions, and results are read and written in Supabase.
- MarkovSvc → Cache: caches · Recent reads can be served through the hybrid cache.
- ExamSvc → Cache: caches · Exam data and session state benefit from local caching.
- ExamSvc → Tutor AI: triggers · Completed sessions feed tutor message generation.
- ExamSvc → Milestones: triggers · Performance events are checked for milestones.
- Milestones → Celebration UI: surfaces · Milestones drive celebration overlays in the UI.
- MarkovSvc → Review Reminders: informs · Learning state drives review reminder logic.
- Review Reminders → Profile: configures · Notification settings are managed from profile.
- Home → Home UI: renders · Home uses shared feature-specific presentation components.
- Progress → Progress UI: renders · Progress visualization is built from dedicated components.
- Exams → Exam UI: renders · Exam and result flows use specialized exam UI.
- Practice → Cards: renders · Practice and dashboard surfaces reuse shared card vocabulary.
- Study Plan Fn → Supabase: integrates · The edge function complements the mobile client backend.
- Migrations → Supabase: defines · Schema evolution shapes the client data contract.
- Import Exam → Migrations: loads · Import pipeline depends on the schema and seed structure.
- Planning → Migrations: documents · Planning artifacts capture schema and product evolution.
- Planning → Markov: documents · Design notes and validation history describe the learning model.
- Planning → ExamSvc: documents · The planning layer traces exam-flow decisions and fixes.