# cockpit-labs/cockpitce architecture

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

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

## Overview

##### Main components
- Frontend Clients:
- Admin Module: Built with Sencha (ExtJS), found under the Admin directory. It includes multiple overrides, custom views, controllers, and uses Sencha CMD for building.
- Studio Module: Also built with Sencha (ExtJS). Like Admin, it has its own overrides, models, views, and build scripts.
- View Module: This front-end is built with Vue.js (as seen in the View directory with components, App.vue, router, and store). It handles mobile and web viewing for checklists, dashboards, and photo galleries.
- Backend Service:
- Core Module: Located under the Core directory, this is a Symfony-based backend (e.g., using composer files, Symfony configuration files, Command classes, Controllers, Entities, and Services). It provides APIs, implements business logic, handles authentication, and integrates with Keycloak (as seen by KeycloakConnector and keycloak configuration files).
- Infrastructure & Deployment:
- Docker and Docker Compose: The presence of “docker-compose.yml”, “Dockerfile” and relevant scripts shows that containers are used to orchestrate the application. The docker-compose file builds the Cockpit container and likely sets up networking between the backend and possibly database containers.
- Database: While not explicitly shown as a separate file, the README commands show the MySQL database creation and initialization scripts (createCockpitDB.sh) implying a relational database is part of the system.
- Authentication/Authorization:
- Additional Tools & Utilities:
- CLI Commands: The Core module has many console commands (e.g., AddUser, TokenCommand, UpgradeCommand) used for maintenance, initializations, and health checks.
- Dataset: The “dataset” directory with JSON datasets (Templates, Users) is used for initial data seeding or testing.

##### Relationships and Interactions
- Integration with Keycloak for authentication – the backend likely validates credentials from clients through Keycloak, so connect the backend to an external “Keycloak” component.
- Docker Compose is used to orchestrate these components. It is useful to encapsulate the environment and show how containers are networked (e.g., one container for backend, one for the frontend, and one for the database).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The system is divided into clear layers. The front-end clients have their own domain (with Sencha or Vue components), the backend (Symfony “Core”) handles business logic and API exposure, and the database persists data.
- Modular Architecture: Since the project is split into Admin, Studio, and View, each module is responsible for a specific part of the UI. This fosters maintainability and independent builds.
- API-Driven Communication: All frontend modules depend on the Core API. Emphasize the RESTful interactions between these layers.
- Containerization: The use of Docker places an emphasis on containerized, reproducible environments.

##### Final Recommendations
- Every component is clearly labeled.
- Be as detailed as possible without cluttering – capturing all the essential modules and their interactions succinctly is key.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Clients
    subgraph "Frontend Clients"
        A["Admin (Sencha/ExtJS)"]:::frontend
        S["Studio (Sencha/ExtJS)"]:::frontend
        V["View (Vue.js)"]:::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        C["Core API (Symfony)"]:::backend
        CLI["CLI Commands & Maintenance"]:::infra
    end

    %% Authentication Services
    subgraph "Authentication"
        K["Keycloak Server"]:::external
        subgraph "Keycloak Integration"
            KConf["Keycloak Config"]:::external
            KConn["Keycloak Connector"]:::external
        end
    end

    %% Containerization & Deployment
    subgraph "Containerization"
        DCO["Docker Compose Orchestration"]:::infra
        D1["Dockerfile"]:::infra
        D2["docker-compose.yml"]:::infra
        D3["docker-compose.override.yml"]:::infra
    end

    %% Data & Infrastructure
    subgraph "Data & Infrastructure"
        DB["MySQL Database"]:::database
        DBInit["DB Init Script"]:::infra
        DS["Dataset for Seeding/Testing"]:::infra
    end

    %% Connections from Frontend to Backend
    A -->|"REST_API"| C
    S -->|"REST_API"| C
    V -->|"REST_API"| C

    %% CLI to Backend
    CLI -->|"maintenance"| C

    %% Backend to Database and Authentication
    C -->|"data_access"| DB
    C -->|"auth_calls"| K
    DS -->|"data_seeding"| C
    DBInit -->|"init_script"| DB

    %% Keycloak Integration details
    K -->|"configured_by"| KConf
    K -->|"uses"| KConn

    %% Containerization linking: all major containerized components
    DCO --- A
    DCO --- S
    DCO --- V
    DCO --- C
    DCO --- CLI
    DCO --- DB

    %% Styles and Classes
    classDef frontend fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef backend fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef external fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef infra fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef database fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;

    %% Click Events
    click A "https://github.com/cockpit-labs/cockpitce/tree/main/Admin/"
    click S "https://github.com/cockpit-labs/cockpitce/tree/main/Studio/"
    click V "https://github.com/cockpit-labs/cockpitce/tree/main/View/"
    click C "https://github.com/cockpit-labs/cockpitce/tree/main/Core/"
    click CLI "https://github.com/cockpit-labs/cockpitce/tree/main/Core/src/Command/"
    click KConf "https://github.com/cockpit-labs/cockpitce/blob/main/Core/config/api_platform/keycloak.yaml"
    click KConn "https://github.com/cockpit-labs/cockpitce/blob/main/Core/src/CentralAdmin/KeycloakConnector.php"
    click D1 "https://github.com/cockpit-labs/cockpitce/tree/main/Dockerfile"
    click D2 "https://github.com/cockpit-labs/cockpitce/blob/main/docker-compose.yml"
    click D3 "https://github.com/cockpit-labs/cockpitce/blob/main/docker-compose.override.yml"
    click DBInit "https://github.com/cockpit-labs/cockpitce/blob/main/cockpit/createCockpitDB.sh"
    click DS "https://github.com/cockpit-labs/cockpitce/tree/main/dataset/"
```
