How mapa-de-carreras/mapa-de-carreras-frontend works
Project Type and Purpose
• This is a single‐page application (SPA) built with React, TypeScript and Vite.
• It targets the browser only (no embedded backend code here), consuming external REST APIs (see src/shared/apis).
• Docker and Docker Compose are used to spin up both development (with HMR via Vite) and production (static assets served via Nginx) environments.
File Structure Analysis
• Top level contains Dockerfiles (dev & prod), docker-compose files, Vite config, Nginx config, package.json, and static index.html.
• src/ divides into:
• index/ – bootstrap (Router, Home).
• modules/ – feature‐oriented pages (academic and users subtrees).
• shared/ – cross‐cutting utilities:
– apis/ – wrappers around remote endpoints (carreras, constantes, generics).
– services/ – auth flows (login, logout, refresh) and route definitions.
– components/ – UI primitives, layout (Navbar, Modal, Tabla), providers (AuthProvider, ThemeProvider), hooks, common libs.
– data/ & types/ – static lists & TS interfaces.
• Config files define linting, TypeScript, Vite bundling and Docker/Nginx behavior.
README Insights
• Provides commands to spin up dev (Vite) vs prod (static build + Nginx).
• Emphasizes React + TypeScript + Vite minimal template and ESLint/Prettier.
a. Main Components
• Developer Machine – runs either Vite Dev Server or builds production image.
• Vite Dev Server – HMR server on port 3000 (docker-compose.dev).
• Docker (Production) – Nginx container serving static /dist assets.
• Browser – end user interface.
• External REST APIs – authentication service, academic service, user service (hosted elsewhere).
• CI/CD (optional) – build pipeline that generates Docker image and pushes to registry.
b. Relationships & Interactions
1. Developer edits code → Vite watches & hot‐reloads in browser.
2. In production, assets are built (vite build) → bundled into /dist → served by Nginx.
3. Browser sends HTTP(S) requests to external backend endpoints via shared/apis wrappers.
4. Auth flows:
– login/logout/refresh endpoints handle tokens stored by AuthProvider.
– Protected routes (GuestRoute, ProtectRouter) guard module pages.
5. Modules import shared components, services, and types to render pages.
c. Architectural Patterns & Principles
• Feature Modules – pages and their subcomponents grouped by domain under src/modules.
• Shared Library – reusable UI components, hooks, utils, and data under src/shared.
• Provider Pattern – context providers for auth and theming.
• Atomic UI Components – base primitives under ui/ that compose higher‐level components.
• Container vs Presentational – modules/pages orchestrate data fetch via services; shared/components render UI.
d. Key Technologies
• React + TypeScript + Vite (frontend framework & bundler)
• Docker & Docker Compose (dev & prod containerization)
• Nginx (static asset server, reverse proxy)
• ESLint/Prettier (code consistency)
Final Recommendations
• Build steps: “vite build → /dist” and Dockerfile layering.
• Validate with the team that all external endpoints are represented.