# acasto/iptic-memex architecture

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

- Interactive diagram: https://gitdiagram.com/acasto/iptic-memex
- Repository: https://github.com/acasto/iptic-memex

## Overview

##### Main Components

a) Core Application Layer:
- Entry point (main.py)
- Configuration management (config_handler.py, session_handler.py)
- Mode handlers (modes/ directory)

b) Action System:
- Action handlers (actions/ directory)
- Command processing
- Context management

c) Context Management System:
- Context handlers (contexts/ directory)
- Different types of content processors

d) Provider Integration Layer:
- Provider interfaces (providers/ directory)
- API communication handlers

e) External Integrations:
- File system interactions
- Web content fetching
- Search capabilities
- Code execution environment

**[User Interface Layer]**

- CLI Interface
- Mode Handlers (ask, chat, completion)

**[Core Application Layer]**

- Action System
- Command Processors

- Context Management
- Context Handlers

- Configuration Management
- Settings & Models

**[Provider Integration Layer]**

- LLM Providers
- OpenAI
- Anthropic
- Google
- Others...

**[External Services Layer]**

- File System
- Web Content
- Search Services
- Code Execution

##### Implementation Details

- Use rectangles for main components
- Use clouds for external services
- Notes for important configuration points

##### Key Relationships to Highlight

- How the action system interfaces with context management
- Relationship between providers and the core application
- Demonstrate how different modes interact with the action system
- Configuration management's influence on all components

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        CLI["CLI Interface"]
        MH["Mode Handlers"]
        ASK["Ask Mode"]:::mode
        CHAT["Chat Mode"]:::mode
        COMP["Completion Mode"]:::mode
        
        CLI --> MH
        MH --> ASK
        MH --> CHAT
        MH --> COMP
    end

    subgraph CORE["Core Application Layer"]
        MAIN["Main Entry Point"]:::core
        CFG["Configuration Management"]:::core
        SESS["Session Management"]:::core
        
        AS["Action System"]:::core
        CMD["Command Processing"]:::core
        CTX_MGR["Context Management"]:::core
    end

    subgraph CTX["Context Management System"]
        CHAT_CTX["Chat Context"]:::context
        FILE_CTX["File Context"]:::context
        WEB_CTX["Web Context"]:::context
        PDF_CTX["PDF Context"]:::context
        PROJ_CTX["Project Context"]:::context
    end

    subgraph PROV["Provider Integration Layer"]
        OPENAI["OpenAI"]:::provider
        ANTHROPIC["Anthropic"]:::provider
        GOOGLE["Google"]:::provider
        COHERE["Cohere"]:::provider
        LLAMA["LlamaCPP"]:::provider
    end

    subgraph EXT["External Services Layer"]
        FS["File System"]:::external
        WEB["Web Content"]:::external
        SEARCH["Search Services"]:::external
        CODE_EXEC["Code Execution"]:::external
        PDF["PDF Processing"]:::external
    end

    %% Connections
    UI --> CORE
    CORE --> CTX
    CORE --> PROV
    CORE --> EXT

    %% Click Events
    click MAIN "https://github.com/acasto/iptic-memex/blob/master/main.py"
    click CFG "https://github.com/acasto/iptic-memex/blob/master/config_handler.py"
    click SESS "https://github.com/acasto/iptic-memex/blob/master/session_handler.py"
    click ASK "https://github.com/acasto/iptic-memex/blob/master/modes/ask_mode.py"
    click CHAT "https://github.com/acasto/iptic-memex/blob/master/modes/chat_mode.py"
    click COMP "https://github.com/acasto/iptic-memex/blob/master/modes/completion_mode.py"
    click CMD "https://github.com/acasto/iptic-memex/blob/master/actions/process_subcommands_action.py"
    click CTX_MGR "https://github.com/acasto/iptic-memex/blob/master/actions/process_contexts_action.py"
    click CHAT_CTX "https://github.com/acasto/iptic-memex/blob/master/contexts/chat_context.py"
    click FILE_CTX "https://github.com/acasto/iptic-memex/blob/master/contexts/file_context.py"
    click WEB_CTX "https://github.com/acasto/iptic-memex/blob/master/contexts/web_content_context.py"
    click PDF_CTX "https://github.com/acasto/iptic-memex/blob/master/contexts/pdf_context.py"
    click PROJ_CTX "https://github.com/acasto/iptic-memex/blob/master/contexts/project_context.py"
    click OPENAI "https://github.com/acasto/iptic-memex/blob/master/providers/openai_provider.py"
    click ANTHROPIC "https://github.com/acasto/iptic-memex/blob/master/providers/anthropic_provider.py"
    click GOOGLE "https://github.com/acasto/iptic-memex/blob/master/providers/google_provider.py"
    click COHERE "https://github.com/acasto/iptic-memex/blob/master/providers/cohere_provider.py"
    click LLAMA "https://github.com/acasto/iptic-memex/blob/master/providers/llamacpp_provider.py"
    click FS "https://github.com/acasto/iptic-memex/blob/master/actions/load_file_action.py"
    click WEB "https://github.com/acasto/iptic-memex/blob/master/actions/fetch_from_web_action.py"
    click SEARCH "https://github.com/acasto/iptic-memex/blob/master/actions/brave_search_action.py"
    click CODE_EXEC "https://github.com/acasto/iptic-memex/blob/master/actions/run_code_action.py"
    click PDF "https://github.com/acasto/iptic-memex/blob/master/actions/load_pdf_action.py"

    %% Styling
    classDef core fill:#2374ab
    classDef context fill:#7209b7
    classDef provider fill:#f77f00
    classDef external fill:#38b000
    classDef mode fill:#d62828

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Context Handlers"]:::context
        L3["Provider Interfaces"]:::provider
        L4["External Services"]:::external
        L5["Mode Handlers"]:::mode
    end
```
