# yaya2devops/gopencti architecture

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

- Interactive diagram: https://gitdiagram.com/yaya2devops/gopencti
- Repository: https://github.com/yaya2devops/gopencti

## Overview

##### Main Components
- Cloud/Infrastructure Layer: Represent the Azure VM hosting the platform. Include network/firewall considerations (as specified with the port rules for Portainer, OpenCTI, SSH, HTTPS, etc.).
- Container Management & Orchestration: Show Docker Engine deployment, Docker Swarm initialization, and Portainer as the web interface for managing Docker stacks.
- Core Service Containers:
- OpenCTI: The main application container (running on port 8080) that provides the user interface and business logic.
- Worker: Multiple instances (replicated) responsible for running background tasks and asynchronous processing.
- Supporting or Data Layer Containers:
- Redis: Caching and message queuing service.
- Elasticsearch: Provides full-text search and indexing capabilities.
- MinIO: Object storage engine for files and attachments.
- RabbitMQ: Message broker for orchestrating asynchronous communication.
- Connector Containers: Various import/export connectors (like connector-import-document, connector-export-file-stix, connector-export-file-csv, connector-export-file-txt, and others for MITRE and Cybercrime Tracker). They integrate by communicating with the OpenCTI instance to either import data or export content in specific formats.

##### Component Relationships and Data Flows
- Infrastructure Layer: External clients (administrators/users) access the Azure VM via defined ports (e.g., 8080 for OpenCTI and 9900 for Portainer).
- Orchestration framework (Docker Swarm) that ties these components together, and indicate that Portainer is used for deployment and management.

##### Architectural Patterns and Technologies
- Containerization and Microservices: Emphasize separation of concerns among discrete containers, each handling specific tasks (application logic, caching, search, messaging, storage, connectors).
- Configuration and Environment Management: Note that environment variables (captured in the opencti.env file) are critical for secure, dynamic configuration of each container.
- Infrastructure as Code: The presence of Docker Compose YAML files and GitHub workflows (.github/workflows) indicates that deployment and CI/CD automation are part of the overall system design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    External_Users["External Users"] 
    Azure_VM["Azure VM (Linux-Based Azure)"]
    Docker_Swarm["Docker Swarm (Orchestration)"]
    Portainer["Portainer (Management UI)"]

    External_Users -->|"SSH/HTTPS"| Azure_VM
    Azure_VM -->|"Hosts Containers"| Docker_Swarm
    Docker_Swarm -->|"Managed by"| Portainer

    subgraph "Containerized Services"
        subgraph "Core Platform"
            opencti["OpenCTI Platform (Port 8080)"]
            worker["Worker (Replicated)"]
        end
        subgraph "Supporting Services"
            redis["Redis Cache"]
            es["Elasticsearch Index"]
            minio["MinIO Object Storage"]
            rabbitmq["RabbitMQ Broker"]
        end
        subgraph "Connectors"
            c_import["Connector: Import Document"]
            c_stix["Connector: Export File STIX"]
            c_csv["Connector: Export File CSV"]
            c_txt["Connector: Export File TXT"]
            c_mitre["Connector: MITRE"]
            c_cyber["Connector: Cybercrime Tracker"]
        end
    end

    %% Relationships within Containerized Services
    opencti -->|"uses"| redis
    opencti -->|"indexes"| es
    opencti -->|"stores"| minio
    opencti -->|"queues"| rabbitmq
    worker -->|"processes_tasks_for"| opencti

    c_import -->|"integrates_with"| opencti
    c_stix -->|"integrates_with"| opencti
    c_csv  -->|"integrates_with"| opencti
    c_txt  -->|"integrates_with"| opencti
    c_mitre -->|"integrates_with"| opencti
    c_cyber -->|"integrates_with"| opencti

    %% Project Repository Subgraph
    subgraph "Project Repository"
        CI_CD["CI/CD & IaC"]
        README["README.md"]
        Config[" _config.yaml"]
        Assets["Static Assets"]
    end

    CI_CD -->|"deploys_via"| Docker_Swarm

    %% Click Events for Project Files
    click CI_CD "https://github.com/yaya2devops/gopencti/tree/main/.github/workflows"
    click README "https://github.com/yaya2devops/gopencti/blob/main/README.md"
    click Config "https://github.com/yaya2devops/gopencti/blob/main/_config.yaml"
    click Assets "https://github.com/yaya2devops/gopencti/tree/main/assets"

    %% Styles
    class External_Users external
    class Azure_VM,Docker_Swarm,Portainer infra
    class opencti,worker core
    class redis,es,minio,rabbitmq support
    class c_import,c_stix,c_csv,c_txt,c_mitre,c_cyber connectors
    class CI_CD,README,Config,Assets project

    classDef external fill:#FFEECC,stroke:#333,stroke-width:2px;
    classDef infra fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef core fill:#CCCCFF,stroke:#333,stroke-width:2px;
    classDef support fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef connectors fill:#D0E1F9,stroke:#333,stroke-width:2px;
    classDef project fill:#E6E6FA,stroke:#333,stroke-width:2px;
```
