The frontend is a Next.js 16 / React 19 / TypeScript 5 application styled with Tailwind CSS 4 and using Recharts 3 for analytics charts. It follows a strict feature-based architecture: every product feature lives in its own folder underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Andr21Da16/UNITRU-ACADEMIC/llms.txt
Use this file to discover all available pages before exploring further.
features/, owning its components and types. The single shared infrastructure piece is the WebSocket client in infrastructure/websocket/, which is the only place in the entire frontend that knows the backend exists.
Feature Directory Structure
Feature Responsibilities
authentication/
Login form (
LoginForm) and the real-time extraction progress screen (AuthenticationProgress). The progress screen groups all backend events into four named stages and shows the current step label.dashboard/
DashboardLayout holds the full post-auth shell: a collapsible sidebar (SidebarNav), a header with student name and CSV export button, and the DashboardTabs router that renders the active feature view.grades/
GradeCards renders one card per enrolled course. Each card shows unit grades U1–U6, sustentación, NP, partial average, and — when predictions are available — the grade combinations needed to pass.attendance/
AttendanceList displays a row per course with total sessions, attended count, absence count, percentage bar, and a prominent “EN RIESGO” badge when is_at_risk is true.schedule/
ScheduleGrid renders the weekly timetable derived from attendance records. Slots show course name, teacher, group, and classroom when available.schedule_optimizer/
OptimizerView shows up to three conflict-free schedule options returned by the backend optimizer, each with a numeric score and a full session-by-session breakdown.record/
RecordTable renders the full historical course list grouped by period, enriched with the current period’s partial averages from the grades module (shown in italics, since final grades are not yet published).analytics/
AnalyticsView uses Recharts to render period-by-period pass rate and weighted average charts, plus a summary table of totals and retried courses.profile/
ProfileCard displays all personal data from the SUV: full name, enrollment number, faculty, school, emails, phone, curriculum, and the student photo (embedded as a data URL).landing/
HeroSection is the pre-authentication welcome screen. It presents the application value proposition and routes the user to the login form.home/
HomeView is the first tab shown after a successful extraction. It provides a summary of the most relevant data: grades, attendance alerts, and upcoming schedule.error/
ErrorScreen displays the user-facing error message delivered by the backend and offers a “Retry” button that resets the app to the login view.WebSocket Client
infrastructure/websocket/websocket_client.ts is the only file that communicates with the backend. The rest of the frontend treats it as a black box.
WebSocketCallbacks Interface
| Callback | When it fires |
|---|---|
onEvent | Every backend progress event except dashboard_ready and error |
onDashboardReport | When event === "dashboard_ready" — the fully typed DashboardReport payload |
onError | When event === "error", when the WebSocket itself errors, or when JSON parsing fails |
onClose | When the WebSocket closes for any reason |
connectAndFetch
connectAndFetch returns a cleanup function — page.tsx can call it to close the WebSocket if the user navigates away before extraction completes.
Configuration
ws://localhost:8000/ws.
Application State Machine
app/page.tsx is the top-level state machine. It manages a single AppView discriminated union and renders the matching feature:
"login" — Credentials form
LoginForm is displayed. On submit, connectAndFetch is called and the view immediately transitions to "loading"."loading" — Extraction in progress
AuthenticationProgress is displayed. onEvent callbacks accumulate progress steps; each one is added to the visible step list. The current event label is shown as a subtitle under the active group."done" — Dashboard
Triggered by
onDashboardReport. The full DashboardReport is stored in state and DashboardLayout is rendered. No further WebSocket communication occurs.Authentication Progress UI
AuthenticationProgress groups all backend events into four labelled stages displayed as a vertical stepper:
| Stage | Backend events included |
|---|---|
| Autenticando | opening_suv, loading_login, downloading_captcha, solving_captcha, submitting_login, selecting_student, authentication_success |
| Perfil y matrícula | extracting_profile, profile_extraction_success/failed, extracting_record, record_extraction_success/failed, extracting_enrollment, enrollment_extraction_success/failed |
| Notas y asistencia | extracting_attendance, attendance_extraction_success/failed, extracting_grades, extracting_academic_info, extracting_courses, grade_extraction_success, optimizing_schedule, schedule_optimized/failed |
| Dashboard listo | dashboard_ready |
EVENT_LABELS as a subtitle.
Key Types
AuthProgressEvent
The complete union of all event strings that can arrive from the backend:
WebSocketMessage
The envelope type for every raw message received from the backend:
EVENT_LABELS
A Record<string, string> map from event name to its Spanish display label, used by AuthenticationProgress to render human-readable subtitles:
DashboardReport
The top-level payload delivered by onDashboardReport. It is the TypeScript mirror of the DashboardReportDto serialized by the backend’s WebSocketHandler._serialize() method:
Fields marked
| null correspond to non-fatal extractors in the backend. The frontend always checks for null before rendering these sections and shows a graceful “not available” message when the data is absent.Dashboard Layout and Navigation
DashboardLayout renders a persistent two-column shell:
- Left:
SidebarNav— a vertical list of tab links. On mobile it is an off-canvas drawer toggled by a hamburger button. Includes the student’s name, an attention badge when any course is at attendance risk, and a “Nueva consulta” reset button. - Right: a scrollable main area containing the
DashboardHeader(student metadata), the CSV export button, and theDashboardTabscontent pane.
DashboardTabs receives the active tab name and the full DashboardReport, then renders the matching feature component. Tab routing is pure React state — there is no Next.js router involvement after the initial page load.
exportGradesCsv(gradeReport, studentName), which builds a comma-separated file in memory and triggers a browser download — no server round-trip.