# ente-io/ente architecture

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

- Interactive diagram: https://gitdiagram.com/ente-io/ente
- Repository: https://github.com/ente-io/ente

## Overview

This monorepo is a complex, multi-product, multi-platform open source ecosystem that delivers a fully end‐to‐end encrypted cloud platform. Its purpose is to support applications like Ente Photos (a cloud photo storage solution that emphasizes privacy, replication, and features like face detection and semantic search) and Ente Auth (an encrypted two‐factor authenticator), along with several other client apps (mobile for iOS/Android/F‑Droid, desktop, web, CLI, etc.) and a backend server that drives all the products.

##### Main components
● Client/Frontends:
– Mobile apps (Android, iOS, F-Droid, etc.)
– Web applications (Ente Auth, Ente Photos web app, and related packages)
– Desktop application (Electron-based)
– CLI (command-line tool)
– Other platform-specific clients (Linux, macOS, Windows)
● Backend/Server:
– Core server component written in Go (directory “server”) that exposes APIs, handles authentication, file operations, encryption, storage bonus, push notifications, etc.
– API endpoints and controllers that manage modules (authenticator, file data, collection, encryption, billing, family, etc.)
● Shared Modules/Library/Packages:
– Common libraries and packages extracted in “packages” and “lib” directories for shared cryptography, UI components, network utilities, and domain models.
● Infrastructure:
– Infrastructure scripts and configurations in “infra” (for deployments, mail templates, ML, CDN, and external integrations such as Wasabi, listmonk, and other cloud services)
– CI/CD workflows (in .github/workflows) that automate builds, releases, and deployments.
● Documentation and Community:
– Documentation (“docs”), architecture details (“architecture”), and supporting material like readme, supporting guides, and community resources.

##### Relationships and Interactions
● Client apps (mobile, web, desktop, CLI) communicate with the backend server via RESTful or similar APIs. Illustrate directional data flows where users make requests (e.g., sign in, upload photos, manage authentication codes) that go to the server.
● The server handles core business logic such as end-to-end encryption, file storage, processing (e.g., ML for photos, face detection, semantic search), user sessions, and push notifications. It uses microservice-style segregation in its code (with separate packages/controllers for authenticator, billing, file management, etc.).
● Shared libraries and packages provide cross-cutting functionality (crypto implementations, internationalization, UI libraries, error handling) that are consumed by both client apps and possibly by the server.
● Infrastructure components support deployment (Dockerfiles, Kubernetes/compose files, migration scripts) and integrate with external systems (storage backends, CDN services, mail services).

##### Architectural Patterns and Design Principles
● Modular Monorepo: Although all components live in one repository, they are organized into distinct directories for mobile, web, server, CLI, etc. This separation reflects both ownership and clear boundaries between the different layers.
● Multi-Tier Architecture: The architecture spans presentation (client apps), business logic (server controllers, API endpoints), data access/storage (databases, file systems, remote storage services, backups), and cross-cutting concerns (encryption, error reporting, logging).
● End-to-End Encryption: Backbone design principle – ensure that data encryption, decryption, and cryptographic key management are clearly encapsulated as shared services both on the client side (using shared crypto libraries) and on the server side.
● Microservices-like internal organization: The server codebase itself is divided into controllers, repo (data access), middleware (authentication, rate limiting, logging), and external integrations with dedicated packages for handling services such as push notifications and share functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications
    subgraph "Client Apps"
        Mobile["Mobile Client App"]:::client
        Web["Web Client Applications"]:::client
        Desktop["Desktop Client Application"]:::client
        CLI["CLI Client Application"]:::client
        Others["Other Platform Clients\n(Linux, macOS, Windows)"]:::client
    end

    %% API Layer
    subgraph "API Layer"
        APIGate["API Gateway"]:::api
    end

    %% Backend Services
    subgraph "Backend Services"
        API["API Endpoints/Controllers"]:::server
        AuthFile["Authentication & File Management"]:::server
        Encryption["Encryption & Cryptographic Services"]:::server
        Notifications["Push Notifications & Billing"]:::server
    end

    %% Shared Modules and Libraries
    subgraph "Shared Modules & Libraries"
        Shared["Shared Libraries/Packages"]:::shared
    end

    %% Infrastructure and Operations
    subgraph "Infrastructure & Operations"
        Infra["Infrastructure & Deployments"]:::infra
        CICD["CI/CD Pipelines"]:::infra
        External["External Systems\n(Cloud Storage, Email, ML, CDN)"]:::external
    end

    %% Documentation & Community
    subgraph "Documentation & Community"
        Docs["Documentation & Architecture"]:::docs
    end

    %% Connections from Clients to API Gateway
    Mobile -->|"calls"| APIGate
    Web -->|"calls"| APIGate
    Desktop -->|"calls"| APIGate
    CLI -->|"calls"| APIGate
    Others -->|"calls"| APIGate

    %% API Gateway routes to Backend Services
    APIGate -->|"routes"| API

    %% Backend internal flow
    API -->|"invokes"| AuthFile
    API -->|"invokes"| Encryption
    API -->|"invokes"| Notifications

    %% Shared Modules usage by Clients and Backend
    Mobile -->|"uses"| Shared
    Web -->|"uses"| Shared
    Desktop -->|"uses"| Shared
    CLI -->|"uses"| Shared
    API -->|"uses"| Shared
    AuthFile -->|"uses"| Shared
    Encryption -->|"uses"| Shared
    Notifications -->|"uses"| Shared

    %% Backend integration with Infrastructure
    API -->|"deploys_to"| Infra
    Infra -->|"integrates_with"| External
    CICD -->|"automates"| Infra

    %% Documentation support (dotted connections)
    Docs -.->|"guides"| Mobile
    Docs -.->|"guides"| Web
    Docs -.->|"guides"| API
    Docs -.->|"guides"| Infra

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef api fill:#E6E6FA,stroke:#000,stroke-width:1px;
    classDef server fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef shared fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef infra fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef docs fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:1px;

    %% Click Events for component mapping
    click Mobile "https://github.com/ente-io/ente/tree/main/mobile/"
    click Desktop "https://github.com/ente-io/ente/tree/main/desktop/"
    click Web "https://github.com/ente-io/ente/tree/main/web/"
    click CLI "https://github.com/ente-io/ente/tree/main/cli/"
    click API "https://github.com/ente-io/ente/tree/main/server/"
    click Shared "https://github.com/ente-io/ente/tree/main/auth/lib"
    click Shared "https://github.com/ente-io/ente/tree/main/mobile/lib"
    click Shared "https://github.com/ente-io/ente/tree/main/web/packages/"
    click Infra "https://github.com/ente-io/ente/tree/main/infra/"
    click CICD "https://github.com/ente-io/ente/tree/main/.github/workflows"
    click Docs "https://github.com/ente-io/ente/tree/main/docs/"
    click Docs "https://github.com/ente-io/ente/tree/main/architecture/"
```
