# seitabv/python-s2-protocol architecture

> Architecture diagram of the GitHub repository seitabv/python-s2-protocol, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/seitabv/python-s2-protocol
- Repository: https://github.com/seitabv/python-s2-protocol

## Overview

##### Main Components

a) Input Layer:
- S2-WS-JSON schemas source (s2-ws-json/s2-asyncapi/s2-cem.yaml)
- Different protocol modes (FRBC, DDBC, PEBC, PPBC)

b) Generation Layer:
- Datamodel-codegen tool component
- Model generation process

c) Library Structure:
- Common module (shared components)
- Protocol-specific modules (FRBC, etc.)
- Messages and Schemas separation

##### Component Relationships

**[S2-WS-JSON Schema Files] --> [datamodel-codegen] --> [Generated Python Models]**

- v
**[Common Models] <---- [Protocol-Specific Models (FRBC, etc.)]**
- ^                            |
- v
**[End User Applications] -----> [Message Handling]**

##### Specific Elements

- Blue: External dependencies (datamodel-codegen)
- Green: Generated code
- Yellow: Core library components
- Gray: Common utilities and shared code

- Rectangles: Main components

##### Important Details to Highlight

- Separation between:
- Raw generated models
- Refactored/organized models
- Common utilities
- Protocol-specific implementations

##### Technical Specifications

A side panel showing:
- Python dependencies
- Generated model structure
- Key class hierarchies
- Integration points

##### Implementation Notes

Annotations indicating:
- Model generation process
- Manual refactoring steps
- Testing framework integration
- Installation process

Key Considerations:

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        SchemaSource["S2-WS-JSON Schema Source"]
        Protocols["Protocol Modes<br/>(FRBC, DDBC, PEBC, PPBC)"]
    end

    subgraph Generation
        CodeGen["datamodel-codegen"]:::external
        GenScript["Model Generation Script"]
    end

    subgraph Library
        subgraph Common
            CommonMod["Common Module"]
            CommonMsg["Common Messages"]
            CommonSchema["Common Schemas"]
            CommonMod --> CommonMsg
            CommonMod --> CommonSchema
        end

        subgraph ProtocolModules
            FRBC["FRBC Module"]
            FRBCMsg["FRBC Messages"]
            FRBCSchema["FRBC Schemas"]
            FRBC --> FRBCMsg
            FRBC --> FRBCSchema
        end
    end

    subgraph Testing
        Tests["Testing Framework"]
        BasicTests["Basic Type Tests"]
        EntityTests["Entity Tests"]
        Tests --> BasicTests
        Tests --> EntityTests
    end

    subgraph Documentation
        Docs["Documentation"]
        APIDocs["API Documentation"]
        ProtocolDocs["Protocol-Specific Docs"]
        CommonDocs["Common Module Docs"]
        Docs --> APIDocs
        Docs --> ProtocolDocs
        Docs --> CommonDocs
    end

    SchemaSource --> CodeGen
    Protocols --> CodeGen
    CodeGen --> GenScript
    GenScript --> CommonMod
    GenScript --> FRBC
    CommonMod --> FRBC
    FRBC --> Tests
    CommonMod --> Tests

    classDef external fill:#3498db
    classDef generated fill:#2ecc71
    classDef core fill:#f1c40f
    classDef common fill:#95a5a6

    click SchemaSource "https://github.com/SeitaBV/python-s2-protocol/tree/main/s2-ws-json/"
    click GenScript "https://github.com/SeitaBV/python-s2-protocol/blob/main/generate_models.sh"
    click CommonMod "https://github.com/SeitaBV/python-s2-protocol/tree/main/src/python_s2_protocol/common/"
    click CommonMsg "https://github.com/SeitaBV/python-s2-protocol/blob/main/src/python_s2_protocol/common/messages.py"
    click CommonSchema "https://github.com/SeitaBV/python-s2-protocol/blob/main/src/python_s2_protocol/common/schemas.py"
    click FRBC "https://github.com/SeitaBV/python-s2-protocol/tree/main/src/python_s2_protocol/FRBC/"
    click FRBCMsg "https://github.com/SeitaBV/python-s2-protocol/blob/main/src/python_s2_protocol/FRBC/messages.py"
    click FRBCSchema "https://github.com/SeitaBV/python-s2-protocol/blob/main/src/python_s2_protocol/FRBC/schemas.py"
    click Tests "https://github.com/SeitaBV/python-s2-protocol/tree/main/tests/"
    click BasicTests "https://github.com/SeitaBV/python-s2-protocol/blob/main/tests/test_basic_types.py"
    click EntityTests "https://github.com/SeitaBV/python-s2-protocol/blob/main/tests/test_medium_entities.py"
    click Docs "https://github.com/SeitaBV/python-s2-protocol/tree/main/docs/"
    click APIDocs "https://github.com/SeitaBV/python-s2-protocol/tree/main/docs/api/"
    click ProtocolDocs "https://github.com/SeitaBV/python-s2-protocol/blob/main/docs/api/python_s2_protocol.FRBC.rst"
    click CommonDocs "https://github.com/SeitaBV/python-s2-protocol/blob/main/docs/api/python_s2_protocol.common.rst"
```
