# johnperedofernandez/proyectologin_tp3 architecture

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

- Interactive diagram: https://gitdiagram.com/johnperedofernandez/proyectologin_tp3
- Repository: https://github.com/johnperedofernandez/proyectologin_tp3

## Overview

Proyecto Login is a PHP/MySQL authentication application with login, account registration, a protected welcome page, and CSRF-protected logout. Users enter credentials or registration details in browser forms; the frontend submits to PHP API endpoints, which validate requests, access MySQL, and maintain authenticated session state. The welcome page reads that session and logout destroys it. The README documents responsive styling and vanilla-JavaScript form validation; those files were not sampled, so their detailed wiring is not asserted. SQL schema contents were also not sampled.

Main entry points: [`src/config/session.php`](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/config/session.php) (Session and CSRF), [`public/api/login.php`](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/api/login.php) (Login endpoint), [`public/api/registro.php`](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/api/registro.php) (Registration endpoint), [`public/index.php`](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/index.php) (Login page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Web experience"]
  node_login_page["Login page<br/>[index.php]"]
  node_registration_page["Registration page<br/>[registro.php]"]
  node_welcome_page["Welcome page<br/>[bienvenida.php]"]
  node_auth_js["Form JavaScript<br/>[auth.js]"]
  node_styles["Responsive styles<br/>[styles.css]"]
end

subgraph group_authentication["Authentication"]
  node_logout_handler["Logout handler<br/>[logout.php]"]
  node_login_api["Login endpoint<br/>[login.php]"]
  node_registration_api["Registration endpoint<br/>[registro.php]"]
end

subgraph group_state["Session and data"]
  node_session["Session and CSRF<br/>[session.php]"]
  node_database_config["PDO connection<br/>[database.php]"]
  node_helpers["Request and output helpers<br/>[helpers.php]"]
  node_mysql[("MySQL")]
  node_schema["Database schema<br/>[schema.sql]"]
end

node_user(("User"))

node_user -->|"opens login"| node_login_page
node_user -->|"opens registration"| node_registration_page
node_user -->|"views account"| node_welcome_page
node_login_page -->|"starts session"| node_session
node_login_page -->|"gets CSRF token"| node_session
node_registration_page -->|"starts session"| node_session
node_registration_page -->|"gets CSRF token"| node_session
node_login_page -->|"loads script"| node_auth_js
node_registration_page -->|"loads script"| node_auth_js
node_login_page -->|"loads styles"| node_styles
node_registration_page -->|"loads styles"| node_styles
node_welcome_page -->|"loads styles"| node_styles
node_auth_js -.->|"submits login"| node_login_api
node_auth_js -.->|"submits registration"| node_registration_api
node_login_api -->|"validates CSRF"| node_session
node_login_api -->|"stores identity"| node_session
node_login_api -->|"gets connection"| node_database_config
node_login_api -->|"reads JSON"| node_helpers
node_login_api -->|"sends JSON"| node_helpers
node_registration_api -->|"validates CSRF"| node_session
node_registration_api -->|"gets connection"| node_database_config
node_registration_api -->|"reads JSON"| node_helpers
node_registration_api -->|"sends JSON"| node_helpers
node_database_config -->|"connects to"| node_mysql
node_login_api -->|"queries users"| node_mysql
node_registration_api -->|"inserts user"| node_mysql
node_schema -->|"defines schema"| node_mysql
node_welcome_page -->|"reads identity"| node_session
node_welcome_page -->|"gets CSRF token"| node_session
node_welcome_page -->|"posts logout"| node_logout_handler
node_logout_handler -->|"validates token"| node_session
node_logout_handler -->|"destroys session"| node_session

click node_login_page "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/index.php"
click node_registration_page "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/registro.php"
click node_welcome_page "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/bienvenida.php"
click node_logout_handler "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/logout.php"
click node_auth_js "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/assets/js/auth.js"
click node_styles "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/assets/css/styles.css"
click node_login_api "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/api/login.php"
click node_registration_api "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/api/registro.php"
click node_session "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/config/session.php"
click node_database_config "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/config/database.php"
click node_helpers "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/includes/helpers.php"
click node_schema "https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/sql/schema.sql"

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_welcome_page,node_auth_js,node_styles,node_user toneBlue
class node_logout_handler,node_login_api,node_registration_api toneAmber
class node_session,node_database_config,node_helpers,node_mysql,node_schema toneMint
```

## Components

### Web experience

- [Login page](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/index.php): `public/index.php`
- [Registration page](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/registro.php): `public/registro.php`
- [Welcome page](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/bienvenida.php): `public/bienvenida.php`
- [Form JavaScript](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/assets/js/auth.js): `public/assets/js/auth.js`
- [Responsive styles](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/assets/css/styles.css): `public/assets/css/styles.css`

### Authentication

- [Logout handler](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/logout.php): `public/logout.php`
- [Login endpoint](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/api/login.php): `public/api/login.php`
- [Registration endpoint](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/public/api/registro.php): `public/api/registro.php`

### Session and data

- [Session and CSRF](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/config/session.php): `src/config/session.php`
- [PDO connection](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/config/database.php): `src/config/database.php`
- [Request and output helpers](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/src/includes/helpers.php): `src/includes/helpers.php`
- **MySQL**
- [Database schema](https://github.com/johnperedofernandez/proyectologin_tp3/blob/main/sql/schema.sql): `sql/schema.sql`

### Other components

- **User**

## Connections

- User → Login page: opens login (evidence: `README.md`)
- User → Registration page: opens registration (evidence: `README.md`)
- User → Welcome page: views account (evidence: `README.md`)
- Login page → Session and CSRF: starts session (evidence: `public/index.php`)
- Login page → Session and CSRF: gets CSRF token (evidence: `public/index.php`)
- Registration page → Session and CSRF: starts session (evidence: `public/registro.php`)
- Registration page → Session and CSRF: gets CSRF token (evidence: `public/registro.php`)
- Login page → Form JavaScript: loads script (evidence: `public/index.php`)
- Registration page → Form JavaScript: loads script (evidence: `public/registro.php`)
- Login page → Responsive styles: loads styles (evidence: `README.md`)
- Registration page → Responsive styles: loads styles (evidence: `README.md`)
- Welcome page → Responsive styles: loads styles (evidence: `README.md`)
- Form JavaScript → Login endpoint: submits login
- Form JavaScript → Registration endpoint: submits registration
- Login endpoint → Session and CSRF: validates CSRF (evidence: `public/api/login.php`)
- Login endpoint → Session and CSRF: stores identity (evidence: `public/api/login.php`)
- Login endpoint → PDO connection: gets connection (evidence: `public/api/login.php`)
- Login endpoint → Request and output helpers: reads JSON (evidence: `public/api/login.php`)
- Login endpoint → Request and output helpers: sends JSON (evidence: `public/api/login.php`)
- Registration endpoint → Session and CSRF: validates CSRF (evidence: `public/api/registro.php`)
- Registration endpoint → PDO connection: gets connection (evidence: `public/api/registro.php`)
- Registration endpoint → Request and output helpers: reads JSON (evidence: `public/api/registro.php`)
- Registration endpoint → Request and output helpers: sends JSON (evidence: `public/api/registro.php`)
- PDO connection → MySQL: connects to (evidence: `src/config/database.php`)
- Login endpoint → MySQL: queries users (evidence: `public/api/login.php`)
- Registration endpoint → MySQL: inserts user (evidence: `public/api/registro.php`)
- Database schema → MySQL: defines schema (evidence: `README.md`)
- Welcome page → Session and CSRF: reads identity (evidence: `public/bienvenida.php`)
- Welcome page → Session and CSRF: gets CSRF token (evidence: `public/bienvenida.php`)
- Welcome page → Logout handler: posts logout (evidence: `public/bienvenida.php`)
- Logout handler → Session and CSRF: validates token (evidence: `public/logout.php`)
- Logout handler → Session and CSRF: destroys session (evidence: `public/logout.php`)
