# generalusermodels/gum architecture

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

- Interactive diagram: https://gitdiagram.com/generalusermodels/gum
- Repository: https://github.com/generalusermodels/gum

## Overview

##### Project type and purpose
- From the README and file tree, GUM is an open-source Python library and CLI tool for building “General User Models.”
- It ingests unstructured observations (e.g., screenshots), applies inference and retrieval to generate confidence-weighted propositions about a user, and stores and continuously revises those user models.

##### File structure
- Top-level files: setup.py, pyproject.toml, CLI entry point (gum/cli.py), database utilities (gum/db_utils.py).
- Core library: gum/gum.py implements the main GUM pipeline.
- Domain objects: gum/models.py (proposition/data classes), gum/schemas.py (validation/serialization).
- Plugin-style observers: gum/observers/observer.py defines the interface; gum/observers/screen.py implements one observer.
- Prompt modules: gum/prompts/gum.py and gum/prompts/screen.py generate instruction templates for inference.
- Documentation (docs/), CI (GitHub Actions for doc deployment), utility scripts (pip-update.sh).

##### README for additional insights
- The “architecture” is described in prose in the paper and docs:
a) Observation collection
b) Inference to propose new user facts via prompts & LLM
c) Retrieval of relevant context
d) Revision of existing propositions
e) Continuous update loop
- No built-in web service or front end; primary interface is CLI and library API.

##### Main components
a. Input Layer
- Observer Plugins (gum/observers/*)
- CLI or Host Process invokes observers
b. Core Engine
- GUM Pipeline (gum/gum.py)
- Inference Module (uses gum/prompts + external LLM)
- Retrieval Module (loads relevant propositions from DB)
- Revision Module (updates existing propositions)
c. Data Layer
- Proposition Store (via gum/db_utils.py; could be SQLite/Postgres)
- Schema & Validation (gum/schemas.py)
d. Model Definitions
- Data classes and ML/logic definitions in gum/models.py
e. Integration Points
- External LLM or AI Service (e.g., OpenAI/GPT API)
- Filesystem or other storage
- CLI (gum/cli.py) / Library API

##### Relationships and interactions
- Observers → (raw observations) → Core Engine.Inference
- Core Engine.Inference ↔ Prompts → External LLM
- LLM response → Core Engine.Retrieval & Revision
- Core Engine outputs → Data Layer (store/update propositions)
- CLI/API calls orchestrate the above flow

##### Architectural patterns and design principles
- Plugin pattern for observers and prompts (observer.py interface)
- Layered architecture: Input → Processing → Storage
- Single Responsibility: each module handles a defined step (observe, prompt, infer, store)
- Dependency injection via library API for custom observers or prompt templates

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Input Layer
    subgraph "Input Layer"
        ObserverInterface["Observer Interface"]:::input
        ObserverPlugin["Example Observer Plugin"]:::input
        CLI["CLI Entry Point"]:::input
    end

    %% Core Engine
    subgraph "Core Engine"
        GUMPipeline["GUM Pipeline"]:::core
        subgraph "Modules"
            Inference["Inference Module"]:::core
            Retrieval["Retrieval Module"]:::core
            Revision["Revision Module"]:::core
        end
        subgraph "Prompts"
            CorePrompts["Core Prompts"]:::input
            ObserverPrompts["Observer Prompts"]:::input
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        PropositionStore["Proposition Store (DB Utilities)"]:::data
        SchemaValidation["Schema & Validation"]:::data
        Models["Model Definitions"]:::data
    end

    %% Integration / External Services
    subgraph "External Services"
        LLM["External LLM Service"]:::external
        Filesystem["Filesystem / Storage"]:::external
    end

    %% Configuration & Docs
    subgraph "Configuration & Documentation"
        Setup["setup.py"]:::config
        Pyproject["pyproject.toml"]:::config
        DocsAPI["API Reference Docs"]:::config
        DocsTutorials["Tutorials Docs"]:::config
        Mkdocs["mkdocs.yml"]:::config
        CI["CI/CD Workflow"]:::config
    end

    %% Connections
    ObserverInterface -->|"provides observations"| Inference
    ObserverPlugin -->|"provides observations"| Inference
    CLI -->|"invokes pipeline"| GUMPipeline

    GUMPipeline -->|orchestrates| Inference
    GUMPipeline -->|orchestrates| Retrieval
    GUMPipeline -->|orchestrates| Revision

    Inference -->|"uses templates"| CorePrompts
    Inference -->|"uses templates"| ObserverPrompts
    Inference -->|"calls"| LLM
    LLM -->|"responds"| Inference

    Retrieval -->|"reads/writes"| PropositionStore
    Revision -->|"updates"| PropositionStore
    PropositionStore -->|"validated by"| SchemaValidation
    PropositionStore -->|"models via"| Models

    GUMPipeline -->|"stores files"| Filesystem

    %% Config & Docs connections
    Setup -->|configures| GUMPipeline
    Pyproject -->|configures| GUMPipeline
    DocsAPI -->|documents| Models
    DocsTutorials -->|tutorials for| CLI
    Mkdocs -->|builds docs| DocsAPI
    Mkdocs -->|builds docs| DocsTutorials
    CI -->|deploys docs| Mkdocs

    %% Click Events
    click ObserverInterface "https://github.com/generalusermodels/gum/blob/main/gum/observers/observer.py"
    click ObserverPlugin "https://github.com/generalusermodels/gum/blob/main/gum/observers/screen.py"
    click CLI "https://github.com/generalusermodels/gum/blob/main/gum/cli.py"
    click GUMPipeline "https://github.com/generalusermodels/gum/blob/main/gum/gum.py"
    click CorePrompts "https://github.com/generalusermodels/gum/blob/main/gum/prompts/gum.py"
    click ObserverPrompts "https://github.com/generalusermodels/gum/blob/main/gum/prompts/screen.py"
    click PropositionStore "https://github.com/generalusermodels/gum/blob/main/gum/db_utils.py"
    click SchemaValidation "https://github.com/generalusermodels/gum/blob/main/gum/schemas.py"
    click Models "https://github.com/generalusermodels/gum/blob/main/gum/models.py"
    click Setup "https://github.com/generalusermodels/gum/blob/main/setup.py"
    click Pyproject "https://github.com/generalusermodels/gum/blob/main/pyproject.toml"
    click DocsAPI "https://github.com/generalusermodels/gum/tree/main/docs/api-reference/"
    click DocsTutorials "https://github.com/generalusermodels/gum/tree/main/docs/tutorials/"
    click Mkdocs "https://github.com/generalusermodels/gum/blob/main/mkdocs.yml"
    click CI "https://github.com/generalusermodels/gum/blob/main/.github/workflows/deploy-docs.yml"

    %% Styles
    classDef input fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef core fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFFF99,stroke:#000,stroke-width:1px
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px
```
