# idvorkin/vapi-call-viewer architecture

> Architecture diagram of the GitHub repository idvorkin/vapi-call-viewer, 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/idvorkin/vapi-call-viewer
- Repository: https://github.com/idvorkin/vapi-call-viewer

## Overview

Key Components to Include:

##### Core Application Components
- Data Models component (from models.py)
- Cache System component (from cache.py)

##### External Dependencies
- Textual Framework (for TUI)
- SQLite Database (for caching)
- Python Standard Library components

- [User] ←→ [TUI Interface Layer] ←→ [Application Core] ←→ [Cache Layer] ←→ [SQLite DB]

##### Component Details

a. TUI Interface Layer (calls.py):
- Subcomponents:
- Key Bindings Handler
- View Controllers
- Formatters (phone numbers, UTC conversion)

b. Application Core:
- Include:
- Data Models (models.py)
- Business Logic
- Call Cost Tracking

c. Cache Layer (cache.py):
- Cache Management
- Data Persistence
- Query Interface

- User Input → TUI Interface
- TUI Interface ↔ Application Core
- Application Core ↔ Cache Layer
- Cache Layer ↔ SQLite Database

##### Additional Elements
- Version requirements (Python 3.12+)

Special Considerations:

##### Local-first architecture
- Temporary file location for the SQLite DB
- Cache invalidation flow

##### Type System
- Pydantic model integration
- Strict typing boundaries

##### Testing Coverage
- Test coverage indicators
- Test file relationships (test_cache.py, test_calls.py)

Level of Detail:
- TUI Component Structure
- Cache Implementation
- Data Model Relationships

- Clear component boundaries
- Nested components
- Text annotations

Recommended Tools:
- PlantUML

Remember to:
- Version numbers for major dependencies
- Development workflow
- Test coverage boundaries
- Async operations if present
- Error handling flows

- How user interactions flow through the system
- Where data is stored and cached
- How the type system ensures data integrity
- The testing boundaries and coverage
- The overall architecture patterns used

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User_Layer
        User(("User"))
    end

    subgraph Interface_Layer
        TUI["TUI Interface"]
        KB["Key Bindings Handler"]
        VC["View Controllers"]
        DF["Display Formatters"]
    end

    subgraph Core_Layer
        DM["Data Models"]
        BL["Business Logic"]
        CT["Call Cost Tracking"]
    end

    subgraph Cache_Layer
        CM["Cache Management"]
        DP["Data Persistence"]
        QI["Query Interface"]
    end

    subgraph Storage_Layer
        DB[(SQLite DB)]
    end

    subgraph Testing_Layer
        TCH["Cache Tests"]
        TTUI["TUI Tests"]
    end

    subgraph Config_Layer
        PC["Project Config"]
        DW["Dev Workflow"]
        CC["Code Conventions"]
    end

    %% Relationships
    User --> TUI
    TUI --> KB
    TUI --> VC
    TUI --> DF
    KB --> BL
    VC --> BL
    DF --> BL
    BL --> DM
    BL --> CT
    DM --> CM
    CT --> CM
    CM --> DP
    DP --> QI
    QI --> DB
    TCH --> CM
    TTUI --> TUI

    %% Click Events
    click TUI "https://github.com/idvorkin/vapi-call-viewer/blob/main/calls.py"
    click DM "https://github.com/idvorkin/vapi-call-viewer/blob/main/models.py"
    click CM "https://github.com/idvorkin/vapi-call-viewer/blob/main/cache.py"
    click TCH "https://github.com/idvorkin/vapi-call-viewer/blob/main/test_cache.py"
    click TTUI "https://github.com/idvorkin/vapi-call-viewer/blob/main/test_calls.py"
    click PC "https://github.com/idvorkin/vapi-call-viewer/blob/main/pyproject.toml"
    click DW "https://github.com/idvorkin/vapi-call-viewer/tree/main/justfile"
    click CC "https://github.com/idvorkin/vapi-call-viewer/blob/main/CONVENTIONS.md"

    %% Styling
    classDef interface fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef cache fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef storage fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef test fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef config fill:#F0F8FF,stroke:#333,stroke-width:2px
    classDef user fill:#FFFFFF,stroke:#333,stroke-width:2px

    class User user
    class TUI,KB,VC,DF interface
    class DM,BL,CT core
    class CM,DP,QI cache
    class DB storage
    class TCH,TTUI test
    class PC,DW,CC config

    %% Legend
    subgraph Legend
        U[User Interface]:::interface
        C[Core Components]:::core
        CA[Cache Layer]:::cache
        S[Storage]:::storage
        T[Testing]:::test
        CO[Configuration]:::config
    end
```
