# michat-arch/proyecto-final-pweb architecture

> Architecture diagram of the GitHub repository michat-arch/proyecto-final-pweb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/michat-arch/proyecto-final-pweb
- Repository: https://github.com/michat-arch/proyecto-final-pweb

## Overview

This repository is an early-stage storefront with implemented account registration, login, and protected profile handling. The main workflow is a user submitting a browser form, the shared API helper sending the request, and the backend validating credentials or creating an account against MongoDB; login returns a token that the browser stores for later requests. Session code also provides role-aware navigation. Storefront catalog, cart, and order links appear in session navigation, but their implementations are not present in the supplied tree. No README was provided; edges reflect shown calls and routing.

Main entry points: [`backend/routes/authRoutes.js`](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/routes/authRoutes.js) (Auth routes), [`frontend/js/login.js`](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/login.js) (Login flow), [`frontend/js/api.js`](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/api.js) (API client), [`backend/app.js`](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/app.js) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser experience"]
  node_login_page["Login page<br/>[login.html]"]
  node_registration_page["Registration page<br/>[registro.html]"]
  node_login_ui["Login flow<br/>[login.js]"]
  node_registration_ui["Registration flow<br/>[registro.js]"]
  node_session["Session navigation<br/>[sesion.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_server["Authentication service"]
  node_app["Express app<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[authRoutes.js]"]
  node_auth_controller["Auth handlers<br/>[authController.js]"]
  node_token_guard["Token middleware<br/>[auth.js]"]
end

subgraph group_data["Persistence"]
  node_user_model["User model<br/>[Usuario.js]"]
  node_db_connector["Database connector<br/>[db.js]"]
end

node_user(("Storefront user"))
node_mongo[("MongoDB")]

node_user -->|"opens"| node_login_page
node_user -->|"opens"| node_registration_page
node_login_page -->|"runs"| node_login_ui
node_registration_page -->|"runs"| node_registration_ui
node_login_ui -->|"submits login"| node_api_client
node_registration_ui -->|"submits registration"| node_api_client
node_login_ui -->|"stores session"| node_session
node_api_client -->|"sends auth requests"| node_auth_routes
node_app -->|"mounts routes"| node_auth_routes
node_app -->|"connects database"| node_db_connector
node_auth_routes -->|"dispatches handlers"| node_auth_controller
node_auth_routes -->|"protects profile"| node_token_guard
node_auth_controller -->|"queries users"| node_user_model
node_db_connector -->|"connects"| node_mongo

click node_login_page "https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/login.html"
click node_registration_page "https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/registro.html"
click node_login_ui "https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/login.js"
click node_registration_ui "https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/registro.js"
click node_session "https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/sesion.js"
click node_api_client "https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/api.js"
click node_app "https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/app.js"
click node_auth_routes "https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/routes/authRoutes.js"
click node_auth_controller "https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/controllers/authController.js"
click node_token_guard "https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/middlewares/auth.js"
click node_user_model "https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/models/Usuario.js"
click node_db_connector "https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/config/db.js"

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_login_page,node_registration_page,node_login_ui,node_registration_ui,node_session,node_api_client,node_user toneBlue
class node_app,node_auth_routes,node_auth_controller,node_token_guard,node_mongo toneAmber
class node_user_model,node_db_connector toneMint
```

## Components

### Browser experience

- [Login page](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/login.html): `frontend/login.html`
- [Registration page](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/registro.html): `frontend/registro.html`
- [Login flow](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/login.js): `frontend/js/login.js`
- [Registration flow](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/registro.js): `frontend/js/registro.js`
- [Session navigation](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/sesion.js): `frontend/js/sesion.js`
- [API client](https://github.com/michat-arch/proyecto-final-pweb/blob/main/frontend/js/api.js): `frontend/js/api.js`

### Authentication service

- [Express app](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/app.js): `backend/app.js`
- [Auth routes](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Auth handlers](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Token middleware](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/middlewares/auth.js): `backend/middlewares/auth.js`

### Persistence

- [User model](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/models/Usuario.js): `backend/models/Usuario.js`
- [Database connector](https://github.com/michat-arch/proyecto-final-pweb/blob/main/backend/config/db.js): `backend/config/db.js`

### Other components

- **Storefront user**
- **MongoDB**

## Connections

- Storefront user → Login page: opens
- Storefront user → Registration page: opens
- Login page → Login flow: runs
- Registration page → Registration flow: runs
- Login flow → API client: submits login (evidence: `frontend/js/login.js`)
- Registration flow → API client: submits registration (evidence: `frontend/js/registro.js`)
- Login flow → Session navigation: stores session (evidence: `frontend/js/login.js`)
- API client → Auth routes: sends auth requests (evidence: `frontend/js/api.js`)
- Express app → Auth routes: mounts routes (evidence: `backend/app.js`)
- Express app → Database connector: connects database (evidence: `backend/app.js`)
- Auth routes → Auth handlers: dispatches handlers (evidence: `backend/routes/authRoutes.js`)
- Auth routes → Token middleware: protects profile (evidence: `backend/routes/authRoutes.js`)
- Auth handlers → User model: queries users (evidence: `backend/controllers/authController.js`)
- Database connector → MongoDB: connects (evidence: `backend/config/db.js`)
