How leydid/fitmanagefront works
Project type and purpose
• This is a React single‑page application (SPA) built with Vite.
• It provides two main user experiences: an administrator console and a client dashboard, each with its own layout, menu, and pages.
• It communicates with a separate backend via a collection of “Api” modules under src/api (e.g. LoginApi.js, PagosApi.js, ClienteApi.js).
File structure
• Top‑level build/dev:
• vite.config.js (+ timestamped mjs)
• index.html
• package.json / package-lock.json
• Public assets: /public
• Source code under /src:
• App entry (main.jsx, index.css, App.jsx, App.css)
• Context providers (AuthContext.jsx, ModalContext.jsx)
• API service layer (/api/*.js)
• UI components (/components) with further subdivisions for “administrador” and “cliente”
• A route guard component (RutaProtegida.jsx)
• No backend code here—calls out to external services.
Key insights from the README
• Built with Vite for blazing‑fast HMR and build speeds.
• Uses React (via @vitejs/plugin-react) and ESLint.
• Minimal template with plugin hooks; all project‑specific work lives in /src.
Main components and their relationships
a. Vite Dev Server / Build Process
• Serves index.html + JS/CSS bundles to the browser
• Transpiles and hot‑reloads React code
b. Browser / Client Runtime
• Loads React app into a root DOM element
• Executes all rendering and API calls
c. React Application
• App.jsx – wraps children with AuthContext & ModalContext
• Router layer – uses RutaProtegida to guard admin and client routes
• Layout components – AdminLayout, ClienteLayout each render menus + nested pages
• Pages – e.g. Clientes.jsx, Pagos.jsx, ActualizarInfo.jsx
• Reusable components – Button, Modal, Header, etc.
d. Context Providers
• AuthContext – holds authentication state, tokens
• ModalContext – controls global modal visibility/content
e. API Service Layer
• ClienteApi, LoginApi, ForgotPasswordApi, CrearContraseñaApi, MembresiaApi, PagosApi
• Each exports functions that perform fetch/axios calls to the backend
f. External Backend Services (not in repo)
• Authentication endpoints
• Client data / profile endpoints
• Membership, payments, password‑reset endpoints
Architectural patterns / design principles
• Separation of concerns: UI, state management (Context), API calls
• Directory‑per‑feature pattern inside components (e.g. /components/administrador/pages)
• Protected vs. unprotected routes via a higher‑order component (RutaProtegida)
• Centralized API service layer for consistency and ease of testing