# ojoven/odiometro architecture

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

- Interactive diagram: https://gitdiagram.com/ojoven/odiometro
- Repository: https://github.com/ojoven/odiometro

## Overview

##### Main Components

a) Frontend Layer:
- Vue.js application structure
- Socket.io client
- Real-time graph component (Smoothie.js)
- Component hierarchy (showing key Vue components)

b) Backend Layer:
- Node.js/Express server
- Socket.io server
- Twitter Stream Integration
- Database Layer (MySQL)

##### Data Flow Indicators

- Twitter API → Backend (Twitter Stream)
- Backend → Frontend (Socket.io real-time updates)
- Backend ↔ Database (data persistence)
- Frontend Component interactions (through Event Bus)

##### Component Details

For the Vue.js frontend, show:
- Store (store.js)
- Event Bus (bus.js)
- Key components:
- RealTimeGraph
- MostHatedUser
- MostHatefulUser
- TweetShow
- Historic

##### State management and event propagation

- How tweets are captured and processed
- How real-time updates are propagated
- How the frontend components interact
- How data is persisted and retrieved

This system design should clearly communicate the application's architecture while highlighting its real-time monitoring capabilities and data processing pipeline.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef socket fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        D[Database]:::database
        E[External]:::external
        S[Socket.io]:::socket
    end

    %% Frontend Layer
    subgraph Frontend
        Browser["Browser (Vue.js App)"]
        MainView["Main View"]:::frontend
        Store["Store Management"]:::frontend
        EventBus["Event Bus"]:::frontend
        SocketClient["Socket.io Client"]:::socket
        
        subgraph Components
            RTGraph["Real-time Graph"]:::frontend
            MHUser["Most Hated User"]:::frontend
            MFUser["Most Hateful User"]:::frontend
            TweetShow["Tweet Show"]:::frontend
            Historic["Historic View"]:::frontend
        end
    end

    %% Backend Layer
    subgraph Backend
        ExpressServer["Express Server"]:::backend
        SocketServer["Socket.io Server"]:::socket
        TwitterHandler["Twitter Stream Handler"]:::backend
        TweetProcessor["Tweet Processing Logic"]:::backend
        Config["Configuration"]:::backend
        Routes["API Routes"]:::backend
    end

    %% Database Layer
    subgraph Database
        MySQL["MySQL Database"]:::database
        TweetModel["Tweet Model"]:::database
        HistoricModel["Historic Model"]:::database
        BotModel["OdiometroBot Model"]:::database
    end

    %% External Services
    TwitterAPI["Twitter API"]:::external

    %% Relationships
    TwitterAPI --> TwitterHandler
    TwitterHandler --> TweetProcessor
    TweetProcessor --> SocketServer
    SocketServer --> SocketClient
    SocketClient --> Store
    Store --> Components
    EventBus --> Components
    ExpressServer --> Routes
    Routes --> MySQL
    TweetProcessor --> MySQL

    %% Click Events
    click ExpressServer "https://github.com/ojoven/odiometro/blob/master/app.js"
    click TwitterHandler "https://github.com/ojoven/odiometro/blob/master/app/lib/twitterStream.js"
    click TweetProcessor "https://github.com/ojoven/odiometro/blob/master/app/lib/track.js"
    click MySQL "https://github.com/ojoven/odiometro/blob/master/app/lib/database.js"
    click SocketClient "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/socket.js"
    click Store "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/store.js"
    click EventBus "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/bus.js"
    click RTGraph "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/components/real_time_graph.js"
    click MHUser "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/components/most_hated_user.js"
    click MFUser "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/components/most_hateful_user.js"
    click TweetShow "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/components/tweet-show.js"
    click Historic "https://github.com/ojoven/odiometro/blob/master/public/js/src/app/components/historic.js"
    click TweetModel "https://github.com/ojoven/odiometro/blob/master/app/models/Tweet.js"
    click HistoricModel "https://github.com/ojoven/odiometro/blob/master/app/models/Historic.js"
    click BotModel "https://github.com/ojoven/odiometro/blob/master/app/models/OdiometroBot.js"
    click Routes "https://github.com/ojoven/odiometro/blob/master/routes.js"
    click MainView "https://github.com/ojoven/odiometro/blob/master/public/views/index.html"
    click Config "https://github.com/ojoven/odiometro/blob/master/config/odiometro.json"
```
