# nextcloud/all-in-one architecture

> Architecture diagram of the GitHub repository nextcloud/all-in-one, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nextcloud/all-in-one
- Repository: https://github.com/nextcloud/all-in-one

## Overview

Based on our review of the complete file structure and the detailed README, it’s clear that this project is the Nextcloud All-in-One (AIO) installation and maintenance system. Its purpose is to deploy a full-featured Nextcloud instance with a wide variety of integrated or optional containers that manage things such as the Nextcloud application itself, the web server (Apache/Caddy), Office integration (Collabora/OnlyOffice), Talk (for communication), backups (using BorgBackup), caching (APCu/Redis), database (Postgresql), and numerous other optional services (like ClamAV, Fulltextsearch, Imaginary for previews, Docker Socket Proxy, and even community containers). The Mastercontainer acts as the “brain” (or container orchestrator) that initializes, updates, and maintains all other containers and their communication.

##### Main Components
- Mastercontainer (“nextcloud-aio-mastercontainer”):
– This central component manages container lifecycles (start, stop, update, backup).
– Has special responsibilities like auto-updates, managing the docker socket (via /var/run/docker.sock), and handling backups with Borg.
- Nextcloud Container:
– Runs the actual Nextcloud instance (PHP-FPM, file storage for Nextcloud via docker volume).
– Interacts with a database container and caching container.
- Web Server / Reverse Proxy Container:
– Typically Apache (or an optional Caddy configuration in the mastercontainer) responsible for serving Nextcloud and handling TLS (ports 80, 443, 8443).
- Database Container:
– Postgresql container holding Nextcloud’s database.
- Cache Containers:
– Redis container (and optionally APCu inside the Nextcloud container) for caching, file locking and performance.
- Optional & Additional Containers:
– Containers for Office: Collabora and/or OnlyOffice.
– Containers for Talk (and Talk Recording) with its own specialized TURN server configuration.
– Containers for security (ClamAV for antivirus) and fulltextsearch.
– Containers for image preview generation (Imaginary).
– Containers for Docker Socket Proxy to safely expose Docker API.
– Community containers (for additional features such as BorgBackup Viewer, LDAP service support, pi-hole for local DNS, etc.)
- Additional orchestration / deployment items:
– “compose.yaml”, Helm charts (in nextcloud-aio-helm-chart), and manual-install scripts indicate that the system can be deployed via native docker commands, docker-compose, or Kubernetes via Helm.

##### Relationships and Interactions
- The Mastercontainer connects to the Docker Engine (through the docker socket) to control and update all child containers.
- It sets up a dedicated Docker network (often named “nextcloud-aio”) so that all containers can securely communicate with each other using their hostnames.
- The Nextcloud container communicates with the database container (using Postgresql credentials – see config files in “php” and “app”) and the Redis container for caching.
- The web interface (built using PHP, with files present in the “php/public” and “app/templates”) serves both the Nextcloud front-end and the AIO administration interface.
- Optional containers “plug into” this network on demand; for example, the “talk” container will connect (and require exposed ports such as 3478/TCP and UDP) while the backup solution integrates BorgBackup processes.
- The system also leverages volumes mounted for persistence: one volume for the mastercontainer configuration, another for Nextcloud’s data (either a docker volume or mounted host path), and volumes for database storage.

##### Detailed Step-by-Step Suggestions for the Engineer
- External components outside this boundary:
– A connection from “Backup / Borg repository” to the Mastercontainer for backup tasks.

