# tweag/python-monorepo-example architecture

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

- Interactive diagram: https://gitdiagram.com/tweag/python-monorepo-example
- Repository: https://github.com/tweag/python-monorepo-example

## Overview

##### Main Components

A. Repository Structure Layer
- Root Monorepo Container
- Libraries Container ("libs/")
- Templates Container ("templates/")
- CI/CD Container (".github/workflows/")

B. Library Components
- Base Library ("libs/base/")
- Fancy Library ("libs/fancy/")
- Their internal structure:
- Source code
- Tests
- Configuration files

C. Template System
- PyLibrary Template
- Template Hooks
- Cookiecutter Generation System

##### Relationships to Highlight

A. Dependencies Flow
- Virtual environment isolation
- Template generation flow

##### Use a Multi-Layer Approach

**┌─ Monorepo Root ──────────────────────────────┐**

- ┌─ Libraries ─────┐  ┌─ Templates ────────┐ │
- ┌─ Base ────┐  │  │  ┌─ PyLibrary ──┐ │ │

- ┘  │  │  └──────────────┘ │ │
- ┌─ Fancy ───┐  │  │                   │ │
- ┘ │
- ┘  │                        │
- ┘                         │

- ┌─ CI/CD ──────────────────────────────┐   │

- ┘   │
- ┘

##### Important Elements

A. Library Components:
- ┌─ Library ─────────────┐
- Source Code        │
- Tests              │
- Requirements       │
- Virtual Environment│
- ┘

B. Template System:
- ┌─ Template ───────────┐
- Cookiecutter JSON │
- Hooks            │
- Template Files   │
- ┘

##### Additional Details

- Version control integration points
- How editable installs work between libraries
- Test execution paths
- Template instantiation process

Remember to:
- Clear labels for all components
- Notes about the "live at HEAD" workflow
- Document virtual environment isolation

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph MonoRepo["Python Monorepo"]
        direction TB
        
        subgraph Libraries["Libraries Container"]
            direction TB
            
            subgraph BaseLib["Base Library"]
                direction TB
                BaseSource["Source Code"]:::source
                BaseTests["Tests"]:::tests
                BaseConfig["Configuration"]:::config
                BaseVenv["Virtual Environment"]:::venv
            end
            
            subgraph FancyLib["Fancy Library"]
                direction TB
                FancySource["Source Code"]:::source
                FancyTests["Tests"]:::tests
                FancyConfig["Configuration"]:::config
                FancyVenv["Virtual Environment"]:::venv
            end
        end
        
        subgraph Templates["Template System"]
            direction TB
            PyLibTemp["PyLibrary Template"]:::template
            TempHooks["Template Hooks"]:::hooks
            CookieCutter["Cookiecutter Config"]:::config
            TempTests["Template Tests"]:::tests
        end
        
        subgraph CICD["CI/CD Workflows"]
            direction TB
            BaseCI["Base Library CI"]:::ci
            FancyCI["Fancy Library CI"]:::ci
            ReusableCI["Reusable Workflow"]:::ci
            TopCI["Top Level CI"]:::ci
        end
    end
    
    %% Relationships
    BaseLib --> FancyLib
    PyLibTemp --> |generates| Libraries
    BaseCI --> BaseLib
    FancyCI --> FancyLib
    ReusableCI --> BaseCI
    ReusableCI --> FancyCI
    TopCI --> ReusableCI
    
    %% Click Events
    click MonoRepo "https://github.com/tweag/python-monorepo-example/tree/main//"
    click Libraries "https://github.com/tweag/python-monorepo-example/tree/main//libs"
    click Templates "https://github.com/tweag/python-monorepo-example/tree/main//templates"
    click CICD "https://github.com/tweag/python-monorepo-example/tree/main//.github/workflows"
    
    click BaseSource "https://github.com/tweag/python-monorepo-example/tree/main//libs/base/mycorp/base"
    click BaseTests "https://github.com/tweag/python-monorepo-example/tree/main//libs/base/tests"
    click BaseConfig "https://github.com/tweag/python-monorepo-example/blob/main//libs/base/pyproject.toml"
    
    click FancySource "https://github.com/tweag/python-monorepo-example/tree/main//libs/fancy/mycorp/fancy"
    click FancyTests "https://github.com/tweag/python-monorepo-example/tree/main//libs/fancy/tests"
    click FancyConfig "https://github.com/tweag/python-monorepo-example/blob/main//libs/fancy/pyproject.toml"
    
    click PyLibTemp "https://github.com/tweag/python-monorepo-example/tree/main//templates/pylibrary"
    click TempHooks "https://github.com/tweag/python-monorepo-example/blob/main//templates/pylibrary/hooks/post_gen_project.py"
    click CookieCutter "https://github.com/tweag/python-monorepo-example/blob/main//templates/pylibrary/cookiecutter.json"
    click TempTests "https://github.com/tweag/python-monorepo-example/tree/main//templates/pylibrary/tests"
    
    click BaseCI "https://github.com/tweag/python-monorepo-example/blob/main//.github/workflows/ci_base.yml"
    click FancyCI "https://github.com/tweag/python-monorepo-example/blob/main//.github/workflows/ci_fancy.yml"
    click ReusableCI "https://github.com/tweag/python-monorepo-example/blob/main//.github/workflows/python_reusable.yml"
    click TopCI "https://github.com/tweag/python-monorepo-example/blob/main//.github/workflows/top_level.yml"
    
    %% Styling
    classDef source fill:#a8e6cf
    classDef tests fill:#dcedc1
    classDef config fill:#ffd3b6
    classDef venv fill:#ffaaa5
    classDef template fill:#98ddca
    classDef hooks fill:#d4f0f0
    classDef ci fill:#ff968a

    %% Legend
    subgraph Legend
        direction TB
        L1["Source Code"]:::source
        L2["Tests"]:::tests
        L3["Configuration"]:::config
        L4["Virtual Environment"]:::venv
        L5["Template"]:::template
        L6["Hooks"]:::hooks
        L7["CI/CD"]:::ci
    end
```
