# tattle-made/uli architecture

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

- Interactive diagram: https://gitdiagram.com/tattle-made/uli
- Repository: https://github.com/tattle-made/uli

## Overview

##### Main Components

a) Browser Extension Components:
- Plugin Frontend (React-based UI)
- Content Scripts (for Twitter integration)
- Background Service
- Local Storage

b) Backend Services:
- API Server (Express.js)
- Authentication Service
- Database Layer (SQL with Sequelize)
- S3 Storage Service
- ML Classification Service

c) External Services:
- Browser APIs (Chrome/Firefox)
- Twitter Platform
- Email Service

**[Client Layer]**
- Browser Extension UI
- Content Scripts
- Background Scripts

**[Communication Layer]**
- Browser APIs
- REST APIs

**[Server Layer]**
- API Server
- Authentication
- ML Services

**[Data Layer]**
- SQL Database
- S3 Storage

##### Key Relationships to Highlight

- Content Script ↔ Twitter DOM interaction
- Background Service ↔ API Server communication
- User Authentication flow
- Data flow for slur detection and replacement
- Archive storage workflow
- ML classification process

##### Component Details

Frontend Components:
- Options UI
- Tweet Controls
- Slur Detection Interface
- Archive Management
- User Preferences

Backend Services:
- User Management
- Post Processing
- Feedback System
- Slur Detection
- Archive Management
- ML Classification

Database Models:
- Users
- Preferences
- Posts
- Feedback
- Slurs
- Categories

##### Implementation Notes

- Use standardized UML notation
- API endpoints
- Database relationships
- Asynchronous processes
- Security boundaries
- Language/region specific handling

##### Technical Stack Indicators

- React/Grommet UI
- Express.js Backend
- Sequelize ORM
- AWS S3
- Docker containers
- Browser APIs

Remember to highlight the privacy-focused architecture and the multi-language support aspects, as these are core to the project's mission of protecting marginalized users.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef external fill:#f1c40f,color:black
    classDef security fill:#e74c3c,color:white
    classDef storage fill:#9b59b6,color:white
    classDef ml fill:#e67e22,color:white

    %% Client Layer
    subgraph BrowserExtension
        UI["Plugin Frontend"]:::frontend
        CS["Content Scripts"]:::frontend
        BS["Background Service"]:::frontend
        LS["Local Storage"]:::storage
        BC["Browser Compatibility"]:::frontend
        SR["Slur Detection/Replace"]:::frontend
        TI["Twitter Integration"]:::frontend
    end

    %% Communication Layer
    subgraph APIs
        BA["Browser APIs"]:::external
        RA["REST APIs"]:::backend
    end

    %% Server Layer
    subgraph Backend
        AS["API Server"]:::backend
        Auth["Authentication Service"]:::security
        MLS["ML Classification"]:::ml
        ES["Email Service"]:::backend
        UP["User Preferences"]:::backend
        AM["Archive Management"]:::backend
        FS["Feedback System"]:::backend
    end

    %% Data Layer
    subgraph Storage
        DB[(SQL Database)]:::storage
        S3["S3 Storage"]:::storage
    end

    %% External Services
    TP["Twitter Platform"]:::external

    %% Relationships
    UI --> BS
    UI --> CS
    CS --> TI
    TI --> TP
    BS --> BC
    BC --> BA
    BS --> RA
    RA --> AS
    AS --> Auth
    AS --> MLS
    AS --> ES
    AS --> UP
    AS --> AM
    AS --> FS
    Auth --> DB
    MLS --> DB
    UP --> DB
    AM --> S3
    FS --> DB
    CS --> SR

    %% Click events
    click UI "https://github.com/tattle-made/Uli/tree/main/browser-extension/plugin/src/ui-components/"
    click CS "https://github.com/tattle-made/Uli/blob/main/browser-extension/plugin/src/content-script.js"
    click BS "https://github.com/tattle-made/Uli/blob/main/browser-extension/plugin/src/background.js"
    click AS "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/index.js"
    click Auth "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/controllers/auth.js"
    click DB "https://github.com/tattle-made/Uli/tree/main/browser-extension/api-server/db/models/"
    click S3 "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/s3.js"
    click MLS "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/service-classifier.js"
    click TI "https://github.com/tattle-made/Uli/tree/main/browser-extension/plugin/src/twitter/"
    click ES "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/controller-email.js"
    click SR "https://github.com/tattle-made/Uli/blob/main/browser-extension/plugin/src/slur-replace.js"
    click UP "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/controllers/preference.js"
    click AM "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/controllers/archive.js"
    click FS "https://github.com/tattle-made/Uli/blob/main/browser-extension/api-server/controllers/feedback.js"
    click BC "https://github.com/tattle-made/Uli/blob/main/browser-extension/plugin/src/browser-compat.js"
```
