# stefanotrv/simple_icd_10 architecture

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

- Interactive diagram: https://gitdiagram.com/stefanotrv/simple_icd_10
- Repository: https://github.com/stefanotrv/simple_icd_10

## Overview

##### Project type and purpose
- This is an open-source, single-module Python library (“simple_icd_10”) whose sole purpose is to load the WHO ICD-10 2019 classification from data files and expose a set of pure-Python functions that let client code query codes, relationships (parent/child/ancestors/descendants), descriptions, and perform format conversions.
- It ships as a pip-installable package, can be imported into any Python 3.9+ project, and is demonstrated in a Jupyter notebook.

##### File structure
- Top level:
- simple_icd_10.py and test_simple_icd_10.py – the core module and its unit tests
- data/ – raw data: plain-text lists and the XML file for the full ICD-10 tree
- other/ – auxiliary scripts to generate or update the XML
- package-files/ – the build/dist output and setup.py for packaging
- Notebook.ipynb – interactive demo
- No frontend/backend split or microservices—this is a library module plus packaging workflows.

##### Key insights from the README
- The library builds an in-memory tree from the XML and text files at import or on first call.
- It provides ~25 functions (is_valid_item, get_children, get_descendants, etc.).
- Data is immutable once loaded—no database, no external API calls.
- Distribution happens via setuptools (setup.py), generating wheel and sdist.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        CC["Client Code\nShowcase notebook.ipynb"]:::client
    end

    subgraph "Tests"
        TEST["Unit Tests\ntest_simple_icd_10.py"]:::test
    end

    subgraph "Library Module"
        API["Library API\nsimple_icd_10.py"]:::runtime

        subgraph "Data Loader & Parser"
            loader["Data Loader & Parser"]:::runtime
            XML["icd_10_v2019.xml"]:::disk
            TXT1["codes.txt"]:::disk
            TXT2["descriptions.txt"]:::disk
            TXT3["code-description pairs.txt"]:::disk
            INIT["__init__.py"]:::disk
        end

        MODEL[(In-Memory Data Model)]:::memory
    end

    subgraph "Auxiliary Scripts"
        GEN["XML file generator.py"]:::disk
        CMD["update commands for package.txt"]:::disk
    end

    subgraph "Packaging / Distribution"
        SETUP["setup.py"]:::disk
        BUILD_API["simple_icd_10.py\n(build/lib)"]:::disk
        BUILD_DATA["icd_10_v2019.xml\n(build/lib/data)"]:::disk
        DISTW[(.whl & .tar.gz)]:::dist
        EGG[(PKG-INFO)]:::dist
        PYPI[(PyPI)]:::repo
    end

    %% Relationships
    CC -->|"imports"| API
    TEST -->|"tests API"| API
    API -->|"lazy init"| loader
    loader -->|"loads XML"| XML
    loader -->|"reads text"| TXT1
    loader -->|"reads text"| TXT2
    loader -->|"reads text"| TXT3
    loader -->|"package entry"| INIT
    loader -->|"builds"| MODEL
    API -->|"queries"| MODEL

    SETUP -->|"reads module & data"| API
    SETUP -->|"produces"| BUILD_API
    SETUP -->|"produces"| BUILD_DATA
    SETUP -->|"outputs"| DISTW
    SETUP -->|"outputs"| EGG
    DISTW -->|"publishes"| PYPI
    EGG -->|"publishes"| PYPI

    %% Click Events
    click CC "https://github.com/stefanotrv/simple_icd_10/blob/master/Showcase notebook.ipynb"
    click API "https://github.com/stefanotrv/simple_icd_10/blob/master/simple_icd_10.py"
    click TEST "https://github.com/stefanotrv/simple_icd_10/blob/master/test_simple_icd_10.py"
    click XML "https://github.com/stefanotrv/simple_icd_10/blob/master/data/icd_10_v2019.xml"
    click TXT1 "https://github.com/stefanotrv/simple_icd_10/blob/master/data/codes.txt"
    click TXT2 "https://github.com/stefanotrv/simple_icd_10/blob/master/data/descriptions.txt"
    click TXT3 "https://github.com/stefanotrv/simple_icd_10/blob/master/data/code-description pairs.txt"
    click INIT "https://github.com/stefanotrv/simple_icd_10/blob/master/data/__init__.py"
    click GEN "https://github.com/stefanotrv/simple_icd_10/blob/master/other/XML file generator.py"
    click CMD "https://github.com/stefanotrv/simple_icd_10/blob/master/other/commands for updating the package.txt"
    click SETUP "https://github.com/stefanotrv/simple_icd_10/blob/master/package-files/setup.py"
    click BUILD_API "https://github.com/stefanotrv/simple_icd_10/blob/master/package-files/build/lib/simple_icd_10/simple_icd_10.py"
    click BUILD_DATA "https://github.com/stefanotrv/simple_icd_10/blob/master/package-files/build/lib/simple_icd_10/data/icd_10_v2019.xml"
    click DISTW "https://github.com/stefanotrv/simple_icd_10/blob/master/package-files/dist/simple_icd_10-2.1.1-py3-none-any.whl"
    click EGG "https://github.com/stefanotrv/simple_icd_10/tree/master/package-files/simple_icd_10.egg-info/PKG-INFO"

    %% Styles
    classDef runtime fill:#8DD3C7,stroke:#333,stroke-width:1px
    classDef disk fill:#B3E2CD,stroke:#333,stroke-width:1px
    classDef memory fill:#FDB462,stroke:#333,stroke-width:1px
    classDef client fill:#80B1D3,stroke:#333,stroke-width:1px
    classDef test fill:#FB8072,stroke:#333,stroke-width:1px
    classDef dist fill:#BC80BD,stroke:#333,stroke-width:1px
    classDef repo fill:#FFED6F,stroke:#333,stroke-width:1px
```
