# mendersoftware/mender-server architecture

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

- Interactive diagram: https://gitdiagram.com/mendersoftware/mender-server
- Repository: https://github.com/mendersoftware/mender-server

## Overview

##### Main Components

a. Frontend Layer:
- Single React-based frontend application (in /frontend)
- Connection to backend services through API gateway

b. Backend Services (in /backend/services):
- deployments - Handles software deployment management
- deviceauth - Manages device authentication
- deviceconfig - Handles device configuration
- deviceconnect - Manages device connectivity
- inventory - Maintains device inventory
- iot-manager - Manages IoT device integration
- reporting - Handles system reporting
- useradm - User administration
- workflows - Workflow management

c. Infrastructure Components:
- MongoDB (indicated by mongo-related code)
- S3-compatible storage (referenced in storage configurations)
- NATS message broker (seen in client implementations)
- Traefik (reverse proxy, seen in compose/config/traefik)

##### Component Relationships

a. External Interfaces:
- HTTPS endpoints for web UI access
- Device communication interfaces
- Cloud provider integrations (AWS IoT Core, Azure IoT Hub)

b. Internal Communication:
- REST API interactions between services
- Message broker-based communication
- Database access patterns

**┌─────────────────────────────────────────────────────────────┐**
- Client Browser                          │
- ┘
- ↓ HTTPS
**┌─────────────────────────────────────────────────────────────┐**
- Traefik (API Gateway)                    │
- ┘
- ↓ HTTP
**┌─────────────────────────────────────────────────────────────┐**
- Frontend Application                      │
- ┘
- ↓ API
**┌─────────────────────────────────────────────────────────────┐**
- Backend Services                         │
- ┬────────────┬────────────┬────────────┬────────┤
- deviceauth │ deployments│  inventory │ useradm    │  ...   │
- ┴────────────┴────────────┴────────────┴────────┘
- ↕
**┌─────────────────────────────────────────────────────────────┐**
- Infrastructure Layer                       │
- ┬────────────┬────────────┬────────────┬────────┤
- MongoDB   │    NATS    │     S3     │  Redis     │  ...   │
- ┴────────────┴────────────┴────────────┴────────┘

##### Additional Details

- Version information for major components
- Scaling capabilities for services
- Security boundaries and authentication flows
- Enterprise vs. community edition components
- Monitoring and logging flows

##### Documentation

- Brief component descriptions
- Configuration requirements
- Document main data flows

##### Implementation Notes

- Maintain consistent sizing and spacing
- Use clear, readable fonts
- A title and version information
- Creating separate detailed views for complex subsystems

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef gateway fill:#9b59b6,stroke:#8e44ad,color:white

    %% External Layer
    Client["Client Browser"]:::external
    
    %% API Gateway Layer
    Gateway["Traefik API Gateway"]:::gateway
    click Gateway "https://github.com/mendersoftware/mender-server/tree/main/compose/config/traefik"
    
    %% Frontend Layer
    Frontend["Frontend Application"]:::frontend
    click Frontend "https://github.com/mendersoftware/mender-server/tree/main/frontend/src/js/components"
    
    %% Backend Services Layer
    subgraph BackendServices["Backend Services"]
        Deployments["Deployments Service"]:::backend
        DeviceAuth["Device Auth Service"]:::backend
        DeviceConfig["Device Config Service"]:::backend
        DeviceConnect["Device Connect Service"]:::backend
        Inventory["Inventory Service"]:::backend
        IoTManager["IoT Manager Service"]:::backend
        Reporting["Reporting Service"]:::backend
        UserAdmin["User Administration"]:::backend
        Workflows["Workflows Service"]:::backend
    end
    
    click Deployments "https://github.com/mendersoftware/mender-server/tree/main/backend/services/deployments"
    click DeviceAuth "https://github.com/mendersoftware/mender-server/tree/main/backend/services/deviceauth"
    click DeviceConfig "https://github.com/mendersoftware/mender-server/tree/main/backend/services/deviceconfig"
    click DeviceConnect "https://github.com/mendersoftware/mender-server/tree/main/backend/services/deviceconnect"
    click Inventory "https://github.com/mendersoftware/mender-server/tree/main/backend/services/inventory"
    click IoTManager "https://github.com/mendersoftware/mender-server/tree/main/backend/services/iot-manager"
    click Reporting "https://github.com/mendersoftware/mender-server/tree/main/backend/services/reporting"
    click UserAdmin "https://github.com/mendersoftware/mender-server/tree/main/backend/services/useradm"
    click Workflows "https://github.com/mendersoftware/mender-server/tree/main/backend/services/workflows"
    
    %% Infrastructure Layer
    subgraph Infrastructure["Infrastructure Layer"]
        MongoDB[(MongoDB)]:::infrastructure
        NATS["NATS Message Broker"]:::infrastructure
        S3["S3 Storage"]:::infrastructure
        Redis[(Redis)]:::infrastructure
    end
    
    click MongoDB "https://github.com/mendersoftware/mender-server/tree/main/backend/pkg/mongo"
    click NATS "https://github.com/mendersoftware/mender-server/tree/main/backend/pkg/ws/menderclient"
    click S3 "https://github.com/mendersoftware/mender-server/tree/main/backend/services/deployments/storage/s3"
    
    %% Common Backend Components
    subgraph CommonLibs["Common Backend Libraries"]
        RestUtils["REST Utils"]:::backend
        Auth["Authentication"]:::backend
        DBUtils["Database Utils"]:::backend
        APIClient["API Client"]:::backend
    end
    
    click RestUtils "https://github.com/mendersoftware/mender-server/blob/main/backend/pkg/rest.utils"
    click Auth "https://github.com/mendersoftware/mender-server/tree/main/backend/pkg/identity"
    click DBUtils "https://github.com/mendersoftware/mender-server/tree/main/backend/pkg/mongo"
    click APIClient "https://github.com/mendersoftware/mender-server/tree/main/backend/pkg/apiclient"
    
    %% Connections
    Client -->|HTTPS| Gateway
    Gateway -->|HTTP| Frontend
    Frontend -->|API| Gateway
    Gateway --> BackendServices
    
    %% Backend Service Connections
    BackendServices --> CommonLibs
    BackendServices --> Infrastructure
    
    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend Service"]:::backend
        Infra_L["Infrastructure"]:::infrastructure
        External_L["External System"]:::external
        Security_L["Security Component"]:::security
        Gateway_L["Gateway"]:::gateway
    end
```
