# leo-step/today architecture

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

- Interactive diagram: https://gitdiagram.com/leo-step/today
- Repository: https://github.com/leo-step/today

## Overview

##### Main Components Identification
- Chatbot Frontend:
- Located in the “chatbot” folder. This is a React project that serves as the chat interface. It doubles as a mobile app (using Capacitor) and a web chat UI.
- Key technologies: React, TypeScript, Vite, and Capacitor for mobile.
- Extension:
- Found in the “extension” folder, this is another React project tailored for a Chrome extension. It includes UI components for various functions (e.g., chat, carousel, weather, study mode).
- Server:
- Under the “server” directory, you see Python files that define endpoints (such as the chat POST endpoint) and contain additional modules for handling memory, hybrid search, model interactions, and templates.
- This component acts as both a chat backend and a widget data server.
- Pipelines:
- The “pipelines” folder contains multiple Python scripts for crawling websites, processing emails, and migrating or processing data from various sources (courses, eating clubs, locations).
- These likely run either via cron jobs (as hinted in the “.github/workflows” folder) or manually to update or ingest data.
- Analysis:
- The “analysis” directory includes Python scripts for statistical analysis, clustering (e.g., kmeans), generation of CSV files, and visualization (charts, heatmaps) of chatbot conversation data.
- GitHub Workflows:
- The “.github/workflows” folder holds YAML files that likely automate tasks such as generating emails and running cron jobs.

##### Architectural Relationships and Interactions
- The Chatbot (and its mobile version) and the Extension act as clients. They communicate with the Server over HTTP REST endpoints (e.g., POST http://127.0.0.1:8000/api/chat).
- The Server is the core backend handling requests from these frontend clients and delivering responses, managing session data, and potentially interacting with other services and modules (like hybrid_search or memory).
- Pipelines operate as scheduled or manual backend tasks (potentially triggered via cron) to gather external data from web crawling, emails, or scraping. Their output can feed into the Server or the Analysis modules.
- Analysis scripts process and generate insights based on conversation data stored/produced by the Server. They might also generate visualizations and export data for further use.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Frontend (chatbot, extension) is clearly separated from backend (server) logic.
- Data processing is modularized into separate pipelines and analysis modules.
- Microservices-like Modularity:
- While it might not be a distributed microservices architecture, the segregation of pipelines, analysis, and the main server provides a modular design that benefits maintenance and scalability.
- Data Flow:
- There is a clear flow of data: from client requests (chatbot/extension) to server processing, then from server (or stored data) to analysis and visualization in separate modules.

##### Relevant Technologies, Frameworks, and Libraries
- Chatbot:
- React, Vite, TypeScript – for a modern, fast, and maintainable UI.
- Capacitor – to build cross-platform mobile apps.
- Extension:
- React again with TypeScript; standard Chrome extension manifest usage.
- Server:
- Python – likely using a framework (Flask or similar) to expose API endpoints.
- Additional libraries for handling prompts, models, and hybrid search might be in use.
- Pipelines & Analysis:
- Python scripts use libraries for data processing (possibly Pandas, scikit-learn for clustering) and visualization.
- Deployment and CI/CD:
- GitHub Workflows (cron and scheduled tasks) plus instructions for deploying to Heroku highlight deployment considerations.

##### Suggested Elements
- A corner labeled “CI/CD & Cron” showing GitHub Workflows triggering tasks in Pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Components
    A["Chatbot UI (Web/Mobile)"]:::frontend
    B["Chrome Extension"]:::frontend

    %% Server Component
    C["Server/API"]:::backend

    %% Processing Components
    D["Pipelines (Data Ingestion/Scraping)"]:::pipeline
    E["Analysis (Data Processing/Visualization)"]:::analysis

    %% CI/CD and Automation
    F["CI/CD & Cron (GitHub Workflows)"]:::ci

    %% Connections from UI to Server
    A -->|"HTTP_REST"| C
    B -->|"HTTP_REST"| C

    %% Connections from Pipelines to Server and Analysis
    D -->|"data_ingestion"| C
    D -->|"data_feed"| E
    
    %% Connection from Server to Analysis
    C -->|"chat_data"| E

    %% CI/CD triggering Pipelines
    F -->|"triggers"| D

    %% Click Events
    click A "https://github.com/leo-step/today/tree/main/chatbot/"
    click B "https://github.com/leo-step/today/tree/main/extension/"
    click C "https://github.com/leo-step/today/tree/main/server/"
    click D "https://github.com/leo-step/today/tree/main/pipelines/"
    click E "https://github.com/leo-step/today/tree/main/analysis/"
    click F "https://github.com/leo-step/today/tree/main/.github/workflows/"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef pipeline fill:#ffa500,stroke:#000,stroke-width:1px;
    classDef analysis fill:#dda0dd,stroke:#000,stroke-width:1px;
    classDef ci fill:#d3d3d3,stroke:#000,stroke-width:1px;
```
