# openapi-generators/openapi-python-client architecture

> Architecture diagram of the GitHub repository openapi-generators/openapi-python-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openapi-generators/openapi-python-client
- Repository: https://github.com/openapi-generators/openapi-python-client

## Overview

##### Main Components

a. Core Generator Components:
- Parser Module
- Template Engine
- Configuration Handler
- CLI Interface

b. Input/Output Components:
- OpenAPI Spec Input (URL/File)
- Generated Client Output

##### Key Relationships

a. Data Flow:
##### Configuration → All Components

b. Component Interactions:
- Parser's subcomponents (Properties, Bodies, Responses)
- Template system's relationship with different output formats

##### Detailed Component Breakdown

a. Parser Module (Blue Components):
- OpenAPI Schema Parser
- Property Parsers (Multiple Types)
- Response Parser
- Body Parser

b. Template System (Green Components):
- Base Templates
- Property Templates
- Custom Template Override System
- Post-Processing Hooks

c. Configuration System (Yellow Components):
- YAML/JSON Config Parser
- Class Override Handler
- Naming Convention Manager

d. Generated Output Structure (Purple Components):
- Client Classes
- API Modules
- Model Classes
- Project Configuration Files

**[Input Layer]**
- ↓
**[Processing Layer]**
- ↓
**[Generation Layer]**
- ↓
**[Output Layer]**

##### Implementation Details to Highlight

- How the parser handles different OpenAPI versions (3.0 and 3.1)
- Template override mechanism
- Demonstrate configuration injection points
- Post-generation hook system

- Rectangles: Main components
- Hexagons: Decision points

- Blue: Core parsing components
- Green: Template system
- Yellow: Configuration system
- Purple: Generated output
- Gray: External dependencies

- Component types
- Special symbols

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        SPEC[OpenAPI Specification]
        CONF[Configuration File]
    end

    subgraph "Parser Layer"
        OPARSER["OpenAPI Schema Parser"]:::parser
        PPARSER["Property Parsers"]:::parser
        RPARSER["Response Parser"]:::parser
        BPARSER["Body Parser"]:::parser
    end

    subgraph "Template System"
        TBASE["Base Templates"]:::template
        TPROP["Property Templates"]:::template
        THELP["Template Helpers"]:::template
        TOVER["Template Override System"]:::template
    end

    subgraph "Configuration System"
        CONFIG["Config Handler"]:::config
        SCHEMA["Schema Definitions"]:::config
    end

    subgraph "CLI System"
        CLI["CLI Interface"]:::cli
        MAIN["Main Entry Point"]:::cli
    end

    subgraph "Output Layer"
        CLIENT["Client Classes"]:::output
        API["API Modules"]:::output
        MODEL["Model Classes"]:::output
        PCONF["Project Config Files"]:::output
    end

    SPEC --> CLI
    CONF --> CONFIG
    CONFIG --> |Configuration| OPARSER
    CONFIG --> |Configuration| TBASE

    CLI --> OPARSER
    MAIN --> CLI

    OPARSER --> PPARSER
    OPARSER --> RPARSER
    OPARSER --> BPARSER

    PPARSER --> TBASE
    RPARSER --> TBASE
    BPARSER --> TBASE

    TBASE --> TPROP
    TBASE --> THELP
    TOVER --> TBASE

    TBASE --> CLIENT
    TBASE --> API
    TBASE --> MODEL
    TBASE --> PCONF

    %% Click events for component mapping
    click OPARSER "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/parser/openapi.py"
    click PPARSER "https://github.com/openapi-generators/openapi-python-client/tree/main/openapi_python_client/parser/properties/"
    click RPARSER "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/parser/responses.py"
    click BPARSER "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/parser/bodies.py"
    click TBASE "https://github.com/openapi-generators/openapi-python-client/tree/main/openapi_python_client/templates/"
    click TPROP "https://github.com/openapi-generators/openapi-python-client/tree/main/openapi_python_client/templates/property_templates/"
    click THELP "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/templates/helpers.jinja"
    click CONFIG "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/config.py"
    click SCHEMA "https://github.com/openapi-generators/openapi-python-client/tree/main/openapi_python_client/schema/"
    click CLI "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/cli.py"
    click MAIN "https://github.com/openapi-generators/openapi-python-client/blob/main/openapi_python_client/__main__.py"

    %% Styling
    classDef parser fill:#a8d1f0,stroke:#333
    classDef template fill:#90EE90,stroke:#333
    classDef config fill:#FFE5B4,stroke:#333
    classDef cli fill:#D3D3D3,stroke:#333
    classDef output fill:#DDA0DD,stroke:#333

    %% Legend
    subgraph Legend
        L1["Parser Components"]:::parser
        L2["Template Components"]:::template
        L3["Configuration Components"]:::config
        L4["CLI Components"]:::cli
        L5["Output Components"]:::output
    end
```
