# amlaksil/odoo-json-rpc-api architecture

> Architecture diagram of the GitHub repository amlaksil/odoo-json-rpc-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amlaksil/odoo-json-rpc-api
- Repository: https://github.com/amlaksil/odoo-json-rpc-api

## Overview

##### Project type and purpose
- This is an open-source collection of example JSON-RPC request payloads for Odoo’s API. It’s not a full-stack application with frontend/backend code, but rather a set of sample requests (employee-*.json, product-*.json) accompanied by a README explaining how to call Odoo’s JSON-RPC services.
- Purpose: Provide developers with ready-made request templates (CRUD operations) against Odoo models via JSON-RPC 2.0.

##### File structure
- Top level:
- README.md — explains API usage, services, methods, examples.
- employee-create.json, employee-read.json, … product-*.json — JSON payloads for create, read, update, delete, search operations on hr.employee and product.template models.
- No code directories, build scripts, or config files—just sample payloads and documentation.

##### README for additional insights
- Describes the JSON-RPC 2.0 protocol for Odoo: authentication (common service), object service (CRUD), report, workflow, web, action, wizard, security, data, utility.
- Shows example request/response formats and best practices.

##### Main components
a. Client Component
- Represents any external application or script using these JSON sample files to drive requests.
b. JSON-RPC Transport Layer
- HTTP(S) endpoint exposing JSON-RPC 2.0.
- Handles request/response marshalling.
c. Odoo Services Layer
- Common Service (authenticate)
- Object Service (execute: CRUD/search_read)
- Other services (report, workflow, web, action, wizard, security, data, utility)
d. Odoo Core & ORM
- Business logic, model definitions (hr.employee, product.template)
e. Odoo Database
- PostgreSQL storing all records
f. Error Handling & Session Management
- Session store or in-memory registry for authenticated sessions
g. External Integrations (optional)
- Mail servers, file storage, third-party APIs invoked by Odoo actions or reports

##### Relationships and interactions
- Client → JSON-RPC Endpoint: send example JSON payload (employee-create.json → HTTP POST).
- JSON-RPC Layer → Common Service: authenticate() to establish session (database, username, password).
- JSON-RPC Layer → Object Service: execute(model_name, method_name, args).
- Object Service → ORM → Database: perform SQL queries/updates.
- Object Service → returns JSON result/error back up to client.
- Other services follow similar flow (report generation → file storage; workflow → schedule tasks, etc.).

##### Architectural patterns & design principles
- Layered architecture: transport layer, service layer, ORM/core, persistence
- Separation of concerns: authentication vs. object operations vs. reporting vs. workflow
- Stateless requests with session ID token
- Extensible services: additional services can be plugged in along the same JSON-RPC interface

##### Technologies, frameworks, libraries
- HTTP(S) + JSON-RPC 2.0 protocol
- Odoo server (Python, built-in ORM on PostgreSQL)
- PostgreSQL database
- Clients: any HTTP client or CLI script loading .json payloads

##### Customizing for this open-source sample project
- “Sample Request Library” as your entry point—show it feeding into the JSON-RPC endpoint.
- Only the services used by the sample files (common and object) more prominently, dim or outline the others.
- A typical CRUD use case flow:
1. authenticate (common)
2. execute create/read/write/unlink (object)
3. return result or error

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Sample Request Library"
        empC["employee-create.json"]:::doc
        empR["employee-read.json"]:::doc
        empU["employee-update.json"]:::doc
        empD["employee-delete.json"]:::doc
        prodC["product-create.json"]:::doc
        prodR["product-read.json"]:::doc
        prodU["product-update.json"]:::doc
        prodD["product-delete.json"]:::doc
        prodCat["product-category.json"]:::doc
        readme["README.md"]:::doc
    end

    empC & empR & empU & empD & prodC & prodR & prodU & prodD & prodCat -->|"sample JSON request"| Endpoint
    readme -->|"documentation"| Endpoint

    Endpoint["JSON-RPC HTTP(S) Endpoint"]:::transport

    subgraph "Service Layer"
        Common["Common Service (authenticate)"]:::service
        Object["Object Service (execute CRUD/search_read)"]:::service
        Others["Other Services\n(report, workflow, web, action,\nwizard, security, data, utility)"]:::service-other
    end

    Endpoint -->|"authenticate() / execute()"| Common
    Endpoint -->|"execute()"| Object
    Endpoint -->|"other service calls"| Others

    Common -->|"session ID"| Session
    Object -->|"ORM calls"| Core
    Others -->|"various integrations"| Core

    Session["Session Store"]:::session
    Core["ORM / Core Business Logic"]:::core
    DB[(PostgreSQL Database)]:::db

    Core -->|"SQL queries/updates"| DB
    DB -->|"results"| Core
    Core -->|"return data"| Object
    Object -->|"JSON response"| Endpoint
    Common -->|"auth response"| Endpoint
    Others -->|"service response"| Endpoint
    Endpoint -->|"JSON response"| empC

    click empC "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./employee-create.json"
    click empR "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./employee-read.json"
    click empU "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./employee-update.json"
    click empD "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./employee-delete.json"
    click prodC "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./product-create.json"
    click prodR "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./product-read.json"
    click prodU "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./product-update.json"
    click prodD "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./product-delete.json"
    click prodCat "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./product-category.json"
    click readme "https://github.com/amlaksil/odoo-json-rpc-api/blob/master/./README.md"

    classDef external fill:#ADD8E6,stroke:#000000
    classDef transport fill:#98FB98,stroke:#000000
    classDef service fill:#98FB98,stroke:#000000
    classDef service-other fill:#CCFFCC,stroke:#000000
    classDef core fill:#FFA500,stroke:#000000
    classDef db fill:#D2B48C,stroke:#000000
    classDef session fill:#D3D3D3,stroke:#000000
    classDef doc fill:#FFFFFF,stroke:#000000
```
