# cockpit-hq/cockpit architecture

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

- Interactive diagram: https://gitdiagram.com/cockpit-hq/cockpit
- Repository: https://github.com/cockpit-hq/cockpit

## Overview

##### Main System Components

a) Frontend Layer:
- Web Interface (modules/App/assets)
- Vue.js Components (modules/*/assets/vue-components)
- Admin Interface (modules/*/admin.php)

b) Application Layer:
- Core Framework (lib/Lime)
- Module System
- App Module (core functionality)
- Content Module (content management)
- Assets Module (media handling)
- System Module (system management)
- Finder Module (file management)
- Updater Module (system updates)

c) Storage Layer:
- Database Abstraction (lib/MongoHybrid)
- MongoDB Support
- SQLite Support (MongoLite)
- File Storage (storage/)
- Cache
- Uploads
- Temporary Files
- Logs

d) Integration Layer:
- REST API (modules/*/api.php)
- GraphQL API (modules/App/GraphQL)
- CLI Interface (modules/*/cli.php)

##### Component Relationships

- HTTP/HTTPS requests from clients to the application
- Database interactions between application and storage layers
- API endpoints connecting to the application core
- File system operations between application and storage
- Module interactions through the core framework

##### Architectural Patterns to Highlight

Patterns:
- MVC Architecture (Controller/View/Helper pattern in modules)
- Module-based Architecture (independent modules with their own assets/controllers)
- Hybrid Database Architecture (MongoDB/SQLite abstraction)
- REST/GraphQL API Architecture

##### Implementation Details

Technical specifications:
- PHP 8.2+ requirement
- Database options (SQLite/MongoDB)
- Required extensions (GD, PDO)
- Docker support
- Web server requirements (mod_rewrite, mod_versions)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WEB["Web Browser"]
        CLI["CLI Interface"]
    end

    subgraph "Frontend Layer"
        WEBUI["Web Interface"]:::frontend
        VUECOMP["Vue.js Components"]:::frontend
        ADMIN["Admin Interface"]:::frontend
    end

    subgraph "Integration Layer"
        REST["REST API"]:::api
        GRAPHQL["GraphQL API"]:::api
        CLIINT["CLI Interface"]:::api
    end

    subgraph "Application Layer"
        CORE["Core Framework"]:::core
        
        subgraph "Module System"
            APP["App Module"]:::module
            CONTENT["Content Module"]:::module
            ASSETS["Assets Module"]:::module
            SYSTEM["System Module"]:::module
            FINDER["File Management"]:::module
            UPDATER["Updater Module"]:::module
        end

        AUTH["Authentication System"]:::security
        ASSETPROC["Asset Processing"]:::utility
        SEARCH["Search Functionality"]:::utility
        CACHE["Caching System"]:::utility
    end

    subgraph "Storage Layer"
        DB["Database Abstraction"]:::storage
        MONGO["MongoDB"]:::db
        SQLITE["SQLite"]:::db
        FILES["File Storage"]:::storage
        CACHEDIR["Cache Storage"]:::storage
        UPLOADS["Uploads"]:::storage
        TEMP["Temporary Files"]:::storage
        LOGS["Logs"]:::storage
    end

    %% Client to Frontend
    WEB --> WEBUI
    WEB --> ADMIN
    CLI --> CLIINT

    %% Frontend to Integration
    WEBUI --> REST
    WEBUI --> GRAPHQL
    VUECOMP --> REST
    ADMIN --> REST

    %% Integration to Application
    REST --> CORE
    GRAPHQL --> CORE
    CLIINT --> CORE

    %% Core to Modules
    CORE --> APP
    CORE --> CONTENT
    CORE --> ASSETS
    CORE --> SYSTEM
    CORE --> FINDER
    CORE --> UPDATER

    %% Module Dependencies
    APP --> AUTH
    ASSETS --> ASSETPROC
    CONTENT --> SEARCH
    SYSTEM --> CACHE

    %% Storage Connections
    DB --> MONGO
    DB --> SQLITE
    FILES --> CACHEDIR
    FILES --> UPLOADS
    FILES --> TEMP
    FILES --> LOGS

    %% Application to Storage
    CORE --> DB
    CORE --> FILES
    ASSETPROC --> FILES
    CACHE --> CACHEDIR

    %% Styling
    classDef frontend fill:#3498db
    classDef api fill:#9b59b6
    classDef core fill:#2ecc71
    classDef module fill:#27ae60
    classDef security fill:#e74c3c
    classDef utility fill:#f1c40f
    classDef storage fill:#e67e22
    classDef db fill:#95a5a6

    %% Click Events
    click CORE "https://github.com/Cockpit-HQ/Cockpit/blob/develop/lib/Lime/App.php"
    click DB "https://github.com/Cockpit-HQ/Cockpit/tree/develop/lib/MongoHybrid/"
    click FILES "https://github.com/Cockpit-HQ/Cockpit/tree/develop/storage/"
    click AUTH "https://github.com/Cockpit-HQ/Cockpit/blob/develop/modules/App/Controller/Auth.php"
    click ASSETPROC "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/Assets/Utils"
    click VUECOMP "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/App/assets/vue-components/"
    click ADMIN "https://github.com/Cockpit-HQ/Cockpit/blob/develop/modules/App/admin.php"
    click REST "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/App/RestApi/"
    click GRAPHQL "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/App/GraphQL/"
    click SEARCH "https://github.com/Cockpit-HQ/Cockpit/tree/develop/lib/IndexHybrid/"
    click CACHE "https://github.com/Cockpit-HQ/Cockpit/blob/develop/lib/Lime/Helper/Cache.php"
    click CONTENT "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/Content/Controller/"
    click FINDER "https://github.com/Cockpit-HQ/Cockpit/blob/develop/modules/Finder/Controller/Finder.php"
    click SYSTEM "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/System/Controller/"
    click UPDATER "https://github.com/Cockpit-HQ/Cockpit/tree/develop/modules/Updater/Controller/"
```
