# alexrguez9/deportesurjc architecture

> Architecture diagram of the GitHub repository alexrguez9/deportesurjc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexrguez9/deportesurjc
- Repository: https://github.com/alexrguez9/deportesurjc

## Overview

#### Purpose and Deployable Units
DeportesURJC is a MERN university sports-management system: users authenticate, manage profiles/wallet subscriptions, reserve facilities, and participate in internal leagues; administrators manage users, facilities, reservations, teams, and results. It runs as separate React/Vite and Node/Express services, with MongoDB Atlas persistence. Main service entry points are `frontend/src/main.jsx`, `frontend/src/App.jsx`, and `backend/server.js`.

#### Frontend Application Shell and Navigation
The React client bootstraps the application and route tree, then provides a shared layout around public, authenticated, and administrative views. Routing is centralized in `frontend/src/router/index.jsx`; common page framing is `frontend/src/views/layout/Layout.jsx`. The client targets a configurable API base URL via `frontend/src/config/env.js`, enabling local, containerized, and production backend endpoints.

#### Client State and Access Boundary
Cross-page state is partitioned into authentication, facility/reservation, and team/result contexts. `frontend/src/context/AuthContext.jsx` owns session-aware user state and access decisions; `frontend/src/context/FacilitiesAndReservationsContext.jsx` and `frontend/src/context/TeamsAndResultsContext.jsx` coordinate domain data consumed by views. This is the primary frontend-to-backend boundary: browser requests must preserve Express session cookies rather than use JWTs.

#### User, Wallet, and Fitness Workflows
Profile flows include login, account information, reservations, and subscriptions under `frontend/src/views/profile/Profile.jsx`. Fitness-room registration and subscription/payment experiences are implemented in `frontend/src/views/fitnessRooms/registration/Registration.jsx` and `frontend/src/views/fitnessRooms/paymentSubscription/PaymentSubscription.jsx`. Backend user actions and persisted user identity/wallet-related data are handled through `backend/app/routes/user.js`, `backend/app/controllers/user.js`, and `backend/app/models/User.js`.

#### Facility Reservation Domain
Facility discovery and booking are first-class workflows: users browse facilities, choose time slots, and inspect their reservations. Key UI surfaces are `frontend/src/views/facilities/Facilities.jsx` and `frontend/src/views/fitnessRooms/fitnessRoomsReservations/FitnessRoomsReservations.jsx`. The Express MVC pipeline maps route requests through `backend/app/routes/facility.js` and `backend/app/routes/reservation.js`, applies domain operations in their controllers, and persists records through `backend/app/models/facility.js` and `backend/app/models/reservation.js`.

#### Internal Leagues and Administration
Internal leagues expose teams, results, and rankings through `frontend/src/views/ligas_internas/LigasInternas.jsx`, `frontend/src/views/ligas_internas/results/Results.jsx`, and `frontend/src/views/ligas_internas/rankings/Rankings.jsx`. Their backend resource boundaries are `backend/app/routes/team.js`, `backend/app/routes/result.js`, `backend/app/models/team.js`, and `backend/app/models/result.js`. Admin-only management views begin at `frontend/src/views/admin/cover/AdminPanel.jsx` and delegate entity management to specialized facility, reservation, team, and user screens.

#### Backend Infrastructure and External Services
`backend/server.js` composes Express, database connectivity, session behavior, and route mounting. MongoDB Atlas connection setup resides in `backend/config/db.js`; MongoDB also persists sessions via Connect-Mongo. Email notification routing/configuration is represented by `backend/app/routes/mail.js` and `backend/config/mails.js`, using SendGrid credentials. Subscription-specific backend logic is isolated in `backend/app/utils/subscription.js`.

#### Delivery Topology
Dockerized local execution is defined by `docker-compose.yml`, `frontend/Dockerfile`, and `backend/Dockerfile`. Production places the static/frontend deployment on Vercel and the Node API on Render, both connecting to MongoDB Atlas; cross-origin secure cookies are required in production. GitHub Actions separates frontend and backend validation and includes Docker publishing through `.github/workflows`.

