# rashek17/clinica-app architecture

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

- Interactive diagram: https://gitdiagram.com/rashek17/clinica-app
- Repository: https://github.com/rashek17/clinica-app

## Overview

##### Project type and purpose
- Clinica-App is a full-stack web application for managing medical appointments, user roles (paciente, médico, administrador), and medical histories.

##### File structure
- Top-level:
- server.js – Express entrypoint
- package.json / node_modules – backend dependencies
- bd/clinica-app.sql – MySQL schema and seed data
- index.html, css/, js/, view/ – static frontend assets and role-specific views
- tests/ – end-to-end and concurrency tests
- Pattern: classic client–server with static assets served by Express and dynamic data via REST API

##### README for additional insights
- Tech stack: HTML/CSS/JS/Bootstrap frontend; Node.js/Express backend; MySQL via XAMPP; JWT for auth; bcrypt for password hashing
- Key features mapped to roles and data flows

##### Elements
- Clear labels: “Paciente Browser,” “Express API,” “MySQL DB,” etc.
- Client → Server (HTTP requests)
- Server → DB (SQL queries)
- DB → Server → Client (JSON responses)
- Blue rectangles for UI components
- Green for backend layers

- Step 1: Sketch all user roles as separate browser nodes.
- Step 5: Overlay authentication flow: login → JWT issuance → token sent in Authorization header.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    subgraph "Client Zone"
        Paciente["Paciente Browser"]:::ui
        Medico["Médico Browser"]:::ui
        Admin["Administrador Browser"]:::ui
        Landing["Landing Page"]:::ui
    end

    %% Server Zone
    subgraph "Server Zone"
        Express["Express Server"]:::backend
        Static["Static File Handler"]:::backend
        Auth["JWT Auth Middleware"]:::backend
        subgraph "Controllers (Business Logic)"
            Citas["Citas Controller"]:::backend
            Usuarios["Usuarios Controller"]:::backend
            Historial["Historial Controller"]:::backend
        end
        DAL["Data Access Layer"]:::backend
    end

    %% Database
    DB["MySQL Database"]:::db

    %% Test Suite
    subgraph "Test Suite"
        Test1["End-to-End Tests"]:::tests
        Test2["Concurrency Tests"]:::tests
    end

    %% Connections
    Paciente -->|HTTP Requests| Express
    Medico -->|HTTP Requests| Express
    Admin -->|HTTP Requests| Express
    Landing -->|Static Asset Requests| Express

    Express -->|serves static| Static
    Express -->|routes through| Auth
    Auth -->|forwards to| Citas
    Auth -->|forwards to| Usuarios
    Auth -->|forwards to| Historial

    Citas -->|SQL Queries| DAL
    Usuarios -->|SQL Queries| DAL
    Historial -->|SQL Queries| DAL
    DAL -->|connects to| DB

    Test1 -.->|simulates HTTP| Express
    Test2 -.->|concurrent HTTP| Express

    %% Click Events
    click Paciente "https://github.com/rashek17/clinica-app/blob/master/view/v-paciente.html"
    click Medico "https://github.com/rashek17/clinica-app/blob/master/view/v-medico.html"
    click Admin "https://github.com/rashek17/clinica-app/blob/master/view/v-administrador.html"
    click Landing "https://github.com/rashek17/clinica-app/blob/master/index.html"
    click Express "https://github.com/rashek17/clinica-app/blob/master/server.js"
    click Static "https://github.com/rashek17/clinica-app/blob/master/server.js"
    click Auth "https://github.com/rashek17/clinica-app/blob/master/server.js"
    click Citas "https://github.com/rashek17/clinica-app/blob/master/server.js"
    click Usuarios "https://github.com/rashek17/clinica-app/blob/master/server.js"
    click Historial "https://github.com/rashek17/clinica-app/blob/master/server.js"
    click DAL "https://github.com/rashek17/clinica-app/blob/master/bd/clinica-app.sql"
    click Test1 "https://github.com/rashek17/clinica-app/blob/master/tests/flujoCompleto.test.js"
    click Test2 "https://github.com/rashek17/clinica-app/blob/master/tests/test_concurrencia_http.test.js"

    %% Styles
    classDef ui fill:#a2d2ff,stroke:#000;
    classDef backend fill:#caffbf,stroke:#000;
    classDef db fill:#ffd6a5,stroke:#000;
    classDef tests fill:#e0e0e0,stroke:#000,stroke-dasharray:5 5;
```
