# kormilitzin/med7 architecture

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

- Interactive diagram: https://gitdiagram.com/kormilitzin/med7
- Repository: https://github.com/kormilitzin/med7

## Overview

##### Project type and purpose
- This is an open-source NLP model package (Med7) for clinical named-entity recognition, built as a spaCy v3+ pipeline component.
- Its primary function is to be installed as a Python package (via pip), loaded into spaCy, and applied to free-text electronic health records to extract seven clinical entity types.

##### File structure
- Top-level files:
- README.md – project overview, installation, usage.
- LICENSE – licensing.
- .DS_Store – macOS artifact.
- Directories:
- images/ – static screenshots and graphs.
- tutorial/ – reproducible Jupyter notebook (`example.ipynb`) and conda environment definition (`environment.yml`).
- No backend/frontend split or microservices; it’s a library/model distribution with a usage tutorial.

##### README for additional insights
- Confirms three spaCy pipeline components: tokenizer/tagger, dependency parser, and an NER component trained on MIMIC-III.
- Installation flow: creates conda environment → pip install spaCy → pip install Med7 from Huggingface.
- Usage snippet: `spacy.load("en_core_med7_lg")` → process text → displaCy visualization → extract .ents.

##### Detailed capture
- Environment.yml under a “Reproducibility” module.
- Images/ folder assets as static resources used by README but not in the runtime flow.

Putting it all together:
- At the top: “Developer / Data Scientist”
→ uses “Tutorial Notebook” (environment.yml)
→ installs via “conda → pip install”
→ fetches model wheel from “Huggingface Hub”
- Center: “Python Runtime” with two sub-layers:
- spaCy Core
- Med7 Pipeline
– tagger
– parser
– clinical NER

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    Developer["Developer / Data Scientist"]:::actor

    %% Repository Assets
    subgraph "Repository Assets"
        README["README.md"]:::static
        LICENSE["LICENSE"]:::static
        StaticImages["images/"]:::static
        DS[".DS_Store"]:::static
    end

    %% Tutorial & Reproducibility
    subgraph "Tutorial & Setup"
        Notebook["Tutorial Notebook\n(example.ipynb)"]:::tutorial
        EnvYml["Reproducible Env\n(environment.yml)"]:::tutorial
    end

    %% Installation & Distribution
    subgraph "Installation & Distribution"
        CondaEnv["Conda Environment"]:::install
        PipInstall["pip install Med7"]:::install
        Huggingface["Huggingface Hub"]:::install
    end

    %% Python Runtime Pipeline
    subgraph "Python Runtime"
        SpaCyCore["spaCy Core"]:::runtime
        subgraph "Med7 Pipeline"
            Tagger["Tagger"]:::runtime
            Parser["Parser"]:::runtime
            CNER["Clinical NER"]:::runtime
        end
    end

    DocOut["Enriched Doc Object"]:::runtime
    Display["displaCy Visualization"]:::runtime

    %% Data Source
    MIMIC["MIMIC-III Dataset"]:::data

    %% Flows
    Developer -->|uses| Notebook
    Developer -->|sets up| CondaEnv
    Notebook -->|defines deps| EnvYml
    CondaEnv -->|installs| PipInstall
    PipInstall -->|fetch model| Huggingface
    PipInstall -->|loads into| SpaCyCore
    SpaCyCore -->|factory loads| Tagger
    Tagger -->|processes| Parser
    Parser -->|processes| CNER
    CNER -->|annotates| DocOut
    DocOut -->|renders| Display

    MIMIC -.pre-trains.-> CNER

    %% Click Events
    click README "https://github.com/kormilitzin/med7/blob/master/README.md"
    click LICENSE "https://github.com/kormilitzin/med7/tree/master/LICENSE"
    click StaticImages "https://github.com/kormilitzin/med7/tree/master/images/"
    click DS "https://github.com/kormilitzin/med7/blob/master/.DS_Store"
    click EnvYml "https://github.com/kormilitzin/med7/blob/master/tutorial/environment.yml"
    click Notebook "https://github.com/kormilitzin/med7/blob/master/tutorial/example.ipynb"

    %% Styles
    classDef actor fill:#FFD580,stroke:#E69A00,stroke-width:1px;
    classDef static fill:#E0E0E0,stroke:#888888,stroke-width:1px;
    classDef tutorial fill:#FFF2CC,stroke:#D6B656,stroke-width:1px;
    classDef install fill:#CCE5FF,stroke:#6699CC,stroke-width:1px;
    classDef runtime fill:#D5E8D4,stroke:#82B366,stroke-width:1px;
    classDef data fill:#F8CECC,stroke:#B85450,stroke-width:1px;
```