Main entry points: [`backend/server.js`](https://github.com/alexrguez9/deportesurjc/blob/main/backend/server.js) (Express server), [`frontend/src/router/index.jsx`](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/router/index.jsx) (Route tree), [`backend/app/models/User.js`](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/models/User.js) (Domain models), [`frontend/src/context/AuthContext.jsx`](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/context/AuthContext.jsx) (Session and domain state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_client_bootstrap["Client bootstrap<br/>React/Vite entry<br/>[main.jsx]"]
  node_app_shell["App shell<br/>React composition<br/>[App.jsx]"]
  node_router["Route tree<br/>React Router<br/>[index.jsx]"]
  node_layout["Shared layout<br/>view layout<br/>[Layout.jsx]"]
  node_client_state["Session and domain state<br/>React contexts<br/>[AuthContext.jsx]"]
  node_user_views["Profile and subscriptions<br/>user views<br/>[Profile.jsx]"]
  node_facility_views["Facility booking<br/>reservation views<br/>[Facilities.jsx]"]
  node_league_views["Leagues and rankings<br/>league views<br/>[LigasInternas.jsx]"]
  node_admin_views["Admin management<br/>admin views<br/>[AdminPanel.jsx]"]
  node_api_env["API endpoint config<br/>client config<br/>[env.js]"]
end

subgraph group_api["Node API"]
  node_server{{"Express server<br/>API composition<br/>[server.js]"}}
  node_user_api["User and wallet API<br/>routes + controller<br/>[user.js]"]
  node_reservation_api["Facility and reservation API<br/>routes + controllers<br/>[reservation.js]"]
  node_league_api["Team and result API<br/>resource routes<br/>[team.js]"]
  node_mail_api["Email notifications<br/>mail route<br/>[mail.js]"]
  node_subscription_logic["Subscription logic<br/>domain utility<br/>[subscription.js]"]
end

subgraph group_data["Data and services"]
  node_mongo[("MongoDB Atlas<br/>database + session store<br/>[db.js]")]
  node_domain_models["Domain models<br/>Mongoose models<br/>[User.js]"]
  node_sendgrid["SendGrid<br/>email provider<br/>[mails.js]"]
end

subgraph group_delivery["Delivery"]
  node_containers["Docker local stack<br/>container topology<br/>[docker-compose.yml]"]
  node_production["Vercel and Render<br/>production deployment"]
  node_ci["GitHub Actions<br/>validation and publishing<br/>[workflows]"]
end

node_client_bootstrap -->|"renders"| node_app_shell
node_app_shell -->|"loads"| node_router
node_router -->|"wraps views"| node_layout
node_router -->|"routes to"| node_user_views
node_router -->|"routes to"| node_facility_views
node_router -->|"routes to"| node_league_views
node_router -->|"guards and routes"| node_admin_views
node_client_state -->|"supplies session"| node_user_views
node_client_state -->|"supplies booking state"| node_facility_views
node_client_state -->|"supplies league state"| node_league_views
node_api_env -.->|"configures browser requests"| node_server
node_user_views -->|"user requests"| node_server
node_facility_views -->|"booking requests"| node_server
node_league_views -->|"league requests"| node_server
node_admin_views -->|"management requests"| node_server
node_server -->|"mounts"| node_user_api
node_server -->|"mounts"| node_reservation_api
node_server -->|"mounts"| node_league_api
node_server -->|"mounts"| node_mail_api
node_user_api -->|"uses"| node_subscription_logic
node_user_api -->|"reads and writes"| node_domain_models
node_reservation_api -->|"reads and writes"| node_domain_models
node_league_api -->|"reads and writes"| node_domain_models
node_domain_models -->|"persists in"| node_mongo
node_server -->|"stores sessions"| node_mongo
node_mail_api -->|"sends email"| node_sendgrid
node_containers -.->|"runs frontend"| node_client_bootstrap
node_containers -.->|"runs backend"| node_server
node_production -.->|"deploys frontend"| node_client_bootstrap
node_production -.->|"deploys API"| node_server
node_ci -.->|"publishes images"| node_containers

click node_client_bootstrap "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/main.jsx"
click node_app_shell "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/App.jsx"
click node_router "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/router/index.jsx"
click node_layout "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/layout/Layout.jsx"
click node_client_state "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/context/AuthContext.jsx"
click node_user_views "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/profile/Profile.jsx"
click node_facility_views "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/facilities/Facilities.jsx"
click node_league_views "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/ligas_internas/LigasInternas.jsx"
click node_admin_views "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/admin/cover/AdminPanel.jsx"
click node_api_env "https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/config/env.js"
click node_server "https://github.com/alexrguez9/deportesurjc/blob/main/backend/server.js"
click node_user_api "https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/user.js"
click node_reservation_api "https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/reservation.js"
click node_league_api "https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/team.js"
click node_mail_api "https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/mail.js"
click node_subscription_logic "https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/utils/subscription.js"
click node_mongo "https://github.com/alexrguez9/deportesurjc/blob/main/backend/config/db.js"
click node_domain_models "https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/models/User.js"
click node_sendgrid "https://github.com/alexrguez9/deportesurjc/blob/main/backend/config/mails.js"
click node_containers "https://github.com/alexrguez9/deportesurjc/blob/main/docker-compose.yml"
click node_ci "https://github.com/alexrguez9/deportesurjc/tree/main/.github/workflows"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_bootstrap,node_app_shell,node_router,node_layout,node_client_state,node_user_views,node_facility_views,node_league_views,node_admin_views,node_api_env toneBlue
class node_server,node_user_api,node_reservation_api,node_league_api,node_mail_api,node_subscription_logic toneAmber
class node_mongo,node_domain_models,node_sendgrid toneMint
class node_containers,node_production,node_ci toneRose
```

## Components

### React client

- [Client bootstrap](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/main.jsx): React/Vite entry · `frontend/src/main.jsx`
- [App shell](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/App.jsx): React composition · `frontend/src/App.jsx`
- [Route tree](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/router/index.jsx): React Router · `frontend/src/router/index.jsx`
- [Shared layout](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/layout/Layout.jsx): view layout · `frontend/src/views/layout/Layout.jsx`
- [Session and domain state](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/context/AuthContext.jsx): React contexts · Auth, reservation/facility, and team/result state. · `frontend/src/context/AuthContext.jsx`
- [Profile and subscriptions](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/profile/Profile.jsx): user views · `frontend/src/views/profile/Profile.jsx`
- [Facility booking](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/facilities/Facilities.jsx): reservation views · `frontend/src/views/facilities/Facilities.jsx`
- [Leagues and rankings](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/ligas_internas/LigasInternas.jsx): league views · `frontend/src/views/ligas_internas/LigasInternas.jsx`
- [Admin management](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/views/admin/cover/AdminPanel.jsx): admin views · `frontend/src/views/admin/cover/AdminPanel.jsx`
- [API endpoint config](https://github.com/alexrguez9/deportesurjc/blob/main/frontend/src/config/env.js): client config · Selects local, container, or production API base URL. · `frontend/src/config/env.js`

### Node API

- [Express server](https://github.com/alexrguez9/deportesurjc/blob/main/backend/server.js): API composition · Mounts routes, sessions, and database connectivity. · `backend/server.js`
- [User and wallet API](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/user.js): routes + controller · `backend/app/routes/user.js`
- [Facility and reservation API](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/reservation.js): routes + controllers · `backend/app/routes/reservation.js`
- [Team and result API](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/team.js): resource routes · `backend/app/routes/team.js`
- [Email notifications](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/routes/mail.js): mail route · `backend/app/routes/mail.js`
- [Subscription logic](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/utils/subscription.js): domain utility · `backend/app/utils/subscription.js`

### Data and services

- [MongoDB Atlas](https://github.com/alexrguez9/deportesurjc/blob/main/backend/config/db.js): database + session store · Persists application records and Connect-Mongo sessions. · `backend/config/db.js`
- [Domain models](https://github.com/alexrguez9/deportesurjc/blob/main/backend/app/models/User.js): Mongoose models · Users, facilities, reservations, teams, and results. · `backend/app/models/User.js`
- [SendGrid](https://github.com/alexrguez9/deportesurjc/blob/main/backend/config/mails.js): email provider · `backend/config/mails.js`

### Delivery

- [Docker local stack](https://github.com/alexrguez9/deportesurjc/blob/main/docker-compose.yml): container topology · `docker-compose.yml`
- **Vercel and Render**: production deployment · Static client on Vercel and Node API on Render.
- [GitHub Actions](https://github.com/alexrguez9/deportesurjc/tree/main/.github/workflows): validation and publishing · Validates both services and publishes Docker images. · `.github/workflows`

## Connections

- Client bootstrap → App shell: renders
- App shell → Route tree: loads
- Route tree → Shared layout: wraps views
- Route tree → Profile and subscriptions: routes to
- Route tree → Facility booking: routes to
- Route tree → Leagues and rankings: routes to
- Route tree → Admin management: guards and routes
- Session and domain state → Profile and subscriptions: supplies session
- Session and domain state → Facility booking: supplies booking state
- Session and domain state → Leagues and rankings: supplies league state
- API endpoint config → Express server: configures browser requests · Requests retain Express session cookies.
- Profile and subscriptions → Express server: user requests
- Facility booking → Express server: booking requests
- Leagues and rankings → Express server: league requests
- Admin management → Express server: management requests
- Express server → User and wallet API: mounts
- Express server → Facility and reservation API: mounts
- Express server → Team and result API: mounts
- Express server → Email notifications: mounts
- User and wallet API → Subscription logic: uses
- User and wallet API → Domain models: reads and writes
- Facility and reservation API → Domain models: reads and writes
- Team and result API → Domain models: reads and writes
- Domain models → MongoDB Atlas: persists in
- Express server → MongoDB Atlas: stores sessions
- Email notifications → SendGrid: sends email
- Docker local stack → Client bootstrap: runs frontend
- Docker local stack → Express server: runs backend
- Vercel and Render → Client bootstrap: deploys frontend
- Vercel and Render → Express server: deploys API
- GitHub Actions → Docker local stack: publishes images
