# hispanotech-ugc/hispanotech-ugc-web architecture

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

- Interactive diagram: https://gitdiagram.com/hispanotech-ugc/hispanotech-ugc-web
- Repository: https://github.com/hispanotech-ugc/hispanotech-ugc-web

## Overview

##### Project type and purpose
- HispanoTech-UGC-WEB is a full-stack, static-hosted web application (GitHub Pages) that uses Supabase (PostgreSQL + Auth + Storage + Realtime) as its backend.
- It provides a UI for law-enforcement crisis management (login/registration, operator dashboard, reporting, mapping, robot control) and includes an auxiliary Python script for weapon detection (`armas/detectarArmas.py`).

##### File structure
- Top-level “html/”, “css/”, “js/” directories → pure frontend: HTML pages, CSS styles, vanilla JS logic.
- “models/” → client-side data models (users, roles, eventos, informes, robots).
- “services/” → wrappers around Supabase client for auth, admin, operator, user, informs.
- “config/” → DB schema (`hispanodb.sql`) + Supabase client initialization (`supabaseClient.js`).
- “armas/” → Python script for weapon detection (external microservice or local batch job).
- “test/” and “doc/” → testing and documentation artifacts.

##### README for additional insights
- Confirms static-hosted SPA pages (landing, login, registro, operador, admin).
- Emphasizes Supabase Auth, real-time subscriptions, and database schema.

##### Essential details
- Authentication flow: Browser → Supabase Auth → DB
- Data-CRUD flow: Browser → services/*.js → Supabase Postgres
- Storage flow: Browser → Supabase Storage → Browser
- Realtime updates: Supabase Realtime → Browser
- Python detection: Storage → Weapon Detection Service → Storage/DB

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client layer
    subgraph "Client"
        direction TB
        Browser(["User Browser"]):::frontend
    end

    %% Frontend static assets
    subgraph "Frontend (GitHub Pages)"
        direction TB
        HTML["HTML Pages"]:::frontend
        CSS["CSS Stylesheets"]:::frontend
        JS["JavaScript Logic"]:::frontend
    end

    %% API layer
    subgraph "API Layer (Services)"
        direction TB
        Models["Data Models"]:::frontend
        Services["Supabase Service Wrappers"]:::frontend
        SupabaseClient["Supabase Client Init"]:::frontend
    end

    %% Supabase BaaS
    subgraph "Supabase (BaaS)"
        direction TB
        Auth["Auth Service"]:::baas
        Storage["Storage Service"]:::baas
        Realtime["Realtime Service"]:::baas
        DBSchema["Database Schema"]:::baas
        DB["PostgreSQL Database"]:::database
    end

    %% External microservice
    WeaponDetection(["Weapon Detection Service"]):::external

    %% Documentation and Tests
    subgraph "Artifacts"
        direction TB
        Docs["Documentation"]:::external
        Tests["Unit Tests"]:::external
    end

    %% Connections
    Browser -->|"GET pages"| HTML
    Browser -->|"GET styles"| CSS
    Browser -->|"GET scripts"| JS
    Browser -->|"uses Models & Services"| Services
    Browser -->|"direct SDK init"| SupabaseClient

    Services -->|"calls Auth"| Auth
    Services -->|"CRUD operations"| DB
    Services -->|"upload/download"| Storage
    Realtime -->|"push updates"| Browser
    Storage -->|"subscribeRealtime"| Realtime

    Storage -->|"on image upload"| WeaponDetection
    WeaponDetection -->|"return results"| Storage
    WeaponDetection -->|"store metadata"| DB

    Docs
    Tests

    %% Click Events
    click HTML "https://github.com/hispanotech-ugc/hispanotech-ugc-web/tree/master/html/"
    click CSS "https://github.com/hispanotech-ugc/hispanotech-ugc-web/tree/master/css/"
    click JS "https://github.com/hispanotech-ugc/hispanotech-ugc-web/tree/master/js/"
    click Models "https://github.com/hispanotech-ugc/hispanotech-ugc-web/tree/master/models/"
    click Services "https://github.com/hispanotech-ugc/hispanotech-ugc-web/tree/master/services/"
    click SupabaseClient "https://github.com/hispanotech-ugc/hispanotech-ugc-web/blob/master/config/supabaseClient.js"
    click DBSchema "https://github.com/hispanotech-ugc/hispanotech-ugc-web/blob/master/config/hispanodb.sql"
    click WeaponDetection "https://github.com/hispanotech-ugc/hispanotech-ugc-web/blob/master/armas/detectarArmas.py"
    click Docs "https://github.com/hispanotech-ugc/hispanotech-ugc-web/blob/master/doc/Documento Técnico HispanoTech-UGC.pdf"
    click Tests "https://github.com/hispanotech-ugc/hispanotech-ugc-web/tree/master/test/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef baas fill:#DFF2E0,stroke:#237C00,color:#237C00;
    classDef external fill:#FFE4B5,stroke:#C65D00,color:#C65D00;
    classDef database fill:#E0FFE9,stroke:#009944,color:#009944;
```
