# infra-geo-ouverte/sdg architecture

> Architecture diagram of the GitHub repository infra-geo-ouverte/sdg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infra-geo-ouverte/sdg
- Repository: https://github.com/infra-geo-ouverte/sdg

## Overview

##### Main Components
- Library Entry Point: The @igo2/sdg package exposed via packages (with a public API in packages/carto/src/public-api.ts, packages/core/src/public-api.ts, packages/geo/src/public-api.ts, and packages/src/public-api.ts). This entry point lets developers import top-level components and submodules.
- Submodules / Packages:
- Core Module (located in packages/core): Contains layout, styles, theming, router, translation, and global utilities.
- Carto Module (in packages/carto): Focused on mapping functionality leveraging OpenLayers (as seen under the src/ol folder), map controllers, and directives for geolocation and map interactions.
- Geo Module (in packages/geo): Provides additional geo-specific components such as map browsers, filters, legends, queries, and screens.
- UI/Lib Components (in packages/src/lib): Encompasses a broad collection of standard UI components (alerts, breadcrumbs, headers, footers, lateral menus, buttons, contact components, etc.).

##### Relationships and Interactions
- Each module is built as an Angular module that can be imported into an Angular application. The public API files expose the components and services.
- The Core package provides global resources (theme, routing, layout, translations) that are consumed by the other submodules like Carto and Geo to ensure consistency.
- The Carto and Geo modules interact to deliver a cohesive map experience (for example, the mapping browser component in geo might use services or directives from carto).
- The library’s UI components (in the shared “lib” folder) are designed to be integrated into any screen or composite UI and orchestrated within the demo application as found in projects/demo.
- The demo application itself acts as a consumer to illustrate how the submodules work together in a full-stack Angular context.
- Build, lint, and deployment scripts (in the root, .github/workflows, and scripts folders) show the CI/CD integration points.

##### Architectural Patterns and Design Principles
- Modular and Layered Architecture: The separate packages (core, carto, geo, src) each encapsulate a dedicated domain of functionality.
- Component-Based Design: The code is organized into Angular components along with supporting services, directives, and utilities.
- Public API Exposure: Each package exposes its interface via a primary “public-api” file that hides internal implementation details.
- Integration with Angular’s Dependency Injection and routing mechanisms to maintain separation of concerns.
- Use of testing (spec.ts files) and style guidelines (Prettier, ESLint, Prettier configurations) to enforce code quality and consistency.
- Design for extensibility: Submodules in the library (UI components and mapping systems) allow developers to import either the entire library or only the required pieces using namespaced imports (for example, “@igo2/sdg/geo”).

##### Relevant Technologies, Frameworks, or Libraries
- Angular: As the web framework driving the component architecture.
- OpenLayers: Implied by the “ol” directories in the Carto package for mapping functionalities.
- IGO2-LIB Integration: Especially in the mapping and cartographic functionalities, as mentioned in the README.
- Node.js, npm, and associated tooling (ESLint, Prettier, Commitlint) for development and CI/CD, as seen in the configurations and GitHub workflows.
- SCSS/CSS for theming, and Angular’s templating for component view rendering.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Angular Library and its Modules
    subgraph "Angular Library (@igo2/sdg)"
        pMain["Main Public API"]:::api
        subgraph "Modules"
            B["Core Module"]:::core
            pCore["Core Public API"]:::api
            C["Carto Module"]:::carto
            pCarto["Carto Public API"]:::api
            D["Geo Module"]:::geo
            pGeo["Geo Public API"]:::api
            E["UI/Lib Components"]:::ui
            pUI["UI/Lib API"]:::api
        end
    end

    %% Demo Application and CI/CD
    F["Demo Application"]:::demo
    subgraph "CI/CD & Build Scripts"
        G1["GitHub Workflows"]:::cicd
        G2["Build/Release Scripts"]:::cicd
    end

    %% Relationships
    F -->|"imports"| pMain
    pMain -->|"exposes"| pCore
    pMain -->|"exposes"| pCarto
    pMain -->|"exposes"| pGeo
    pMain -->|"exposes"| pUI

    F -->|"imports"| B
    F -->|"imports"| C
    F -->|"imports"| D
    F -->|"imports"| E

    B -->|"provides"| C
    B -->|"provides"| D
    C -->|"interacts"| D
    D -->|"interacts"| C

    G1 -->|"triggers"| pMain
    G2 -->|"triggers"| pMain

    %% Click Events
    click pMain "https://github.com/infra-geo-ouverte/sdg/blob/next/packages/src/public-api.ts"
    click pCore "https://github.com/infra-geo-ouverte/sdg/blob/next/packages/core/src/public-api.ts"
    click pCarto "https://github.com/infra-geo-ouverte/sdg/blob/next/packages/carto/src/public-api.ts"
    click pGeo "https://github.com/infra-geo-ouverte/sdg/blob/next/packages/geo/src/public-api.ts"
    click B "https://github.com/infra-geo-ouverte/sdg/tree/next/packages/core"
    click C "https://github.com/infra-geo-ouverte/sdg/tree/next/packages/carto"
    click D "https://github.com/infra-geo-ouverte/sdg/tree/next/packages/geo"
    click E "https://github.com/infra-geo-ouverte/sdg/tree/next/packages/src/lib"
    click F "https://github.com/infra-geo-ouverte/sdg/tree/next/projects/demo"
    click G1 "https://github.com/infra-geo-ouverte/sdg/tree/next/.github/workflows"
    click G2 "https://github.com/infra-geo-ouverte/sdg/tree/next/scripts/"

    %% Styles
    classDef angular fill:#DAE8FC,stroke:#6C8EBF,stroke-width:2px;
    classDef core fill:#C3E6CB,stroke:#28A745,stroke-width:2px;
    classDef carto fill:#FFF2CC,stroke:#E2B007,stroke-width:2px;
    classDef geo fill:#F8CECC,stroke:#D14B5C,stroke-width:2px;
    classDef ui fill:#E4DFDA,stroke:#82B366,stroke-width:2px;
    classDef demo fill:#D5D5F5,stroke:#8A8ACB,stroke-width:2px;
    classDef cicd fill:#FFE6CC,stroke:#D18B00,stroke-width:2px;
    classDef api fill:#E1D5E7,stroke:#9673A6,stroke-width:2px;
```
