# sylvainomydoo/odoolocust architecture

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

- Interactive diagram: https://gitdiagram.com/sylvainomydoo/odoolocust
- Repository: https://github.com/sylvainomydoo/odoolocust

## Overview

##### Project type and purpose
- This is a Python-based load-testing library and sample suite for Odoo, built on top of Locust and odoolib.
- It ships as a reusable package (`src/OdooLocust/…`), plus sample test files and CRM-specific tasks.

##### File structure
- Top-level:
- setup.py, requirements.txt – package metadata and dependencies
- README.md – project overview and usage
- src/OdooLocust/… – actual library code
- test.py, test_sale.py – standalone tests
- src/OdooLocust:
- OdooLocustUser.py – subclass of Locust User, wraps odoolib client
- OdooTaskSet.py – generic TaskSet and CRM-specific TaskSets under crm/
- samples/ – example test scenarios and locust.conf
- The presence of locust.conf and shell scripts indicates master/worker orchestration and headless runs.

##### README for architecture hints
- Two core abstractions:
- OdooLocustUser (a Locust user that holds connection parameters)
- TaskSets (OdooTaskSet, OdooGenericTaskSet, crm.lead/partner/quotation)
- Integration points: users write subclasses, Locust drives them, they invoke odoolib over JSON-RPC to the Odoo server.
- Master/worker model for distributed load tests; configuration via locust.conf.

##### Main components
a. Locust Master (or headless master)
b. Locust Workers (one or many)
c. OdooLocust Library
- OdooLocustUser
- OdooTaskSet (generic + crm modules)
- Sample user scripts (Seller.py, load_odoo.py)
d. External Odoo Server
e. Configuration Layer (locust.conf / CLI args)
f. odoolib (the underlying RPC client)

##### Relationships and data flows
- Workers spawn greenlet Users (instances of OdooLocustUser).
- Each User uses its TaskSet(s) to execute tasks at runtime.
- Tasks call into OdooLocustUser.client (odoolib RPC client), issuing JSON-RPC over HTTP/S to the Odoo server.
- Responses flow back and feed into subsequent tasks.
- Master coordinates workers, aggregates results, exposes web UI or headless summary.
- Configuration (locust.conf or CLI) feeds host, user count, spawn rate, run time into Master/Workers.

##### Architectural patterns and principles
- Extension via subclassing: users extend OdooLocustUser & TaskSets.
- Modular services: clear separation between test harness (Locust) and RPC client (odoolib).
- Master/worker concurrency model using greenlets.
- Plug-and-play CRM modules in `src/OdooLocust/crm`.

##### Technologies, frameworks, libraries
- Python 3.x
- Locust (load-testing framework, master & workers)
- odoolib (Odoo RPC client)
- JSON-RPC / HTTP(S)
- gevent/greenlet (concurrency)

##### Diagramming recommendations
- Blue for internal modules (OdooLocustUser, TaskSets)
- Green for runtime engines (Locust master/workers)
- Orange for external services (Odoo server)
- Grey for configuration files/CLI
- From Master → Workers (control/coordination)
- From Workers → OdooLocustUser/TaskSet (instantiation)
- From TaskSet → odoolib client → Odoo server (RPC calls)
- From server → back to TaskSet → Master (metrics)

##### Essential details to capture
- Runtime model: Locust master and workers, headless vs UI mode.
- Extension mechanism: how sample scripts pick up OdooLocustUser & TaskSets.
- Communication flow: Task code → client → server → response.
- Configuration injection: locust.conf, environment defaults, CLI flags.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration Layer
    subgraph "Configuration" 
        LOCUST_CONF["locust.conf"]:::config
        CLI_ARGS["CLI Args / env vars"]:::config
    end

    %% Documentation and Metadata
    subgraph "Project Metadata & Docs"
        SETUP["setup.py"]:::docs
        REQS["requirements.txt"]:::docs
        README["README.md"]:::docs
    end

    %% Runtime Engines
    subgraph "Locust Runtime" 
        MASTER["Locust Master\n(Web UI / Headless)"]:::runtime
        WORKERS["Locust Workers"]:::runtime
    end

    %% Library Components
    subgraph "OdooLocust Library" 
        USER["OdooLocustUser"]:::library
        TASKSET["OdooTaskSet\n(Generic TaskSet)"]:::library
        subgraph "CRM Modules"
            LEAD["crm.lead TaskSet"]:::library
            PARTNER["crm.partner TaskSet"]:::library
            QUOTE["crm.quotation TaskSet"]:::library
        end
        subgraph "Samples"
            SELLER["Seller.py Scenario"]:::library
            LOAD_ODOO["load_odoo.py"]:::library
        end
    end

    %% Underlying RPC Client
    OD00LIB["odoolib RPC Client"]:::rpc

    %% External Service
    ODOO["Odoo Server\n(JSON-RPC over HTTP/S)"]:::external

    %% Standalone Tests
    subgraph "Standalone Tests"
        TEST_ALL["test.py"]:::tests
        TEST_SALE["test_sale.py"]:::tests
    end

    %% Connections and Data Flow
    CLI_ARGS -->|provides config| MASTER
    LOCUST_CONF -->|provides config| MASTER
    MASTER -->|spawns & coordinates| WORKERS
    WORKERS -->|instantiates| USER
    USER -->|uses| TASKSET
    TASKSET -->|imports| LEAD
    TASKSET -->|imports| PARTNER
    TASKSET -->|imports| QUOTE
    USER -->|calls| OD00LIB
    OD00LIB -->|JSON-RPC calls| ODOO
    ODOO -->|responses| OD00LIB
    OD00LIB -->|returns data| USER
    WORKERS -->|sends metrics| MASTER

    %% Tests & Samples integration
    SELLER -->|extends| USER
    LOAD_ODOO -->|drives| USER
    TEST_ALL -->|imports library| USER
    TEST_SALE -->|imports library| TASKSET

    %% Click Events
    click USER "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/OdooLocustUser.py"
    click TASKSET "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/OdooTaskSet.py"
    click LEAD "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/crm/lead.py"
    click PARTNER "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/crm/partner.py"
    click QUOTE "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/crm/quotation.py"
    click SELLER "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/samples/Seller.py"
    click LOCUST_CONF "https://github.com/sylvainomydoo/odoolocust/blob/master/src/OdooLocust/samples/locust.conf"
    click TEST_ALL "https://github.com/sylvainomydoo/odoolocust/blob/master/test.py"
    click TEST_SALE "https://github.com/sylvainomydoo/odoolocust/blob/master/test_sale.py"
    click SETUP "https://github.com/sylvainomydoo/odoolocust/blob/master/setup.py"
    click REQS "https://github.com/sylvainomydoo/odoolocust/blob/master/requirements.txt"
    click README "https://github.com/sylvainomydoo/odoolocust/blob/master/README.md"

    %% Styles
    classDef config fill:#e0e0e0,stroke:#bbb,stroke-width:1px
    classDef docs fill:#f5f5f5,stroke:#ccc,stroke-width:1px
    classDef runtime fill:#b3e6b3,stroke:#4ca64c,stroke-width:1px
    classDef library fill:#cce0ff,stroke:#4a6fa5,stroke-width:1px
    classDef rpc fill:#ffe0b3,stroke:#ffaa00,stroke-width:1px
    classDef external fill:#ffd9cc,stroke:#ff6f4c,stroke-width:1px
    classDef tests fill:#f2e6ff,stroke:#9a4cb4,stroke-width:1px
```
