# map-rank/residat-front-office architecture

> Architecture diagram of the GitHub repository map-rank/residat-front-office, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/map-rank/residat-front-office
- Repository: https://github.com/map-rank/residat-front-office

## Overview

##### Project Type and Purpose
- This is a full-stack climate-risk platform’s frontend repository (“residat-front-platform”), implemented as a Vue 3 Single-Page Application (SPA) built with Vite.
- It delivers interactive GIS dashboards, community reports, chatrooms, and push notifications. The frontend consumes backend REST APIs, leverages Firebase Cloud Messaging, and loads static GeoJSON data for maps.

##### File-Structure Analysis
- Top-level:
- public/ – static assets (GeoJSON, images, service worker for FCM)
- src/ – application source
– api/ (axios wrappers & endpoints)
– components/ (base UI & common components)
– features/ (domain-oriented Views: Auth, ChatRoom, Community, etc.)
– services/ (business-logic wrappers over API calls)
– stores/ (Pinia/Vuex stores for state management)
– router/, langs/, plugins/, utils/, model/
- Config files: Dockerfile, Vite, PostCSS, Tailwind, GitHub Actions workflows – indicate CI/CD, containerization, and static-site deployment.

##### Key Architecture Insights from README
- SPA front-end interacts with microservices exposing endpoints for Auth, Posts, Events, Notifications, Reports, etc.
- Uses Firebase for push notifications (service worker registered in public/).
- Serves static GeoJSON from public/assets and storage/, plus dynamic spatial data from backend.

