# pedrolivaresanchez/emergency-cv architecture

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

- Interactive diagram: https://gitdiagram.com/pedrolivaresanchez/emergency-cv
- Repository: https://github.com/pedrolivaresanchez/emergency-cv

## Overview

##### Project type and purpose
- This is a full‑stack emergency‑response web application (“Ajuda Dana Valencia”) built with Next.js (React) on the frontend, Next.js API routes on the backend, and Supabase as the database/auth layer.
- It centralizes real‑time alerts, interactive maps, help requests/offers, and integrates with an external C# “DanaCrawler” worker to seed and update data from Google Sheets.

##### File structure
- Top‑level:
- next.config.mjs, Dockerfile, kubernetes.yml for build/deploy
- src/app (Next.js pages and layouts)
- src/api (internal API routes under src/app/api)
- src/components, src/context, src/lib, src/helpers, src/types for UI, state, service calls, and type definitions
- supabase/ for database migrations, seed, config
- tools/DanaCrawler/ is a standalone .NET worker that runs in its own container
- .github/workflows for CI/CD (code quality, crawler run, webapp deploy)
- The presence of kubernetes.yml and Dockerfile suggests containerized deployments (both webapp and crawler).

##### README for additional insights
- Confirms Next.js, Supabase, TailwindCSS stack.
- Mentions environment variables for Supabase URL and ANON key.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    subgraph "Client Side"
        Browser("User Browser"):::external
    end

    %% Web Application
    subgraph "Web Application"
        subgraph "Frontend Code"
            Frontend["Next.js Frontend\n(app router & pages)"]:::frontend
            Components["UI Components Library"]:::frontend
            Context["Client-side State & Context Providers"]:::frontend
            Lib["Service Layer & Supabase Client Middleware"]:::backend
            Types["Type Definitions"]:::backend
            Helpers["Helper Functions & Hooks"]:::backend
        end
        subgraph "API Layer"
            API["Next.js API Routes"]:::api
        end
    end

    %% Database
    subgraph "Database & Auth"
        Supabase["Supabase Postgres & Auth"]:::db
        Migrations["Database Migrations & Seed Scripts"]:::db
        SupabaseConfig["Supabase Config"]:::db
    end

    %% Worker
    subgraph "DanaCrawler Worker"
        Crawler["DanaCrawler Worker Service (.NET)"]:::worker
    end

    %% External Services
    subgraph "External Services"
        Sheets("Google Sheets"):::external
        Maps("Google Maps / Geolocation API"):::external
    end

    %% Infrastructure
    subgraph "Infrastructure"
        DockerfileNode["Docker Build for Webapp"]:::infra
        K8s["Kubernetes Deployment Config"]:::infra
        CI["GitHub Actions CI/CD"]:::infra
        Tests["End-to-End Test Suite (Playwright)"]:::infra
    end

    %% Connections
    Browser -->|"HTTP/S"| Frontend
    Frontend -->|"fetch() calls"| API
    API -->|"CRUD operations"| Supabase
    Frontend -->|"JS SDK"| Supabase
    Frontend -->|"REST calls"| Maps
    Crawler -->|"writes data"| Supabase
    Crawler -->|"reads data"| Sheets
    CI -->|"build & deploy webapp"| DockerfileNode
    CI -->|"deploy to cluster"| K8s
    CI -->|"build & run crawler"| Crawler
    CI -->|"run tests"| Tests
    Migrations -->|"run at deploy"| Supabase
    SupabaseConfig --> Supabase

    %% Click Events
    click Frontend "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/app"
    click API "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/app/api"
    click Components "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/components"
    click Context "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/context"
    click Lib "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/lib"
    click Types "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/types"
    click Helpers "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/src/helpers"
    click SupabaseConfig "https://github.com/pedrolivaresanchez/emergency-cv/blob/main/supabase/config.toml"
    click Migrations "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/supabase/migrations"
    click DockerfileNode "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/Dockerfile"
    click K8s "https://github.com/pedrolivaresanchez/emergency-cv/blob/main/kubernetes.yml"
    click Crawler "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/tools/DanaCrawler"
    click CI "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/.github/workflows"
    click Tests "https://github.com/pedrolivaresanchez/emergency-cv/tree/main/tests"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0080FF,color:#000
    classDef api fill:#E8F4FF,stroke:#0066CC,color:#000
    classDef backend fill:#FFEFD0,stroke:#FFAA00,color:#000
    classDef db fill:#DFFFE0,stroke:#00AA00,color:#000,shape:cylinder
    classDef external fill:#F0F0F0,stroke:#888888,color:#000
    classDef infra fill:#FFE0E0,stroke:#CC0000,color:#000
    classDef worker fill:#E8D0FF,stroke:#8000CC,color:#000
```
