How acad-ia/frontend works
1. What this app is
- This is a client-side TanStack React application for managing study plans (planes) and subjects (asignaturas), with supporting flows for bibliography and AI-assisted content generation.
- The repository is organized as a frontend-only SPA that talks to Supabase and edge/API functions rather than hosting its own business backend.
2. Application shell and navigation
- The visual shell is centered around src/routes/__root.tsx, src/components/layout/*, and route-level layouts.
- Navigation is file-based via TanStack Router; src/routeTree.gen.ts is the generated route graph.
- The root layout provides shared UI such as the header/sidebar, while route outlets render the active page inside that shell.
3. Primary domain boundaries
- The main domain split is:
- Plans: src/routes/planes/*, src/components/planes/*, src/features/planes/*
- Subjects: src/routes/planes/$planId/asignaturas/*, src/components/asignaturas/*, src/features/asignaturas/*
- Authentication: src/components/auth/*
- This is a strong signal that the app is structured around a parent entity (plan) and child entities (asignaturas), with detail views and nested subroutes.
4. Route hierarchy and page composition
- Plans have both list and detail flows:
- list/index routes under src/routes/planes/_lista.tsx
- create flow under src/routes/planes/_lista/nuevo.tsx
- plan detail sections under src/routes/planes/$planId/_detalle/*
- Subject detail routes are nested under a plan and subject ID, with separate tabs/pages for:
- main subject view
- content (contenido)
- document (documento)
- history (historial)
- AI assistant view (iaasignatura)
- bibliography (bibliografia)
- The route structure maps almost one-to-one with domain tabs in the UI.
5. Wizard-driven creation flows
- New plans and new subjects are created through multi-step wizards rather than single forms.
- The wizard subsystem lives in src/components/*/wizard/* and src/features/*/nuevo/*.
- These flows are split into reusable steps like:
- basic data entry
- source selection / cloning
- details panel
- method/mode selection
- summary/confirmation
- This suggests a guided creation experience with branching behavior depending on whether the user is cloning, editing, or generating from AI.
6. Data access layer and server boundary
- src/data/api/* is the main boundary to the server side.
- It contains focused API modules for:
- AI
- documents
- files
- metadata
- notifications
- repositories
- plans
- subjects
- tasks
- OpenAI-related file handling
- src/data/supabase/* wraps the Supabase client, env access, and edge-function invocation.
- src/data/hooks/* exposes domain-specific React hooks over those APIs, and src/data/query/* centralizes query keys and the TanStack Query client.
7. AI-assisted and async workflows
- The presence of ai.api.ts, openaiFiles.api.ts, useAI.ts, and UI like AIProgressLoader, IAAsignaturaTab, and planes/detalle/Ia/* indicates AI is a first-class feature.
- AI is not isolated to a single screen; it appears in both plan and subject workflows, likely for drafting, improving, or validating academic content.
- tasks, notifications, and progress-related components suggest long-running operations are tracked asynchronously and surfaced in the UI.
8. Bibliography and document formatting subsystem
- The repository includes citation assets under public/csl/* and fonts under public/fonts/indivisa/*.
- That points to a document/bibliography rendering pipeline using CSL styles and localized citation data.
- Components like BibliographyItem, DocumentoSEPTab, and src/lib/asignaturaColumnParsers.ts suggest the app can parse and present structured academic/document data, not just plain CRUD records.
9. Shared UI foundation
- Most primitives come from src/components/ui/*, consistent with a shadcn/ui-style design system.
- Custom higher-level widgets such as step indicators, progress indicators, motion tabs, dialogs, and cards are layered on top.
- This separates the architectural boundary between low-level UI primitives and domain-specific screens.
10. Shared domain types and utilities
- Canonical data contracts live in src/types/* and src/data/types/domain.ts.
- Utility logic is kept outside components in src/lib/*, src/utils/*, and feature-specific helpers like file-size formatting and icon utilities.
- This helps keep route and component layers thin while centralizing domain formatting and parsing rules.
11. Static assets and application metadata
- public/manifest.json, robots.txt, index.html, and public/fonts indicate a deployable browser application with PWA-like metadata and branded typography.
- public/csl is a meaningful content asset bundle for the bibliography/document subsystem.
- src/styles.css is the global styling entry point, layered with Tailwind CSS and component-level styles.
12. Build, deployment, and runtime shape
- The app is built with Vite and managed with Bun.
- Production packaging is containerized via Dockerfile and served through nginx.conf, implying a static frontend build deployed behind Nginx.
- github/workflows/deploy.yaml and staticwebapp.config.json show the repo is prepared for automated deployment, likely to a static hosting platform or container-based static serving.
13. What to emphasize in an architecture diagram
- Draw the system as a React SPA shell with route-driven pages on top.
- Show a clear split between:
- UI/layout layer
- domain feature modules for plans and subjects
- shared data/query layer
- Supabase + edge-function backend boundary
- AI/file/document external services
- The most important flows are: user navigation → route page → feature wizard/detail screen → data hooks/api layer → Supabase/edge services → query cache/UI updates.
Main entry points: AsignaturaDetailPage.tsx Subjects · PlanEstudiosCard.tsx Plans · button.tsx UI primitives · usePlans.ts Domain hooks
Components 20
App shell
SPA bootstrap, layout, and file-based routing.
- Root app · Application entry, root route, and generated route tree.
src/main.tsx - App shell · Top-level route layout with shared navigation and outlet.
src/routes/__root.tsx - Layout · Header, sidebar, and overall page chrome.
src/components/layout/AppLayout.tsx - Route tree · Generated TanStack Router graph and page routes.
src/routeTree.gen.ts - Plan routes · List, detail, and nested plan subroutes.
src/routes/planes/_lista.tsx - Subject routes · Nested subject detail tabs under a plan.
src/routes/planes/$planId/asignaturas/$asignaturaId/index.tsx
Domain features
Plans, subjects, bibliography, and AI-assisted creation flows.
- Plans · Plan list, detail, AI, and creation flows.
src/components/planes/PlanEstudiosCard.tsx - Subjects · Subject detail pages, content editing, and wizards.
src/components/asignaturas/detalle/AsignaturaDetailPage.tsx - Bibliography · Citation UI and bibliography creation flow.
src/features/bibliografia/nueva/NuevaBibliografiaModalContainer.tsx - Plan AI · AI-assisted plan improvement and generation.
src/components/planes/detalle/Ia/ImprovementCard.tsx - Subject AI · AI-assisted subject improvement and progress UI.
src/components/asignaturas/detalle/IAAsignaturaTab.tsx - Plan wizard · Multi-step wizard for creating or cloning plans.
src/features/planes/nuevo/hooks/useNuevoPlanWizard.ts - Subject wizard · Multi-step wizard for creating or cloning subjects.
src/features/asignaturas/nueva/hooks/useNuevaAsignaturaWizard.ts
Data layer
Query, API, Supabase, and domain contracts.
- Query client · TanStack Query client and cache keys.
src/data/query/queryClient.tsx - Domain hooks · Typed hooks wrapping plans, subjects, AI, files, tasks, and notifications.
src/data/hooks/usePlans.ts - API modules · Focused API modules for plans, subjects, AI, documents, files, tasks, and metadata.
src/data/api/plans.api.ts - Supabase · Client setup, env access, and edge-function invocation.
src/data/supabase/client.ts - Domain types · Canonical plan, subject, and Supabase type definitions.
src/data/types/domain.ts
Shared UI
Reusable components, utilities, and static assets.
- UI primitives · Reusable shadcn-style components and base controls.
src/components/ui/button.tsx - Static assets · Bibliography styles, fonts, manifest, and hosting metadata.
public/csl/styles/apa.csl
Connections 23
- Root app → App shell: boots · The app entry renders the root route and route tree.
- App shell → Layout: uses · The root route composes the shared app shell.
- Root app → Route tree: loads · Generated routes power file-based navigation.
- Route tree → Plan routes: includes · Plan pages are part of the route graph.
- Route tree → Subject routes: includes · Subject tabs are nested under plan routes.
- Plan routes → Plans: renders · Plan routes mount plan list, detail, wizard, and AI screens.
- Subject routes → Subjects: renders · Subject routes mount detail tabs and editors.
- Plans → Plan wizard: creates · Plan creation uses a dedicated multi-step wizard.
- Subjects → Subject wizard: creates · Subject creation uses a dedicated multi-step wizard.
- Plans → Plan AI: assists · Plan screens include AI-driven improvement flows.
- Subjects → Subject AI: assists · Subject screens include AI-driven assistant flows.
- Subjects → Bibliography: manages · Subject detail includes bibliography management.
- Plans → Domain hooks: calls · Domain screens consume typed hooks for data access.
- Subjects → Domain hooks: calls · Subject screens consume typed hooks for data access.
- Domain hooks → API modules: wraps · Hooks are thin facades over API modules.
- API modules → Supabase: invokes · API modules call Supabase and edge functions.
- Domain hooks → Query client: caches · Hooks integrate with the shared query client.
- API modules → Domain types: uses · API modules are typed by domain contracts.
- UI primitives → Layout: builds · The shell uses shared UI primitives.
- UI primitives → Plans: supports · Plan screens are composed from shared primitives.
- UI primitives → Subjects: supports · Subject screens are composed from shared primitives.
- Static assets → Bibliography: feeds · CSL styles and fonts support bibliography rendering.
- Static assets → UI primitives: styles · Static typography and metadata support the UI layer.