# mdwikicx/cx-1 architecture

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

- Interactive diagram: https://gitdiagram.com/mdwikicx/cx-1
- Repository: https://github.com/mdwikicx/cx-1

## Overview

##### Main Components
- Frontend (UI Layer):
– Represented by the “app” directory and its sub-directories (src, components, store, router, etc.).
– Built with Vue.js with numerous Vue components (e.g., CXDashboard, SXEditor, SXPublisher) and libraries (mediawiki.ui components from “app/src/lib/mediawiki.ui”).
– Uses modern UI patterns and state management (Vuex) to handle translation workflows, language selectors, and suggestions.

- Backend (API & Business Logic Layer):
– Located mainly in the “includes” directory plus additional PHP modules and templates (found in “modules”, “minT”, and other PHP-related directories).
– Implements MediaWiki-specific API endpoints (see files under includes/ActionApi/) and hook handlers managing translation events.
– Contains service classes (in includes/Service and includes/Store) that handle translation operations, notifications, and integration with other MediaWiki components.

- Database and Schema:
– SQL scripts in the “sql” folder show migrations, schema changes, and table definitions that support the translation data model.
– These scripts clarify how translation units, draft/published translation records, and notification logs are managed.

- External Services and Integrations:
– Integration with MediaWiki’s Parsoid (ParsoidClient.php), machine translation APIs (under modules/mw.cx.MachineTranslationService.js and similar files), and Chart.js (included as a dependency).
– Event logging and notifications likely interface with external logging or MediaWiki’s Echo notification system.

##### Out the Relationships and Interactions
– API calls are routed through the Vuex store actions and routed via the “router” configuration.
– These calls hit the backend (PHP API endpoints in includes/ActionApi and modules) to perform create, update, and delete operations.

- Communication between the backend and database:
– Backend services (in includes/Service, includes/Store) interact with the database using the SQL schema defined in the “sql” folder.

- Integration with external services:

##### Architectural Patterns and Dependencies
- Frontend:
– Use of an SPA pattern with separation of UI, state management, and routing.
– The frontend is modular, with clearly separated components (each translation tool has its own Vue file and supporting JavaScript logic).

- Backend:
– Many modules follow a service/handler pattern to plug into MediaWiki’s hook system.
– The use of API endpoints and DTO (Data Transfer Objects) in includes/DTO indicates clear separation between internal models and API communications.

- Dependency Flow:
– How front-end components rely on mediawiki.ui libraries and custom UI components for presenting translation interfaces.
– How backend modules rely on the MediaWiki framework’s hook system and external APIs.

## Diagram (Mermaid)

```mermaid
graph TD
    U("User"):::actor

    subgraph "ContentTranslation Frontend (Vue SPA)"
        A1("Main Vue Components"):::frontend
        A2("UI Components"):::frontend
        A3("Vuex Store"):::frontend
        A4("Router"):::frontend
    end

    subgraph "Backend Layer (MediaWiki Extension)"
        B1("API Endpoints & Hook Handlers"):::backend
        B2("Service Classes"):::backend
    end

    subgraph "External Services & Integrations"
        E1("Machine Translation Service"):::external
        E2("Parsoid Integration"):::external
    end

    D1("Database Schema & SQL Scripts"):::database

    U -->|"initiates"| A1
    A4 -->|"API_request"| B1
    B1 -->|"DB_operations"| D1
    B1 -->|"calls"| E1
    B1 -->|"calls"| E2

    click A1 "https://github.com/mdwikicx/cx-1/tree/main/app/src"
    click A2 "https://github.com/mdwikicx/cx-1/tree/main/app/src/components"
    click A3 "https://github.com/mdwikicx/cx-1/tree/main/app/src/store"
    click A4 "https://github.com/mdwikicx/cx-1/tree/main/app/router"
    click B1 "https://github.com/mdwikicx/cx-1/tree/main/includes/ActionApi"
    click B2 "https://github.com/mdwikicx/cx-1/tree/main/includes/Service"
    click D1 "https://github.com/mdwikicx/cx-1/tree/main/sql/"
    click E1 "https://github.com/mdwikicx/cx-1/blob/main/modules/mw.cx.MachineTranslationService.js"
    click E2 "https://github.com/mdwikicx/cx-1/blob/main/includes/ParsoidClient.php"

    classDef actor fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef database fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
```
