# siddhantladdha/analog_daddy architecture

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

- Interactive diagram: https://gitdiagram.com/siddhantladdha/analog_daddy
- Repository: https://github.com/siddhantladdha/analog_daddy

## Overview

##### Project type and purpose
- This is an open-source Python library (“analog_daddy”) for transistor sizing via precomputed lookup tables (LUTs).
- Its primary purpose is to import CSV/NumPy LUT data, perform gm/ID style lookups and interpolation, produce configuration files for EDA flows, and provide plotting templates/notebooks for analog designers.

##### File structure
- Top-level packaging:
- setup.py, requirements.txt, LICENSE, README.md
- analog_daddy/ (core Python package)
- docs/ (usage guides, demos, notebooks, images)
- sample_files/ (example LUT data)
- tests/ (unit tests validating importer, lookup, write_config)
- Core modules in analog_daddy/:
- conf.py – global settings (e.g., file paths, defaults)
- importer.py – reads CSV/NumPy LUT files into in-memory structures
- look_up.py – lookup/interpolation functions (e.g., gm/ID, VGS lookups)
- write_config.py – writes Cadence assembler config files from lookup results
- utils.py – plotting templates (Plotly/Dash), common helper routines
- Deployment artifacts:
- pip-installable Python package (AGPLv3 licensed)
- Test suite driven by unittest discover

##### README for additional insights
- Dependencies: numpy, scipy, pandas, matplotlib, dash
- Supports offline & online installation
- No monolithic services – operations happen in-process via library calls or notebooks
- External integration:
- SPICE (ngspice) can be invoked externally in notebook workflows for LUT generation
- Cadence Virtuoso/Cadence Assembler testbench configs are generated by write_config.py

a. Main components
- User Interfaces:
- Jupyter Notebooks (docs/notebooks) – interactive demos & plots
- CLI / Python API – library functions imported by user scripts
- Core Library Package (analog_daddy/)
- importer module
- look_up module
- write_config module
- utils module & conf module
- Data Layer
- LUT files (CSV/NPY) in sample_files or user-provided
- External Tools & Services
- ngspice (for LUT generation workflows)
- Cadence Assembler / Virtuoso (config consumer)
- Tests & CI
- Unit tests in tests/
- GitHub Actions (implied by .github/ISSUE_TEMPLATE)
b. Relationships & interactions
- User → invokes CLI or imports Python API → calls importer to load LUT data → look_up performs interpolation → write_config emits config files → Cadence assembler consumes those files
- Notebooks orchestrate importer, look_up, utils (plotting) and optionally call ngspice externally
- Tests exercise all core modules against sample_files
c. Architectural patterns & principles
- Modular package structure – single responsibility per module
- Lazy data loading (NumPy-backed) for performance
- Extensibility via:
- Adding new lookup functions in look_up.py
- Supporting additional file formats in importer.py
- Custom plotting templates in utils.py
- Separation of concerns: data import, processing, output generation, visualization
d. Relevant technologies & frameworks
- Python packaging (setup.py, pip)
- NumPy, pandas, SciPy for data handling & interpolation
- Plotly/Dash & Matplotlib for plotting
- JupyterLab for interactive demos
- EDA tools: ngspice, Cadence Virtuoso/Assembler

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    UI_CLI["CLI / Python API"]:::ui
    UI_Notebook["Jupyter Notebooks"]:::ui
    UI_Docs["Documentation & Usage Guides"]:::docs

    %% Data Store
    LUTs[(CSV/NPY LUT Data)]:::data

    %% External Tools
    NGSPICE[(ngspice)]:::external
    CADENCE[(Cadence Virtuoso / Assembler)]:::external

    %% Core Package Boundary
    subgraph "analog_daddy Package"
        direction TB
        CONF["conf.py (Global Settings)"]:::module
        IMPORTER["importer.py (LUT Ingestion)"]:::module
        LOOKUP["look_up.py (Interpolation)"]:::module
        WRITECFG["write_config.py (Config Writer)"]:::module
        UTILS["utils.py (Plotting & Helpers)"]:::module
    end

    %% Tests & CI
    TESTS["Unit Tests"]:::test

    %% Project Metadata & Packaging
    subgraph "Project Metadata & Packaging"
        direction TB
        SETUP["setup.py"]:::meta
        REQS["requirements.txt"]:::meta
        LICENSE["LICENSE"]:::meta
        README["README.md"]:::meta
        ISSUE[".github/ISSUE_TEMPLATE/"]:::meta
    end

    %% Relationships
    UI_CLI -->|"invokes"| IMPORTER
    UI_CLI -->|"invokes"| LOOKUP
    UI_CLI -->|"invokes"| WRITECFG

    UI_Notebook -->|"imports"| IMPORTER
    UI_Notebook -->|"calls"| LOOKUP
    UI_Notebook -->|"uses"| UTILS
    UI_Notebook -->|"optional SPICE run"| NGSPICE

    LUTs -->|"load data"| IMPORTER
    IMPORTER -->|"provides tables"| LOOKUP
    LOOKUP -->|"results"| WRITECFG
    WRITECFG -->|"generates configs"| CADENCE

    TESTS -->|"validate importer"| IMPORTER
    TESTS -->|"validate lookup"| LOOKUP
    TESTS -->|"validate write_config"| WRITECFG

    UI_Docs -->|"guides usage"| UI_Notebook
    UI_Docs -->|"explains API"| UI_CLI

    %% Click Events
    click analog_daddy "https://github.com/siddhantladdha/analog_daddy/tree/main/analog_daddy/"
    click CONF "https://github.com/siddhantladdha/analog_daddy/blob/main/analog_daddy/conf.py"
    click IMPORTER "https://github.com/siddhantladdha/analog_daddy/blob/main/analog_daddy/importer.py"
    click LOOKUP "https://github.com/siddhantladdha/analog_daddy/blob/main/analog_daddy/look_up.py"
    click WRITECFG "https://github.com/siddhantladdha/analog_daddy/blob/main/analog_daddy/write_config.py"
    click UTILS "https://github.com/siddhantladdha/analog_daddy/blob/main/analog_daddy/utils.py"
    click LUTs "https://github.com/siddhantladdha/analog_daddy/tree/main/sample_files/"
    click UI_Notebook "https://github.com/siddhantladdha/analog_daddy/tree/main/docs/notebooks/"
    click UI_Docs "https://github.com/siddhantladdha/analog_daddy/tree/main/docs/"
    click TESTS "https://github.com/siddhantladdha/analog_daddy/tree/main/tests/"
    click SETUP "https://github.com/siddhantladdha/analog_daddy/blob/main/setup.py"
    click REQS "https://github.com/siddhantladdha/analog_daddy/blob/main/requirements.txt"
    click LICENSE "https://github.com/siddhantladdha/analog_daddy/tree/main/LICENSE"
    click README "https://github.com/siddhantladdha/analog_daddy/blob/main/README.md"
    click ISSUE "https://github.com/siddhantladdha/analog_daddy/tree/main/.github/ISSUE_TEMPLATE/"

    %% Styles
    classDef ui fill:#B3E5FC,stroke:#0288D1,color:#000
    classDef module fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef data fill:#FFE0B2,stroke:#EF6C00,color:#000,shape: cylinder
    classDef external fill:#FFCDD2,stroke:#C62828,color:#000,shape: hexagon
    classDef test fill:#D1C4E9,stroke:#512DA8,color:#000
    classDef meta fill:#F5F5F5,stroke:#9E9E9E,color:#000
```
