# taghubnet/frepple architecture

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

- Interactive diagram: https://gitdiagram.com/taghubnet/frepple
- Repository: https://github.com/taghubnet/frepple

## Overview

##### Main Components
- Core Planning Engine: Represented by the C++ source files found under the “src” directory (such as src/model and src/solver) and header files under “include”. This engine embodies the planning algorithms, business logic, and optimization routines (covering scheduling, load planning, operation planning, and bottleneck management).
- Python/Django Integration Layer: Found under “contrib/django”. This part provides the web frontend (administrative UI, reporting and REST API endpoints) and the binding to the planning engine. Here, modules for input (data ingestion), output (reports, dashboards) and connectors (e.g., for interfacing with external ERP systems) are defined.
- External Connectors and Integrations: Components like the Odoo and Openbravo integrations (located under “contrib/odoo” and “contrib/django/freppledb”) are essential to interface with ERP systems. They handle data exchange such as importing parameters or exporting schedules.
- Packaging/Deployment and Installer Modules: Parts in “contrib/debian”, “contrib/rpm”, “contrib/vc”, and “contrib/installer” indicate that the system has tailored deployment processes and installers (Windows, Linux packages). This should be shown as a separate component for distribution and deployment.
- Documentation and Testing: Although not directly part of runtime architecture, the “doc” and “test” directories highlight extensive technical documentation and a comprehensive testing framework. (You may optionally include these in an “Auxiliary” or “Support” layer to indicate continuous integration and quality assurance aspects.)

##### Relationships and Data Flows
- That the Django-based UI (presentation layer) interacts with the Core Planning Engine. This is often achieved via the Python extension (located in “src/pythonextension.cpp” and corresponding bindings).
- That external modules (such as the ERP connectors) both receive inputs from and output results back to the planning engine.
- Packaging and installer components as pipelines that take the combined application (engine + integration UI) and produce deployment artifacts (e.g., deb, rpm, Windows installer).

##### Architectural Patterns and Technologies
- Layered Architecture: Visually separate the system into layers – the Business Logic (C++ engine), the Integration/Interface Layer (Python/Django application), and the Deployment/Packaging/Support Layer.
- Hybrid Integration: Note how the system employs language interoperability where high-performance routines run in C++ while user interaction and external communication are managed by Django.
- Extensibility: With multiple integration modules (ERP connectors, additional extension modules as seen in “doc/extension-modules”), highlight how the architecture supports plug-ins and extension points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    ext["External Users/ERP Systems"]:::external

    %% Python/Django Integration Layer
    subgraph "Python/Django Integration Layer"
        djangoUI["Django UI & API"]:::integration
        djangoSettings["Django Settings"]:::integration
        frepplectl["frepplectl"]:::integration
        djangoDB["frepple DB"]:::integration
    end

    %% Core Planning Engine (C++ Model & Solver)
    subgraph "Core Planning Engine (C++ Model & Solver)"
        cppModel["C++ Model"]:::core
        cppSolver["C++ Solver"]:::core
        cppHeaders["C++ Headers"]:::core
        cppPython["Python Binding (C++ extension)"]:::core
    end

    %% ERP Connectors
    subgraph "ERP Connectors"
        erpOdoo["Odoo Connector"]:::erp
        erpOpenbravo["Openbravo Connector"]:::erp
    end

    %% Packaging & Deployment Modules
    subgraph "Packaging & Deployment"
        deployDebian["Debian Packaging"]:::deploy
        deployRPM["RPM Packaging"]:::deploy
        deployVC["VC Deployment"]:::deploy
        deployInstaller["Installer Modules"]:::deploy
    end

    %% Support & QA
    subgraph "Support & QA"
        supportDoc["Documentation"]:::support
        supportTest["Testing Framework"]:::support
    end

    %% Connections between layers
    ext -->|"sends_requests"| djangoUI

    %% Internal connections in Integration Layer
    djangoUI -->|"loads"| djangoSettings
    djangoUI -->|"executes"| frepplectl
    djangoUI -->|"communicates"| djangoDB

    %% ERP Connectors interact with Integration Layer
    erpOdoo -->|"exchanges_data"| djangoDB
    erpOpenbravo -->|"exchanges_data"| djangoDB
    djangoDB -->|"triggers"| cppPython

    %% Integration Layer to Core Planning Engine
    djangoUI -->|"invokes"| cppPython
    cppPython -->|"calls_model"| cppModel
    cppPython -->|"calls_solver"| cppSolver

    %% Optional internal core communication
    cppModel -->|"collaborates"| cppSolver

    %% Core & Integration feed into Packaging & Deployment
    djangoUI -->|"packaged_with"| deployDebian
    cppPython -->|"packaged_with"| deployRPM
    cppHeaders -->|"included_in"| deployVC
    cppSolver -->|"included_in"| deployInstaller

    %% Support & QA connections (dotted lines)
    supportDoc -.->|"reviews"| djangoUI
    supportDoc -.->|"reviews"| cppModel
    supportTest -.->|"verifies"| djangoUI
    supportTest -.->|"verifies"| cppModel

    %% Click Events for Core Planning Engine
    click cppModel "https://github.com/taghubnet/frepple/tree/master/src/model"
    click cppSolver "https://github.com/taghubnet/frepple/tree/master/src/solver"
    click cppHeaders "https://github.com/taghubnet/frepple/tree/master/include"
    click cppPython "https://github.com/taghubnet/frepple/blob/master/src/pythonextension.cpp"

    %% Click Events for Python/Django Integration Layer
    click djangoUI "https://github.com/taghubnet/frepple/tree/master/contrib/django"
    click djangoSettings "https://github.com/taghubnet/frepple/blob/master/contrib/django/djangosettings.py"
    click frepplectl "https://github.com/taghubnet/frepple/blob/master/contrib/django/frepplectl.py"
    click djangoDB "https://github.com/taghubnet/frepple/tree/master/contrib/django/freppledb"

    %% Click Events for ERP Connectors
    click erpOdoo "https://github.com/taghubnet/frepple/tree/master/contrib/odoo"
    click erpOpenbravo "https://github.com/taghubnet/frepple/tree/master/contrib/django/freppledb/openbravo"

    %% Click Events for Packaging/Deployment
    click deployDebian "https://github.com/taghubnet/frepple/tree/master/contrib/debian"
    click deployRPM "https://github.com/taghubnet/frepple/tree/master/contrib/rpm"
    click deployVC "https://github.com/taghubnet/frepple/tree/master/contrib/vc"
    click deployInstaller "https://github.com/taghubnet/frepple/tree/master/contrib/installer"

    %% Click Events for Documentation and Testing
    click supportDoc "https://github.com/taghubnet/frepple/tree/master/doc"
    click supportTest "https://github.com/taghubnet/frepple/tree/master/test"

    %% Styles
    classDef external fill:#f6d6ad,stroke:#333,stroke-width:2px;
    classDef integration fill:#cfe2f3,stroke:#333,stroke-width:2px;
    classDef core fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef erp fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef deploy fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef support fill:#d0e0e3,stroke:#333,stroke-width:2px;
```
