How andresbrav/pg-frontend-ts- works
1. This is a Vite + React + TypeScript single-page client application. The runtime entry points are src/main.tsx and src/App.tsx, with Vite handling dev server, HMR, and production bundling.
2. The app is organized around two major user journeys: account access and the game/training experience. The src/pages/users area contains Login.tsx, SignUp.tsx, and avatar selection, while src/pages/Games contains the learning activities and presentation/dashboard screens.
3. Authentication is a distinct subsystem. src/Context/TokenContext.tsx and TokenProvider.tsx manage access-token state, src/Services/authService.ts centralizes auth logic, and useAuthRedirect.ts / useCerrarSesion.ts provide login gating and logout behavior.
4. Backend integration is abstracted behind API modules rather than embedded in pages. src/api/usuarioApi.ts and src/api/notificacionApi.ts are the main client boundaries for user and notification data, suggesting the UI talks to an external backend service for persisted state and alerts.
5. The game area is split into two levels with separate exercise sets: Level1 and Nivel2. Each level has its own exercise pages, result-checking modules (VerificarResultado.ts, VerificarResultadoPseudo.ts), and supporting type/data files (typesLevel1.ts, widgetsDataLevel1.ts, ejercicios.ts).
6. Each game level also has responsive UI variants for desktop and mobile. The DesignLaptop and DesignPhone folders under each level indicate the same exercise logic is rendered through device-specific presentation components, likely chosen through screen-size detection.
7. Presentation and onboarding for the game are separated from the exercises themselves. src/pages/Games/Presentation contains the dashboard plus modal-based explanations (Dashboard.tsx, ExplicationModal.tsx, ModalInf1.tsx, ModalInf2.tsx), which likely serve as the entry screen before users enter exercises.
8. Responsive behavior is handled as a cross-cutting concern. useVerificarTamañoPantalla.ts appears to decide which device-specific component tree to show, keeping the exercise logic independent from layout selection.
9. Styling is heavily domain-scoped rather than global. CSS is partitioned into background, dashboard, games, modals, sweet alerts, and user/profile styles under src/assets/styles, which suggests the visual system is organized by feature area and screen type.
10. Static assets support the UI and avatar/game visuals. The src/assets/avatares and src/assets/filesSvg directories imply iconography and avatar-based personalization are part of the user-facing flow.
11. The repo is front-end only in this tree: there is no local server, database layer, or routing backend code shown. Any persisted auth, user data, or notifications are expected to come from the external API layer through the service modules.
12. For an architecture diagram, the clearest boundaries are: app bootstrap, auth/token management, API integration, game presentation layer, level/exercise logic, and responsive view variants. The main data flow is user interaction -> page/component state -> validation or API call -> token/user/notification state update -> navigation or feedback modal.
Main entry points: App.tsx App · Level1 Level 1 · Nivel2 Level 2 · Login.tsx Login
Components 19
Bootstrap
Vite entry and app shell
Access
Token state, auth flows, and user entry
- Token state · Access-token state shared across the app
src/Context/TokenContext.tsx - Token provider · Context provider wiring token state into the tree
src/Context/TokenProvider.tsx - Auth service · Centralized authentication logic
src/Services/authService.ts - Login · User sign-in screen
src/pages/users/Login.tsx - Sign up · User registration screen
src/pages/users/SignUp.tsx - Avatars · Avatar selection and profile options
src/pages/users/avatars.ts - User API · Backend boundary for user data and profile operations
src/api/usuarioApi.ts - Notify API · Backend boundary for notifications and alerts
src/api/notificacionApi.ts - Auth guard · Login gating and protected navigation
src/hooks/useAuthRedirect.ts - Logout hook · Logout behavior and session clearing
src/hooks/useCerrarSesion.ts
Game flows
Presentation and level exercises
- Presentation · Dashboard and modal-based onboarding for the game area
src/pages/Games/Presentation/Dashboard.tsx - Intro modal · Primary explanation dialog for the game flow
src/pages/Games/Presentation/ExplicationModal.tsx - Level 1 · First exercise track with desktop and phone variants
src/pages/Games/Level1 - Level 2 · Second exercise track with desktop and phone variants
src/pages/Games/Nivel2
Shared UI
Responsive selection, data, and assets
- Screen hook · Responsive breakpoint selection for device-specific trees
src/hooks/useVerificarTamañoPantalla.ts - Exercises data · Common exercise content used by the game flows
src/data/ejercicios.ts - Styles · Feature-scoped styling for users, dashboard, games, modals, and alerts
src/assets/styles
Connections 24
- main → App: boots · Mounts the application shell
- App → Token provider: wraps · Provides token context to the routed UI
- Token provider → Token state: supplies · Implements shared token state
- App → Auth guard: guards · Protects authenticated journeys
- App → Login: routes to · Entry point for sign-in
- App → Sign up: routes to · Entry point for registration
- Login → Auth service: authenticates · Uses centralized auth logic
- Sign up → User API: creates user · Persists new user data through backend API
- Login → User API: loads user · Fetches account-related backend data
- Sign up → Avatars: chooses · Includes avatar selection in onboarding
- Auth service → Token state: updates · Stores and clears access token state
- Logout hook → Token state: clears · Ends the active session
- Presentation → Intro modal: opens · Shows onboarding and explanations before play
- Presentation → Level 1: enters · Navigates into the first exercise track
- Presentation → Level 2: enters · Navigates into the second exercise track
- Level 1 → Screen hook: adapts · Selects mobile or desktop presentation
- Level 2 → Screen hook: adapts · Selects mobile or desktop presentation
- Level 1 → Exercises data: uses · Consumes shared exercise content
- Level 2 → Exercises data: uses · Consumes shared exercise content
- Level 1 → Styles: styled by · Uses scoped game and modal CSS
- Level 2 → Styles: styled by · Uses scoped game and modal CSS
- Login → Notify API: alerts · Can surface notification-backed feedback
- Level 1 → Notify API: reports · May write progress or feedback notifications
- Level 2 → Notify API: reports · May write progress or feedback notifications