GymSys follows a two-tier architecture: a React + Vite single-page application runs in the browser and communicates exclusively with a backend REST API over HTTP. The frontend never touches a database directly — all persistence is handled by the API server running atDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Hansel-Pan/sistema-de-informacion-web-para-un-gimnasio/llms.txt
Use this file to discover all available pages before exploring further.
http://localhost:3001/api. The services/api.js module acts as the sole bridge between UI components and the network layer, keeping data-fetching logic out of React components and in one auditable place.
Frontend (React + Vite)
Entry point
main.jsx bootstraps the application by mounting <App /> inside React’s StrictMode, which enables additional runtime warnings during development.
Routing (App.jsx)
App.jsx wraps the entire application in a BrowserRouter and defines all client-side routes. A persistent <Navbar /> sidebar sits outside the <Routes> tree so it renders on every page.
| Path | Component | Purpose |
|---|---|---|
/ | Inicio | Dashboard — stats overview |
/clientes | Clientes | Client list |
/clientes/nuevo | ClienteForm | New client form |
/clientes/editar/:id | ClienteForm | Edit existing client |
/pagos | Pagos | Payment list and new payment form |
/acceso | Acceso | Entry / exit control and occupancy |
/reportes | Reportes | Reports — client list and occupancy |
Navbar component
Navbar.jsx renders a sidebar using an array of link definitions. Each item is rendered as a React Router NavLink. The end prop on the root path (/) prevents it from matching as active on every page.
API Service Layer (services/api.js)
All network requests originate fromservices/api.js. Nothing else in the codebase calls fetch directly, which means the backend base URL and request defaults live in exactly one file.
Base URL and shared helper
peticion() is not exported — it is an internal helper used by every public API object. It:
- Prepends the base URL to the path fragment.
- Sets
Content-Type: application/jsonon every request. - Parses the JSON response body.
- Throws a descriptive
Errorwhen the HTTP status is not in the 2xx range.
clientesApi
Handles all CRUD operations for gym members.pagosApi
Records and retrieves payment transactions.accesoApi
Controls gym entry and exit events and exposes live occupancy data.Data Flow
Every interaction in GymSys follows the same unidirectional path:- A React component mounts or an event fires (e.g., a form submission or a button click).
- The component calls the relevant method on one of the exported API objects (
clientesApi,pagosApi, oraccesoApi). - That method delegates to
peticion(), which callsfetch()against the REST endpoint. - The JSON response is returned as a resolved Promise value.
- The component stores the result in local state (typically via
useState+useEffect), triggering a re-render.
Component → endpoint reference
| Component | API Method | HTTP Method | Endpoint |
|---|---|---|---|
| Clientes | clientesApi.listar() | GET | /api/clientes |
| ClienteForm | clientesApi.crear() | POST | /api/clientes |
| ClienteForm | clientesApi.actualizar() | PUT | /api/clientes/:id |
| ClienteForm | clientesApi.obtener() | GET | /api/clientes/:id |
| Clientes | clientesApi.eliminar() | DELETE | /api/clientes/:id |
| Pagos | pagosApi.listar() | GET | /api/pagos |
| Pagos | pagosApi.crear() | POST | /api/pagos |
| Acceso | accesoApi.entrada() | POST | /api/acceso/entrada |
| Acceso | accesoApi.salida() | POST | /api/acceso/salida |
| Acceso | accesoApi.ocupacion() | GET | /api/acceso/ocupacion |
| Acceso | accesoApi.historial() | GET | /api/acceso/historial/:cliente_id |
| Reportes | accesoApi.ocupacion() | GET | /api/acceso/ocupacion |