# geopython/pygeoapi architecture

> Architecture diagram of the GitHub repository geopython/pygeoapi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/geopython/pygeoapi
- Repository: https://github.com/geopython/pygeoapi

## Overview

##### Main Components

a. Core Components:
- API Layer (pygeoapi/api/)
- Provider Layer (pygeoapi/provider/)
- Process Layer (pygeoapi/process/)
- Formatter Layer (pygeoapi/formatter/)
- Configuration Management (pygeoapi/config.py)
- Web Framework Adapters (flask_app.py, django_app.py, starlette_app.py)

b. External Interfaces:
- OGC API Endpoints
- Database Connections
- File System Access
- External Services

##### Component Relationships

**[Client Requests] → [Web Framework Adapters]**
- ↓
**[Configuration Management] ← [API Layer] → [OpenAPI Specification]**
- ↓                    ↓
- [Provider Layer] ←→ [Process Layer]
- ↓
**[Data Sources/Services]**

##### Specific Implementation Details

a. API Layer (Blue):
- Separate modules for different OGC API specifications
- Coverages.py, environmental_data_retrieval.py, processes.py, etc.

b. Provider Layer (Green):
- Providers by type (file-based, database, service)
- Connections to supported data sources
- Major providers like elasticsearch_, postgresql, rasterio_, etc.

c. Process Layer (Yellow):
- Process management system
- Process execution flow
- Process manager implementations

##### Integration Points

- Clear interfaces between components
- Async/sync operations differently

##### Additional Elements

- Notes for key configuration points
- Security and authentication layers
- Internationalization support (l10n.py)

##### Architectural Patterns to Highlight

- Plugin architecture for providers and processes
- REST API implementation
- Model-View separation
- Configuration-driven design

##### Technical Details

- Supported data formats
- API specifications implemented
- Database connectors
- Processing capabilities
- Templating system

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CR[Client Requests]
    end

    subgraph "Web Framework Layer"
        FA["Flask Adapter"]:::adapter
        DA["Django Adapter"]:::adapter
        SA["Starlette Adapter"]:::adapter
    end

    subgraph "Core Layer"
        CM["Configuration Management"]:::core
        OA["OpenAPI Implementation"]:::core
        L10["Internationalization Support"]:::core
    end

    subgraph "API Layer"
        AC["OGC API Coverages"]:::api
        AE["OGC API EDR"]:::api
        AP["OGC API Processes"]:::api
    end

    subgraph "Provider Layer"
        BP["Base Provider"]:::provider
        subgraph "Database Providers"
            PG["PostgreSQL"]:::provider
            ES["Elasticsearch"]:::provider
            MG["MongoDB"]:::provider
        end
        subgraph "File Providers"
            GJ["GeoJSON"]:::provider
            CSV["CSV"]:::provider
            RT["Raster"]:::provider
        end
    end

    subgraph "Process Layer"
        PB["Process Base"]:::process
        PM["Process Manager"]:::process
        subgraph "Process Managers"
            PMM["MongoDB Manager"]:::process
            PMP["PostgreSQL Manager"]:::process
            PMT["TinyDB Manager"]:::process
        end
        subgraph "Sample Processes"
            EP["Echo Process"]:::process
            HW["Hello World Process"]:::process
        end
    end

    subgraph "Formatter Layer"
        BF["Base Formatter"]:::formatter
        CF["CSV Formatter"]:::formatter
    end

    subgraph "Models"
        CM1["Configuration Models"]:::model
        OM["OpenAPI Models"]:::model
        PM1["Provider Models"]:::model
    end

    CR --> FA & DA & SA
    FA & DA & SA --> CM
    CM --> AC & AE & AP
    AC & AE & AP --> OA
    AC & AE & AP --> BP
    BP --> PG & ES & MG & GJ & CSV & RT
    AP --> PB
    PB --> PM
    PM --> PMM & PMP & PMT
    PB --> EP & HW
    BP --> BF
    BF --> CF

    %% Click events for components
    click FA "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/flask_app.py"
    click DA "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/django_app.py"
    click SA "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/starlette_app.py"
    click CM "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/config.py"
    click OA "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/openapi.py"
    click L10 "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/l10n.py"
    click AC "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/api/coverages.py"
    click AE "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/api/environmental_data_retrieval.py"
    click AP "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/api/processes.py"
    click BP "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/base.py"
    click PG "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/postgresql.py"
    click ES "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/elasticsearch_.py"
    click MG "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/mongo.py"
    click GJ "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/geojson.py"
    click CSV "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/csv_.py"
    click RT "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/provider/rasterio_.py"
    click PB "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/process/base.py"
    click PM "https://github.com/geopython/pygeoapi/tree/master/pygeoapi/process/manager/"
    click PMM "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/process/manager/mongodb_.py"
    click PMP "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/process/manager/postgresql.py"
    click PMT "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/process/manager/tinydb_.py"
    click EP "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/process/echo.py"
    click HW "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/process/hello_world.py"
    click BF "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/formatter/base.py"
    click CF "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/formatter/csv_.py"
    click CM1 "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/models/config.py"
    click OM "https://github.com/geopython/pygeoapi/blob/master/pygeoapi/models/openapi.py"
    click PM1 "https://github.com/geopython/pygeoapi/tree/master/pygeoapi/models/provider/"

    %% Styling
    classDef api fill:#2196F3,stroke:#000,color:#fff
    classDef provider fill:#4CAF50,stroke:#000,color:#fff
    classDef process fill:#FFC107,stroke:#000,color:#000
    classDef formatter fill:#9C27B0,stroke:#000,color:#fff
    classDef adapter fill:#FF9800,stroke:#000,color:#fff
    classDef core fill:#607D8B,stroke:#000,color:#fff
    classDef model fill:#795548,stroke:#000,color:#fff
```
