# dnwits/projecte_entorns architecture

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

- Interactive diagram: https://gitdiagram.com/dnwits/projecte_entorns
- Repository: https://github.com/dnwits/projecte_entorns

## Overview

##### Project type and purpose
- This is a full-stack, client-server cinema reservation system consisting of:
- A Python CLI “frontend” (clientConsola.py)
- A Flask-based RESTful “backend” (server.py + DAO layer)
- A MySQL database (cinema.sql + inserts.sql)
- Users can view showtimes, select seats and make/manage reservations. Authentication is JWT-based.

##### File structure
Top-level folders/files:
- documentacio/ – use cases and endpoint descriptions
- webservice/ – all server & client code, DAO, auth & hashing, config, tests
- cinema.sql & inserts.sql – DB schema & seed data
- README.md – project overview & tech stack

Key architectural elements:
- webservice/server.py exposes REST endpoints (Flask)
- webservice/DAO*.py contains data-access objects for Pelicula and Usuari
- webservice/hash*.py implements password hashing & JWT
- webservice/clientConsola.py is the CLI client sending HTTP requests to the server
- MySQL runs locally; server_config.py holds connection settings

##### README for additional insights
- Backend: Python + Flask, JWT auth, MySQL on localhost
- Frontend: Python CLI
- No external APIs, no cloud components
- Layers: Presentation (CLI), Service/API (Flask), Data (DAO → MySQL)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    CLI["CLI Client\n(clientConsola.py)"]:::frontend
    JWTStorage["Local JWT Storage"]:::frontend

    %% Backend/API
    Server["Flask REST API\n(server.py)"]:::backend
    Config["Server Config\n(server_config.py)"]:::backend

    %% Business Logic / Auth
    subgraph "Business Logic & Auth"
        direction TB
        JWT["JWT & Auth Helpers\n(hash.py)"]:::biz
        PassHash["Password Hashing Utility\n(hashear_pass.py)"]:::biz
    end

    %% Data Access Layer
    subgraph "DAO Layer"
        direction TB
        DAO1["Pelicula DAO\n(DAOPelicula.py)"]:::dao
        DAO2["Usuari DAO\n(DAOUsuari.py)"]:::dao
    end

    %% Database
    DB["MySQL Database\n(cinema schema)"]:::db
    DBschema["Schema Definition\n(cinema.sql)"]:::db
    DBseed["Seed Inserts\n(inserts.sql)"]:::db

    %% Documentation & Diagrams
    subgraph "Documentation & Diagrams"
        direction TB
        UseCases["Use Cases\n(cas_dus.md)"]:::docs
        Endpoints["Endpoint Descriptions\n(end-points_desc.md)"]:::docs
        Arch["Architecture Diagram\n(d_arquitectura_cliente_server.mermaid)"]:::docs
        ER["ER Model\n(d_model_entitat_relacio.mermaid)"]:::docs
        Classes["Class Diagram\n(d_classes_backend.mermaid)"]:::docs
        Seq["Sequence Diagram\n(d_secuencia_login.mermaid)"]:::docs
        Wireframes["Wireframes\n(d_wireframe_*.mermaid)"]:::docs
        Readme["Project Overview\n(README.md)"]:::docs
    end

    %% Tests
    Tests["Unit Tests\n(test_unitari.py)"]:::tests

    %% Connections
    CLI -->|"HTTP/JSON"| Server
    CLI -.->|"stores token"| JWTStorage
    CLI -.->|"reads token"| JWTStorage
    Server -->|"uses config"| Config
    Server -->|"auth requests"| JWT
    Server -->|"password hashing"| PassHash
    Server -->|"DB access"| DAO1
    Server -->|"DB access"| DAO2
    DAO1 -->|"SQL queries"| DB
    DAO2 -->|"SQL queries"| DB
    DBschema --> DB
    DBseed --> DB

    %% Click Events
    click CLI "https://github.com/dnwits/projecte_entorns/blob/main/webservice/clientConsola.py"
    click Server "https://github.com/dnwits/projecte_entorns/blob/main/webservice/server.py"
    click Config "https://github.com/dnwits/projecte_entorns/blob/main/webservice/server_config.py"
    click JWT "https://github.com/dnwits/projecte_entorns/blob/main/webservice/hash.py"
    click PassHash "https://github.com/dnwits/projecte_entorns/blob/main/webservice/hashear_pass.py"
    click DAO1 "https://github.com/dnwits/projecte_entorns/blob/main/webservice/DAOPelicula.py"
    click DAO2 "https://github.com/dnwits/projecte_entorns/blob/main/webservice/DAOUsuari.py"
    click DBschema "https://github.com/dnwits/projecte_entorns/blob/main/cinema.sql"
    click DBseed "https://github.com/dnwits/projecte_entorns/blob/main/inserts.sql"
    click Tests "https://github.com/dnwits/projecte_entorns/blob/main/webservice/test_unitari.py"
    click UseCases "https://github.com/dnwits/projecte_entorns/blob/main/documentacio/cas_dus.md"
    click Endpoints "https://github.com/dnwits/projecte_entorns/blob/main/documentacio/end-points_desc.md"
    click Arch "https://github.com/dnwits/projecte_entorns/blob/main/diagrames/d_arquitectura_cliente_server.mermaid"
    click ER "https://github.com/dnwits/projecte_entorns/blob/main/diagrames/d_model_entitat_relacio.mermaid"
    click Classes "https://github.com/dnwits/projecte_entorns/blob/main/diagrames/d_classes_backend.mermaid"
    click Seq "https://github.com/dnwits/projecte_entorns/blob/main/diagrames/d_secuencia_login.mermaid"
    click Wireframes "https://github.com/dnwits/projecte_entorns/blob/main/diagrames/d_wireframe_*.mermaid"
    click Readme "https://github.com/dnwits/projecte_entorns/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0EBFF,stroke:#0077B6,stroke-width:1px
    classDef backend fill:#D8F5A2,stroke:#2D6A4F,stroke-width:1px
    classDef biz fill:#FFF3BF,stroke:#CC8400,stroke-width:1px
    classDef dao fill:#FFD8A8,stroke:#D9480F,stroke-width:1px
    classDef db fill:#E9ECEF,stroke:#495057,stroke-width:1px
    classDef docs fill:#E5DBFF,stroke:#5C1B77,stroke-width:1px
    classDef tests fill:#FFE3E3,stroke:#C92A2A,stroke-width:1px
    %% Dashed style for JWT storage
    class JWTStorage dashed-stroke
    classDef dashed-stroke stroke-dasharray: 5 5,stroke:#0077B6
```