– The central role of the Mastercontainer managing a series of Docker containers.
– The segregation between core Nextcloud services (web server, database, caching, file storage) and optional service containers.
– The use of docker networks, mounted volumes, environment variables, and external connections (reverse proxy settings, TLS termination, backup connectivity).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Nodes
    Internet["Internet/Client"]:::external
    DockerEngine["Docker Engine\n(/var/run/docker.sock)"]:::external
    BackupRepo["Backup Repository"]:::external

    %% Docker Network Subgraph
    subgraph "Docker Network: nextcloud-aio"
        OMC["Mastercontainer"]:::orchestration

        subgraph "Core Services"
            NC["Nextcloud Container"]:::service
            WS["Web Server/Reverse Proxy"]:::service
            DB["Database (Postgresql)"]:::service
            RC["Redis Cache"]:::service
        end

        subgraph "Optional Services"
            O1["Office (Collabora)"]:::optional
            O2["Office (OnlyOffice)"]:::optional
            TC["Talk Container"]:::optional
            TRC["Talk Recording Container"]:::optional
            BB["Backup Container (BorgBackup)"]:::optional
            SC["Security (ClamAV)"]:::optional
            FT["Fulltextsearch"]:::optional
            IP["Image Preview (Imaginary)"]:::optional
            DSP["Docker Socket Proxy"]:::optional
            CC["Community Containers"]:::optional
        end

        subgraph "Deployment Artifacts"
            H["Helm Deployment Artifacts"]:::external
            CY["Compose Deployment File"]:::external
        end
    end

    %% External Connections
    Internet -->|"TLStermination"| WS
    BackupRepo -->|"backup_tasks"| OMC
    OMC -->|"docker_socket"| DockerEngine

    %% Orchestration Control Connections from Mastercontainer
    OMC -->|"control"| NC
    OMC -->|"control"| WS
    OMC -->|"control"| DB
    OMC -->|"control"| RC
    OMC -->|"control"| O1
    OMC -->|"control"| O2
    OMC -->|"control"| TC
    OMC -->|"control"| TRC
    OMC -->|"control"| BB
    OMC -->|"control"| SC
    OMC -->|"control"| FT
    OMC -->|"control"| IP
    OMC -->|"control"| DSP
    OMC -->|"control"| CC

    %% Communication Between Core Services
    NC -->|"data_access"| DB
    NC -->|"cache"| RC
    WS -->|"serves"| NC

    %% Deployment Artifacts Trigger
    H -->|"deploy"| OMC
    CY -->|"deploy"| OMC

    %% Click Events
    click OMC "https://github.com/nextcloud/all-in-one/tree/main/Containers/mastercontainer"
    click NC "https://github.com/nextcloud/all-in-one/tree/main/Containers/nextcloud"
    click WS "https://github.com/nextcloud/all-in-one/tree/main/Containers/apache"
    click DB "https://github.com/nextcloud/all-in-one/tree/main/Containers/postgresql"
    click RC "https://github.com/nextcloud/all-in-one/tree/main/Containers/redis"
    click O1 "https://github.com/nextcloud/all-in-one/tree/main/Containers/collabora"
    click O2 "https://github.com/nextcloud/all-in-one/tree/main/Containers/onlyoffice"
    click TC "https://github.com/nextcloud/all-in-one/tree/main/Containers/talk"
    click TRC "https://github.com/nextcloud/all-in-one/tree/main/Containers/talk-recording"
    click BB "https://github.com/nextcloud/all-in-one/tree/main/Containers/borgbackup"
    click SC "https://github.com/nextcloud/all-in-one/tree/main/Containers/clamav"
    click FT "https://github.com/nextcloud/all-in-one/tree/main/Containers/fulltextsearch"
    click IP "https://github.com/nextcloud/all-in-one/tree/main/Containers/imaginary"
    click DSP "https://github.com/nextcloud/all-in-one/tree/main/Containers/docker-socket-proxy"
    click CC "https://github.com/nextcloud/all-in-one/tree/main/community-containers"
    click H "https://github.com/nextcloud/all-in-one/tree/main/nextcloud-aio-helm-chart"
    click CY "https://github.com/nextcloud/all-in-one/blob/main/compose.yaml"

    %% Styles
    classDef orchestration fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#186A3B,stroke-width:2px;
    classDef optional fill:#FAD7A0,stroke:#7D6608,stroke-dasharray: 5,5,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#2E86C1,stroke-dasharray: 4,2,stroke-width:2px;
    class OMC orchestration;
    class NC,WS,DB,RC service;
    class O1,O2,TC,TRC,BB,SC,FT,IP,DSP,CC optional;
    class Internet,DockerEngine,BackupRepo,H,CY external;
```
