# tom-platform/tom-server-python architecture

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

- Interactive diagram: https://gitdiagram.com/tom-platform/tom-server-python
- Repository: https://github.com/tom-platform/tom-server-python

## Overview

##### Main Components

a. Core Server Components:
- WebSocket Server (primary communication hub)
- Base Component System
- Configuration Management
- Database Layer

b. Service Layer:
- Running Service
- Martial Arts Service
- PandaLens Service
- Memory Assistance Service
- Learning Service
- Dashboard Service
- Context Service

c. API Integration Layer:
- Cloud Vision API
- Fitbit Web API
- Geoapify API
- Google Maps API
- HoloLens API
- LangChain LLM APIs (OpenAI, Gemini, Anthropic)
- Local Services (CLIP, LLM, Vector DB)

d. Processors:
- YOLOv8 Object Detection
- Background Audio Classifier
- Emotion Classifier
- Whisper Speech Recognition

e. Data Management:
- Protocol Buffers (DataFormat)
- Database Models
- Memory Management

**[Client Layer]**

**[Communication Layer (WebSocket)]**

**[Service Layer]**

**[Processing Layer]**

**[API Integration Layer]**

**[Data Layer]**

##### Connection Types

- Double lines: High-bandwidth connections (e.g., video streams)

##### Important Details

- WebSocket communication on port 8090
- Protocol Buffer message types between components
- Database table relationships
- External API authentication points
- Real-time processing pipelines
- Service state management

##### Subdiagrams

- Running Service Architecture
- Martial Arts Service Flow
- PandaLens Service Pipeline
- Memory Assistance System

##### Notes

- Real-time nature of the system
- Scalability points
- Configuration dependencies
- Security boundaries
- Error handling paths

Remember to include documentation references and link to the DeveloperGuide.md for detailed implementation guidelines.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph Communication
        WS["WebSocket Server"]:::server
    end

    subgraph Core
        BC["Base Component System"]:::core
        CM["Configuration Management"]:::core
        DB["Database Layer"]:::database
    end

    subgraph "Service Layer"
        RS["Running Service"]:::service
        MAS["Martial Arts Service"]:::service
        PLS["PandaLens Service"]:::service
        MES["Memory Assistance Service"]:::service
        LS["Learning Service"]:::service
        DS["Dashboard Service"]:::service
        CS["Context Service"]:::service
    end

    subgraph "Processing Layer"
        YOLO["YOLOv8 Detector"]:::processor
        BAC["Background Audio Classifier"]:::processor
        EC["Emotion Classifier"]:::processor
        WP["Whisper Speech Recognition"]:::processor
    end

    subgraph "API Integration"
        CV["Cloud Vision API"]:::api
        FB["Fitbit Web API"]:::api
        GEO["Geoapify API"]:::api
        GM["Google Maps API"]:::api
        HL["HoloLens API"]:::api
        LC["LangChain LLM APIs"]:::api
        LCS["Local Services"]:::api
    end

    subgraph "Data Management"
        PB["Protocol Buffers"]:::data
        DBM["Database Models"]:::data
        MM["Memory Management"]:::data
    end

    %% Connections
    CL <--> WS
    WS --> BC
    BC --> CM
    BC --> DB

    %% Service Connections
    BC --> RS & MAS & PLS & MES & LS & DS & CS

    %% Processing Layer Connections
    PLS --> YOLO
    MES --> BAC
    MAS --> EC
    CS --> WP

    %% API Integration Connections
    PLS --> CV
    RS --> FB
    CS --> GEO
    CS --> GM
    MAS --> HL
    MES & LS --> LC
    PLS & MES --> LCS

    %% Data Management Connections
    BC --> PB
    DB --> DBM
    MES & CS --> MM

    %% Click Events
    click WS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Websocket/socket_server.py"
    click BC "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/base_component.py"
    click CM "https://github.com/TOM-Platform/TOM-Server-Python/tree/main/Config/"
    click DB "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Database/database.py"
    click RS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/running_service/running_service.py"
    click MAS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/martial_arts_service/martial_arts_service.py"
    click PLS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/pandalens_service/pandalens_service.py"
    click MES "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/memory_assistance_service/memory_assistance_service.py"
    click LS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/learning_service/learning_service.py"
    click DS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/dashboard_service/dashboard_service.py"
    click CS "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Services/context_service/context_service.py"
    click CV "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/APIs/cloud_vision/VisionClient.py"
    click FB "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/APIs/fitbit_web/web_api.py"
    click GEO "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/APIs/geoapify_api/geoapify_api.py"
    click GM "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/APIs/google_maps/google_maps_api.py"
    click HL "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/APIs/hololens/hololens_portal.py"
    click LC "https://github.com/TOM-Platform/TOM-Server-Python/tree/main/APIs/langchain_llm/"
    click LCS "https://github.com/TOM-Platform/TOM-Server-Python/tree/main/APIs/local_clip/"
    click YOLO "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Processors/Yolov8/detector.py"
    click BAC "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Processors/BackgroundAudioClassifier/background_audio_classifier.py"
    click EC "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Processors/EmotionClassifier/emotion_classifier.py"
    click WP "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Processors/Whisper/transcribe.py"
    click PB "https://github.com/TOM-Platform/TOM-Server-Python/tree/main/DataFormat/ProtoFiles/"
    click DBM "https://github.com/TOM-Platform/TOM-Server-Python/tree/main/Database/Models/"
    click MM "https://github.com/TOM-Platform/TOM-Server-Python/blob/main/Memory/Memory.py"

    %% Styling
    classDef default fill:#fff,stroke:#000,stroke-width:1px
    classDef server fill:#add8e6,stroke:#000
    classDef core fill:#87ceeb,stroke:#000
    classDef service fill:#98fb98,stroke:#000
    classDef processor fill:#ffa500,stroke:#000
    classDef api fill:#dda0dd,stroke:#000
    classDef data fill:#f0e68c,stroke:#000
    classDef database fill:#b8860b,stroke:#000
```
