# csgroup-oss/sharinghub-server architecture

> Architecture diagram of the GitHub repository csgroup-oss/sharinghub-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/csgroup-oss/sharinghub-server
- Repository: https://github.com/csgroup-oss/sharinghub-server

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Application Layer:
- FastAPI Application Server
- Authentication Service (app/auth)
- STAC API Service (app/stac)
- Store Service (app/store)
- Providers Service (app/providers)

b) External Integration Layer:
- GitLab Integration
- Other potential providers (extensible architecture)

c) Utility Services:
- Caching System
- Configuration Management
- Geo Utils
- HTTP Client

**Client Layer**

- ▼
**API Gateway (FastAPI)**

- ┬─────────────────┬────────────────┐
- ▼                     ▼                 ▼                ▼
**Auth Service         STAC Service     Store Service    Providers Service**

- ▼
- Provider Clients

- ▼
- (GitLab, etc.)
- ▼                     ▼                 ▼
**Shared Utilities (Cache, Config, Geo, HTTP)**

##### Specific Implementation Details

a) Authentication Flow:
- How auth/api.py and auth/views.py interact
- Dependency injection points (auth/depends.py)

b) STAC Implementation:
- Three main STAC endpoints (build, category, search)
- Connection to store service

c) Provider Integration:
- Demonstrate the abstract base client (_base.py)
- Concrete implementation (gitlab.py)
- Proxy and download capabilities

##### Additional Elements

Supporting components:
- Configuration management (config.yaml)
- Cache mechanism
- Gunicorn server configuration
- Docker container boundary

##### Deployment Context

Show:
- Docker container boundary
- Environment configuration flow
- External service connections

Remember to:
- Use clear labels for all components
- Version/git information
- Configuration flow from .env and config.yaml

This system design should provide a clear understanding of how the SharingHub Server components interact while maintaining the appropriate level of detail for a principal software engineer to understand the system architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph API_Gateway
        API[FastAPI Server]:::api
        Router[API Router]:::api
    end

    subgraph Core_Services
        Auth[Authentication Service]:::core
        STAC[STAC API Service]:::core
        Store[Store Service]:::core
        Prov[Providers Service]:::core
    end

    subgraph Auth_Components
        AuthAPI[Auth API]:::auth
        AuthViews[Auth Views]:::auth
        AuthDep[Auth Dependencies]:::auth
    end

    subgraph STAC_Components
        STACBuild[Build API]:::stac
        STACCat[Category API]:::stac
        STACSearch[Search API]:::stac
    end

    subgraph Store_Components
        StoreViews[Store Views]:::store
        StoreSettings[Store Settings]:::store
    end

    subgraph Provider_Components
        BaseClient[Base Client]:::provider
        GitLabClient[GitLab Client]:::provider
        Download[Download Handler]:::provider
        Proxy[Proxy Handler]:::provider
        Checker[Provider Checker]:::provider
    end

    subgraph Utilities
        Cache[Cache System]:::util
        Config[Configuration]:::util
        Geo[Geo Utils]:::util
        HTTP[HTTP Client]:::util
    end

    %% Relationships
    CL --> API
    API --> Router
    Router --> |routes| Auth
    Router --> |routes| STAC
    Router --> |routes| Store
    Router --> |routes| Prov

    Auth --> AuthAPI
    Auth --> AuthViews
    Auth --> AuthDep

    STAC --> STACBuild
    STAC --> STACCat
    STAC --> STACSearch

    Store --> StoreViews
    Store --> StoreSettings

    Prov --> BaseClient
    BaseClient --> GitLabClient
    Prov --> Download
    Prov --> Proxy
    Prov --> Checker

    %% Utility Dependencies
    Auth -.-> Cache
    STAC -.-> Cache
    Store -.-> Cache
    Prov -.-> Cache

    Auth -.-> Config
    STAC -.-> Config
    Store -.-> Config
    Prov -.-> Config

    STAC -.-> Geo
    Store -.-> Geo

    Prov -.-> HTTP

    %% Click Events
    click API "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/main.py"
    click Router "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/router.py"
    click Auth "https://github.com/csgroup-oss/sharinghub-server/tree/main/app/auth/"
    click AuthAPI "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/auth/api.py"
    click AuthViews "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/auth/views.py"
    click AuthDep "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/auth/depends.py"
    click STAC "https://github.com/csgroup-oss/sharinghub-server/tree/main/app/stac/"
    click STACBuild "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/stac/api/build.py"
    click STACCat "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/stac/api/category.py"
    click STACSearch "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/stac/api/search.py"
    click Store "https://github.com/csgroup-oss/sharinghub-server/tree/main/app/store/"
    click StoreViews "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/store/views.py"
    click StoreSettings "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/store/settings.py"
    click Prov "https://github.com/csgroup-oss/sharinghub-server/tree/main/app/providers/"
    click BaseClient "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/providers/client/_base.py"
    click GitLabClient "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/providers/client/gitlab.py"
    click Download "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/providers/views/download.py"
    click Proxy "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/providers/views/proxy.py"
    click Checker "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/providers/views/checker.py"
    click Cache "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/utils/cache.py"
    click Config "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/utils/config.py"
    click Geo "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/utils/geo.py"
    click HTTP "https://github.com/csgroup-oss/sharinghub-server/blob/main/app/utils/http.py"

    %% Styles
    classDef api fill:#1E88E5,color:white
    classDef core fill:#0D47A1,color:white
    classDef auth fill:#1565C0,color:white
    classDef stac fill:#0277BD,color:white
    classDef store fill:#00838F,color:white
    classDef provider fill:#2E7D32,color:white
    classDef util fill:#FFA000,color:black
```
