# dataforgoodfr/13_brigade_coupes_rases architecture

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

- Interactive diagram: https://gitdiagram.com/dataforgoodfr/13_brigade_coupes_rases
- Repository: https://github.com/dataforgoodfr/13_brigade_coupes_rases

## Overview

##### Project Type & Purpose
- The project is a full-stack solution aimed at automating the detection, processing, and visualization of illegal clear-cutting events using satellite data.
- The README clarifies it includes: an algorithm (GlobEO) for detection, data pipelines for processing, a database (PostgreSQL with PostGIS), a backend API for CRUD operations and management, and a frontend for interactive maps and data visualization.
- Additional support functions include analytics, utility scripts (d4g-utils), and testing/infrastructure through Docker, Poetry, Tox and pre-commit hooks.

##### Analyzing the File Structure
- Top-level directories (backend, frontend, data_pipeline, analytics, misc) clearly segment concerns:
- The “backend” directory is likely to contain the API (Flask/FastAPI or similar) and logic for interfacing with the database.
- The “frontend” directory houses the UI components for data visualization and interactive maps, with a strong focus on “clear-cutting” features (e.g., components that render maps, sidebars, lists).
- The “data_pipeline” directory indicates dedicated scripts for ingesting and processing incoming clear-cutting data.
- The “analytics” directory suggests additional scripts for data analysis and visualization beyond the immediate UI.
- Additional support for configuration and deployment is seen in “docker”, “.github” workflows for CI/CD, and build/installation files for Poetry and Python (pyproject.toml, tox.ini).

##### Key Components
a. GlobEO Algorithm:
- External data source (GlobEO) that detects clear-cutting events.
- This component feeds raw data (CSV/JSON) into the system.
b. Data Pipeline:
c. Database (PostgreSQL + PostGIS):
- Use a dedicated component to represent the spatially enabled database.
d. Backend Service/API:
- API (e.g., Flask/FastAPI) that handles CRUD operations, business logic, and authentication for administrative tasks.
- That the backend interacts with both the database and the frontend.
e. Frontend Application:
- Detail the UI portion with components for visualizing maps, listing incidents, and managing records.
- Clear separation of components (e.g., interactive maps, filter panels, dialogs).
f. Analytics Module:
- A separate analytics/visualization module that takes data from the database, performs further processing, and displays insights.
g. Supporting Utilities & Infrastructure:
- Support components like Docker containers (e.g., “docker/” for Postgres deployment), CI/CD configurations (.github/workflows), and dependency management tools (Poetry).

##### Relationships and Data Flow
- How the backend API fetches/updates data in the database.
- That the frontend interacts with the backend API to retrieve data and render maps/statistics.
- Optionally, include loose coupling between the analytics module and the database or backend for additional processing.
- Utility paths (like d4g-utils for environment setup) and integration with CI/CD pipelines.

##### Architectural Patterns & Design Principles
- A modular and layered architecture that clearly separates concerns (data ingestion, processing, storage, business logic, presentation).
- If applicable, note that the frontend seems to use a component-based design (e.g., ClearCutting, offline features) while the backend is likely following RESTful API design.
- Mention that the system benefits from containerization (Docker) and automation (GitHub workflows, pre-commit hooks, Tox).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Ingestion & Processing Layer
    subgraph "Data Ingestion & Processing"
        GDI["GlobEO Data Ingestion"]:::external
        DP["Data Pipeline & Processing"]:::processing
    end
    GDI -->|"feeds"| DP

    %% Data Storage Layer
    subgraph "Data Storage"
        DB["Database (PostgreSQL + PostGIS)"]:::database
    end
    DP -->|"processes"| DB

    %% Application Services Layer
    subgraph "Application Services"
        BE["API Backend"]:::backend
    end
    DB -->|"CRUD"| BE
    BE -->|"APIcalls"| FM["Frontend Maps & UI"]:::frontend
    DB -->|"insights"| AM["Analytics Module"]:::analytics

    %% Supporting Utilities & Infrastructure
    subgraph "Supporting Utilities & Infrastructure"
        CI["CI/CD & Pre-commit"]:::utilities
        PP["PyProject"]:::utilities
        TC["Tox Config"]:::utilities
        US["Utility Scripts"]:::utilities
    end
    CI ---|"deploys"| BE
    PP ---|"manages"| BE
    TC ---|"configures"| BE
    US ---|"supports"| BE

    %% Click Events
    click DP "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/data_pipeline/"
    click DB "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/docker/postgres/"
    click BE "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/backend/"
    click FM "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/frontend/"
    click AM "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/analytics/"
    click CI "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/.github/workflows/"
    click PP "https://github.com/dataforgoodfr/13_brigade_coupes_rases/blob/main/pyproject.toml"
    click TC "https://github.com/dataforgoodfr/13_brigade_coupes_rases/blob/main/tox.ini"
    click US "https://github.com/dataforgoodfr/13_brigade_coupes_rases/tree/main/d4g-utils/"

    %% Styles
    classDef external fill:#f9d,stroke:#333,stroke-width:2px;
    classDef processing fill:#bbf,stroke:#333,stroke-width:2px;
    classDef database fill:#cfc,stroke:#333,stroke-width:2px;
    classDef backend fill:#fc9,stroke:#333,stroke-width:2px;
    classDef frontend fill:#9cf,stroke:#333,stroke-width:2px;
    classDef analytics fill:#fcd,stroke:#333,stroke-width:2px;
    classDef utilities fill:#ddd,stroke:#333,stroke-width:2px;
```
