# yahuli/follow-in-fediverse architecture

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

- Interactive diagram: https://gitdiagram.com/yahuli/follow-in-fediverse
- Repository: https://github.com/yahuli/follow-in-fediverse

## Overview

##### Main Components
- UI Components: Distinctly mark out the Popup and Options interfaces. These are implemented as Vue components (src/Popup.vue, src/Option.vue) with corresponding TypeScript files (src/popup.ts, src/option.ts) to control UI logic and user interaction.
- Scripts and Core Logic:
- Background Script: Located in src/scripts/background.ts, it handles background tasks like listening for extension events and facilitating communication between components.
- Content Script: Found in src/scripts/content.ts, it interacts with the actual webpage, capturing context-specific data (like user profile data) and sending messages to the background script.
- Server/Communication Layer: The src/server.ts file acts as an abstraction layer to interact with external Fediverse servers.
- Fediverse API Integrations: In src/softwares, you find separate modules for each supported Fediverse platform (mastodon, misskey, pixelfed, fedibird). These modules encapsulate API specifics and make it easier for the extension to interact with multiple backends reliably.
- Utility Functions: The src/utils folder (e.g., chrome.ts) contains helper functions to interact with browser APIs or abstract common logic.

##### Relationships and Interactions
- Detail how the Popup and Options UIs send/receive data from the Background Script.
- Communication flows from the Content Script (which detects a user's profile on another server) to the Background Script and then to the Server/Software modules.
- How the Server/Software modules interact with external Fediverse APIs, and how the Background Script aggregates data and sends responses back to the UI components.
- Role of configuration management (user settings saved via the Options page) and how that configuration affects API calls made through the server integration layer.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clearly show the separation between UI (Popup/Options), background processes (scripts), and API integration (softwares).
- Modular Design: Emphasize the “softwares” directory that abstracts support for different Fediverse platforms via individual modules.

##### Relevant Technologies and Tools
- Vue.js: For building the Popup and Options interfaces.
- TypeScript: Used throughout the project for tooling and type safety.
- Vite: The build tool (configured via vite.config.ts) that bundles the extension.
- Chrome Extension APIs: Implicit through files like chrome.ts and the extension manifest.
- Localization: Handle multiple language support via the public/_locales directories.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Extension Shell / Manifest
    ExtensionShell["Extension Shell/Manifest"]:::shell

    %% UI Components Subgraph
    subgraph "User Interfaces"
        PopupUI["Popup UI"]:::ui
        OptionsUI["Options UI"]:::ui
    end

    %% Scripts and Core Logic Subgraph
    subgraph "Core Scripts"
        BackgroundScript["Background Script"]:::script
        ContentScript["Content Script"]:::script
    end

    %% Server/Communication and Fediverse Integration
    subgraph "API Integration & Utilities"
        ServerLayer["Server/Communication Layer"]:::server
        FediverseAPIs["Fediverse API Integrations"]:::fediverse
        UtilityFuncs["Utility Functions"]:::utility
    end

    %% Connections
    ExtensionShell -->|"loads"| PopupUI
    ExtensionShell -->|"loads"| OptionsUI
    ExtensionShell -->|"loads"| BackgroundScript
    ExtensionShell -->|"loads"| ContentScript

    PopupUI -->|"sendsAction"| BackgroundScript
    OptionsUI -->|"updatesConfig"| BackgroundScript
    ContentScript -->|"sendsData"| BackgroundScript

    BackgroundScript -->|"callsAPI"| ServerLayer
    ServerLayer -->|"delegates"| FediverseAPIs
    FediverseAPIs -->|"returnsResponse"| BackgroundScript

    BackgroundScript -->|"uses"| UtilityFuncs

    %% Click Events
    click ExtensionShell "https://github.com/yahuli/follow-in-fediverse/blob/master/public/manifest.json"
    click PopupUI "https://github.com/yahuli/follow-in-fediverse/blob/master/popup.html"
    click OptionsUI "https://github.com/yahuli/follow-in-fediverse/blob/master/option.html"
    click BackgroundScript "https://github.com/yahuli/follow-in-fediverse/blob/master/src/scripts/background.ts"
    click ContentScript "https://github.com/yahuli/follow-in-fediverse/blob/master/src/scripts/content.ts"
    click ServerLayer "https://github.com/yahuli/follow-in-fediverse/blob/master/src/server.ts"
    click FediverseAPIs "https://github.com/yahuli/follow-in-fediverse/tree/master/src/softwares"
    click UtilityFuncs "https://github.com/yahuli/follow-in-fediverse/tree/master/src/utils"

    %% Styles
    classDef shell fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef ui fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef script fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef server fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef fediverse fill:#D2B4DE,stroke:#512E5F,stroke-width:2px;
    classDef utility fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
```
