# yaseenbashat/savebox architecture

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

- Interactive diagram: https://gitdiagram.com/yaseenbashat/savebox
- Repository: https://github.com/yaseenbashat/savebox

## Overview

##### Project type and purpose
- This is a lightweight full-stack Node.js web application that aggregates and displays user profiles (and playlists) from multiple social platforms (GitHub, LinkedIn, Reddit, Twitter, YouTube).
- It uses Express as the HTTP server, EJS as the view-templating engine, and individual OAuth setup modules to authenticate with each external API.

##### File structure
Top-level files
- package.json / package-lock.json – project metadata and dependencies
- main.js – Express server entry point
- authSetupGitHub.js, authSetupLinkedIn.js, authSetupReddit.js, authSetupTwitter.js, authSetupYouTube.js – per-service OAuth configuration and token management
- readme.txt – (currently empty) intended for high-level docs
Directory “views” (EJS templates)
- index.ejs – homepage / service selection
- githubProfile.ejs, linkedinProfile.ejs, redditProfile.ejs, twitterProfile.ejs, youtubeProfile.ejs – templates rendering fetched data
- playlists.ejs – specialized YouTube playlists view

##### Extracted architectural insights (README is blank, so rely on conventions)
- Monolithic backend serving both API-calls and view rendering
- MVC-style separation: main.js + authSetup*.js = Controller/Service layer, views folder = View layer
- No persistent database—data flows directly from external APIs to the user’s browser via server-side rendering

##### Detailed element checklist
- Browser / Client node
- Express Server boundary containing:
– Route Handler (main.js)
– OAuth Modules (authSetup*.js)
– EJS Renderer + view templates folder
- External Social API clouds for GitHub, LinkedIn, Reddit, Twitter, YouTube

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser("Browser"):::client

    %% Backend Server
    subgraph "Backend Server"
        direction TB
        RouteHandler["Express Route Handler\n(main.js)"]:::server
        EjsRenderer["EJS Renderer"]:::view
        ViewsDir["views/"]:::viewDir

        subgraph "OAuth Adapters"
            direction TB
            GitHubAdapter["authSetupGitHub.js"]:::adapter
            LinkedInAdapter["authSetupLinkedIn.js"]:::adapter
            RedditAdapter["authSetupReddit.js"]:::adapter
            TwitterAdapter["authSetupTwitter.js"]:::adapter
            YouTubeAdapter["authSetupYouTube.js"]:::adapter
        end
    end

    %% External Social APIs
    subgraph "External Social APIs"
        direction TB
        GitHubAPI["GitHub API"]:::external
        LinkedInAPI["LinkedIn API"]:::external
        RedditAPI["Reddit API"]:::external
        TwitterAPI["Twitter API"]:::external
        YouTubeAPI["YouTube API"]:::external
    end

    %% Data Flow
    Browser -->|"HTTP Request"| RouteHandler
    RouteHandler -->|"invoke OAuth"| GitHubAdapter
    RouteHandler -->|"invoke OAuth"| LinkedInAdapter
    RouteHandler -->|"invoke OAuth"| RedditAdapter
    RouteHandler -->|"invoke OAuth"| TwitterAdapter
    RouteHandler -->|"invoke OAuth"| YouTubeAdapter

    GitHubAdapter -->|"OAuth Redirect / Callback"| GitHubAPI
    LinkedInAdapter -->|"OAuth Redirect / Callback"| LinkedInAPI
    RedditAdapter -->|"OAuth Redirect / Callback"| RedditAPI
    TwitterAdapter -->|"OAuth Redirect / Callback"| TwitterAPI
    YouTubeAdapter -->|"OAuth Redirect / Callback"| YouTubeAPI

    RouteHandler -->|"API Request (with Token)"| GitHubAPI
    RouteHandler -->|"API Request (with Token)"| LinkedInAPI
    RouteHandler -->|"API Request (with Token)"| RedditAPI
    RouteHandler -->|"API Request (with Token)"| TwitterAPI
    RouteHandler -->|"API Request (with Token)"| YouTubeAPI

    GitHubAPI -->|"JSON Data"| RouteHandler
    LinkedInAPI -->|"JSON Data"| RouteHandler
    RedditAPI -->|"JSON Data"| RouteHandler
    TwitterAPI -->|"JSON Data"| RouteHandler
    YouTubeAPI -->|"JSON Data"| RouteHandler

    RouteHandler -->|"render HTML"| EjsRenderer
    EjsRenderer -->|"HTTP Response"| Browser

    %% Click Events
    click RouteHandler "https://github.com/yaseenbashat/savebox/blob/main/main.js"
    click GitHubAdapter "https://github.com/yaseenbashat/savebox/blob/main/authSetupGitHub.js"
    click LinkedInAdapter "https://github.com/yaseenbashat/savebox/blob/main/authSetupLinkedIn.js"
    click RedditAdapter "https://github.com/yaseenbashat/savebox/blob/main/authSetupReddit.js"
    click TwitterAdapter "https://github.com/yaseenbashat/savebox/blob/main/authSetupTwitter.js"
    click YouTubeAdapter "https://github.com/yaseenbashat/savebox/blob/main/authSetupYouTube.js"
    click ViewsDir "https://github.com/yaseenbashat/savebox/tree/main/views/"
    click IndexTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/index.ejs"
    click GitHubProfileTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/githubProfile.ejs"
    click LinkedInProfileTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/linkedinProfile.ejs"
    click RedditProfileTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/redditProfile.ejs"
    click TwitterProfileTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/twitterProfile.ejs"
    click YouTubeProfileTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/youtubeProfile.ejs"
    click PlaylistsTemplate "https://github.com/yaseenbashat/savebox/blob/main/views/playlists.ejs"

    %% Individual template nodes (hidden for positioning)
    IndexTemplate["index.ejs"]:::view
    GitHubProfileTemplate["githubProfile.ejs"]:::view
    LinkedInProfileTemplate["linkedinProfile.ejs"]:::view
    RedditProfileTemplate["redditProfile.ejs"]:::view
    TwitterProfileTemplate["twitterProfile.ejs"]:::view
    YouTubeProfileTemplate["youtubeProfile.ejs"]:::view
    PlaylistsTemplate["playlists.ejs"]:::view

    %% Styles
    classDef client fill:#e0f7e9,stroke:#337a3e,stroke-width:2px
    classDef server fill:#d0e6ff,stroke:#1a5fb4,stroke-width:2px
    classDef adapter fill:#cfefff,stroke:#1a5fb4,stroke-width:2px
    classDef view fill:#ffe0f0,stroke:#b41a5f,stroke-width:2px
    classDef viewDir fill:#ffdfe0,stroke:#b41a5f,stroke-width:2px
    classDef external fill:#ffe6c2,stroke:#b4771a,stroke-width:2px
```