##### Main Components
A. Client Layer (Browser/Mobile)
- Vue 3 SPA (App.vue, Features, Components)
- Pinia stores (state)
- Vue Router (navigation)
- Localization (i18n)
- Service Worker (public/firebase-messaging-sw.js)
B. Static Asset Hosting
- CDN / S3 or NGINX (serves index.html & JS bundles, static GeoJSON)
C. Backend API Services
- Auth Service
- Post Service
- Event Service
- Report Service
- Notification Service
- Disaster / Zone / Sector Services
- Each exposed as REST endpoints (https://api.residat.com/…)
D. Real-Time & Push Infrastructure
- Firebase Cloud Messaging (for mobile/Web pushes)
- (Optionally) WebSocket / Socket.IO or Firestore Real-Time DB for ChatRooms
E. Data Stores
- Primary Database (e.g., PostgreSQL/PostGIS for spatial data)
- Blob/Document Storage (for reports, images)
- Cache / CDN for GeoJSON tiles
F. External GIS/Mapping Services
- Tile Provider (OSM, Mapbox)
- GeoJSON file hosting (in public/assets, storage/)

##### Relationships & Data Flows
- Browser → (HTTPS) → CDN → index.html & JS bundle
- Vue App → (HTTP/REST) → Backend API endpoints → Database
- Vue App → (WebSocket or Firebase SDK) → Real-Time Chat service
- Vue App → (FCM SDK) → Firebase Cloud Messaging → Device notification
- Vue App → (Direct fetch) → Static GeoJSON in public/ or S3/Storage
- Backend → (DB queries) → PostGIS spatial queries → serves JSON

##### Architectural Patterns & Principles
- Feature-based modularization (src/features)
- Component library + atomic/base components (src/components/base)
- Service abstraction (src/services & src/api)
- State management with Pinia (stores folder)
- Separation: View (Vue components) ←→ State (stores) ←→ API (services)
- CI/CD: Docker build → Static Deployment (GitHub Actions)
- Testing: Vitest for unit & integration tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Layer
    subgraph "Browser (Client Layer)" 
        direction TB
        VueApp["Vue 3 SPA"]:::frontend
        Router["Vue Router"]:::frontend
        Stores["Pinia Stores"]:::frontend
        I18n["i18n Localization"]:::frontend
        SW["Service Worker (FCM)"]:::frontend
    end

    %% Static Hosting
    CDN["CDN / Static Hosting"]:::frontend

    %% Backend Services
    subgraph "Backend API Services" 
        direction TB
        AuthSvc["Auth Service"]:::backend
        PostSvc["Post Service"]:::backend
        EventSvc["Event Service"]:::backend
        ReportSvc["Report Service"]:::backend
        NotificationSvc["Notification Service"]:::backend
        DisasterSvc["Disaster/Zone/Sector Services"]:::backend
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        PostGIS["PostgreSQL/PostGIS"]:::datastore
        BlobStore["Blob/Document Storage"]:::datastore
        GeoCache["GeoJSON Cache/CDN"]:::datastore
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Firebase["Firebase Cloud Messaging"]:::external
        RealTime["WebSocket/Realtime Chat"]:::external
        MapTiles["Map Tile Provider"]:::external
    end

    %% CI/CD
    subgraph "CI/CD & Build"
        direction TB
        GitHub["GitHub Actions"]:::external
        DockerImg["Docker Build"]:::external
        ViteCfg["Vite Config"]:::frontend
        TailwindCfg["Tailwind Config"]:::frontend
    end

    %% Connections
    VueApp -->|loads bundles via HTTPS| CDN
    CDN -->|serves index.html & JS| VueApp

    VueApp -->|REST API calls| AuthSvc
    VueApp -->|REST API calls| PostSvc
    VueApp -->|REST API calls| EventSvc
    VueApp -->|REST API calls| ReportSvc
    VueApp -->|REST API calls| NotificationSvc
    VueApp -->|REST API calls| DisasterSvc

    AuthSvc -->|DB queries| PostGIS
    PostSvc -->|DB queries| PostGIS
    EventSvc -->|DB queries| PostGIS
    ReportSvc -->|DB queries| BlobStore
    NotificationSvc -->|push triggers| Firebase
    DisasterSvc -->|DB queries| PostGIS

    VueApp -->|fetch GeoJSON| GeoCache
    EventSvc -->|cache GeoJSON| GeoCache

    VueApp -->|connect| RealTime
    VueApp -->|subscribe| Firebase

    VueApp -->|fetch tiles| MapTiles

    GitHub -->|triggers| DockerImg
    DockerImg -->|deploys to| CDN

    %% Click Events
    click VueApp "https://github.com/map-rank/residat-front-office/blob/main/src/main.js"
    click VueApp "https://github.com/map-rank/residat-front-office/blob/main/src/App.vue"
    click Router "https://github.com/map-rank/residat-front-office/blob/main/src/router/index.js"
    click Stores "https://github.com/map-rank/residat-front-office/tree/main/src/stores/"
    click I18n "https://github.com/map-rank/residat-front-office/blob/main/src/langs/i18nSetup.js"
    click SW "https://github.com/map-rank/residat-front-office/blob/main/public/firebase-messaging-sw.js"
    click CDN "https://github.com/map-rank/residat-front-office/tree/main/public/assets/maps/"
    click StorageGeo "https://github.com/map-rank/residat-front-office/tree/main/storage/media/geojson/"
    click ApiLayer "https://github.com/map-rank/residat-front-office/blob/main/src/api/api.js"
    click BizServices "https://github.com/map-rank/residat-front-office/tree/main/src/services/"
    click CI "https://github.com/map-rank/residat-front-office/tree/main/Dockerfile"
    click CIYml "https://github.com/map-rank/residat-front-office/blob/main/.github/workflows/deploy.yml"
    click ViteCfg "https://github.com/map-rank/residat-front-office/blob/main/vite.config.mjs"
    click TailwindCfg "https://github.com/map-rank/residat-front-office/blob/main/tailwind.config.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0676D9,color:#003366
    classDef backend fill:#DFF0D8,stroke:#3C763D,color:#2E5128
    classDef external fill:#FFE8B8,stroke:#D97706,color:#663C00
    classDef datastore fill:#E8E8E8,stroke:#707070,color:#333333
```
