# skinatech/orfeong_backend architecture

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

- Interactive diagram: https://gitdiagram.com/skinatech/orfeong_backend
- Repository: https://github.com/skinatech/orfeong_backend

## Overview

##### Main Components
- API Layer: Located in the “api” directory, this component contains its own controllers, models, views (including version modules such as “api/modules/version1”), and configuration files. It is responsible for exposing REST endpoints and handling specific document management tasks (for example, radication, notification, external client interactions, dynamic forms, etc.).
- Backend: Found in the “backend” directory, this is the administrative or management interface. It follows the MVC pattern with distinct controllers, models, views, and configuration files. It likely handles administration, configuration, and management tasks and integrates heavily with the common components.
- Frontend: Placed in the “frontend” directory, this component serves the public or end-user interface (e.g., for registration of PQRS, consultation, or displaying documents). It too follows MVC, with its own controllers, models, views, and web assets.
- Common Components: The “common” directory holds shared business logic, configuration files, models (such as the User model and login forms), shared fixtures, and widgets that are used across API, frontend, and backend.
- Console: The “console” directory encapsulates CLI-based operations such as migrations, scheduled tasks, and any command-line utilities required for deployment or maintenance.
- Deployment and Infrastructure: Beyond the code itself, notice that there are Dockerfiles (in api, backend and frontend), Vagrant configurations, and docker-compose.yml – these indicate containerization and virtualized development environments which are key to deployment.
- Documentation & Testing: Several testing directories (under tests for api, frontend, and backend) and documentation paths (like “api/documentacion” and “vagrant” for provisioning) should be factored in to show integration and quality control aspects.

##### Relationships and Interactions
- The UI (both backend administrative UI and frontend public UI) interacts with their respective controllers but also shares common logic and models.
- The API layer exposes endpoints (e.g., via its modules in “version1”) which may be consumed by external clients or even by the frontend when asynchronous data exchange is needed.
- All three layers (api, backend, frontend) rely on the shared “common” components for consistent business rules, configurations, and data models.
- The console application manages the database migrations and other background tasks that ensure the system remains synchronized.

##### Architectural Patterns and Design Principles
- MVC Pattern: Since the project is developed using the Yii2 framework, each layer (api, backend, frontend) adheres to the Model-View-Controller pattern for separation of concerns.
- Modular Design: The API’s use of modules (e.g., “version1”) indicates a modular architecture that facilitates versioning and clear separation of business functionalities.
- Layered Separation: There is a clear separation between presentation (frontend and backend), business logic (common and models), and data operations (migrations, database interactions).
- Containerization & Virtualization: Docker and Vagrant configurations show an orientation towards modern deployment practices.

##### Relevant Technologies and Libraries
- Yii2 Framework (PHP-based)
- Docker and Vagrant (for containerized and virtualized setups)
- Codeception (for testing, seen in the test directories)
- Likely relational database systems (MySQL/MariaDB, as suggested by scripts and documentation files)
- A broad set of web assets (CSS, JS, fonts used for frontend UI – e.g., Font Awesome, Google Fonts, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Layer
    INFRA["Deployment & Infrastructure\n(Docker, Vagrant, Compose)"]:::infrastructure

    %% Web Interfaces Subgraph
    subgraph "Web Interfaces"
        FE["Frontend (MVC)"]:::frontend
        BE["Backend (MVC)"]:::backend
    end

    %% API Layer
    API["API Layer (REST, Modules: version1)"]:::api

    %% Common Components (Shared Business Logic & Models)
    COMMON["Common Components"]:::common

    %% External Clients
    EXTERNAL["External Clients/Systems"]:::external

    %% Console (CLI and Migrations)
    CONSOLE["Console (CLI, Migrations)"]:::console

    %% Database
    DB["Database"]:::database

    %% Documentation & Testing Subgraph
    subgraph "Documentation & Testing"
        API_TESTS["API Tests"]:::doc
        API_DOC["API Documentation"]:::doc
        BE_TESTS["Backend Tests"]:::doc
        FE_TESTS["Frontend Tests"]:::doc
    end

    %% Connections
    %% Infrastructure deploys to main components
    INFRA --> FE
    INFRA --> BE
    INFRA --> API
    INFRA --> CONSOLE

    %% Web Interfaces interact with shared components
    FE -->|"uses"| COMMON
    BE -->|"uses"| COMMON

    %% API Layer interactions
    API -->|"uses"| COMMON
    API -->|"exposes"| EXTERNAL

    %% Console operations on Database
    CONSOLE -->|"migrates"| DB

    %% API Layer testing and docs
    API -->|"verified-by"| API_TESTS
    API -->|"documented-in"| API_DOC
    BE -->|"tested-by"| BE_TESTS
    FE -->|"tested-by"| FE_TESTS

    %% Click Events
    click FE "https://github.com/skinatech/orfeong_backend/tree/main/frontend/"
    click BE "https://github.com/skinatech/orfeong_backend/tree/main/backend/"
    click API "https://github.com/skinatech/orfeong_backend/tree/main/api/"
    click COMMON "https://github.com/skinatech/orfeong_backend/tree/main/common/"
    click CONSOLE "https://github.com/skinatech/orfeong_backend/tree/main/console/"
    click INFRA "https://github.com/skinatech/orfeong_backend/blob/main/docker-compose.yml"
    click API_TESTS "https://github.com/skinatech/orfeong_backend/tree/main/api/tests/"
    click API_DOC "https://github.com/skinatech/orfeong_backend/tree/main/api/documentacion/"
    click BE_TESTS "https://github.com/skinatech/orfeong_backend/tree/main/backend/tests/"
    click FE_TESTS "https://github.com/skinatech/orfeong_backend/tree/main/frontend/tests/"

    %% Styles
    classDef frontend fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef backend fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef api fill:#f94144,stroke:#333,stroke-width:2px;
    classDef common fill:#577590,stroke:#333,stroke-width:2px;
    classDef external fill:#a44a3f,stroke:#333,stroke-width:2px;
    classDef console fill:#f3722c,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#277da1,stroke:#333,stroke-width:2px;
    classDef database fill:#43aa8b,stroke:#333,stroke-width:2px;
    classDef doc fill:#ffcc00,stroke:#333,stroke-width:2px;
```
