# mwaraic/my-web-feed architecture

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

- Interactive diagram: https://gitdiagram.com/mwaraic/my-web-feed
- Repository: https://github.com/mwaraic/my-web-feed

## Overview

##### Main Components
- Frontend (React):
- Located in the “frontend” folder.
- Developed using React with various pages (e.g., googleNews, reddit, twitter) and components (e.g., dashboard, login, signup).
- Includes assets like images and styles.
- Uses routing and Firebase for authentication (client-side integration in “frontend/src/firebase”).
- Backend (Node.js/Express):
- Located in the “backend” folder.
- Contains API endpoints for different content sources:
- /news (Google News integration)
- /reddit (Reddit integration)
- /tweets (Twitter integration)
- /preferences (for managing user preferences)
- Organized under “backend/src/apis” with dedicated subdirectories for each content source.
- Contains a server entry point (“backend/src/server.js”).
- Manages external service integrations using client libraries for Firebase, MongoDB, and Twitter (see “backend/src/client/…”).
- External Services & Integrations:
- Authentication: Firebase for secure user authentication.
- Database: MongoDB for storing user preferences and possibly content-related data.
- Social/Content APIs: External API calls to Google News, Reddit, and Twitter.
- Docker Components:
- Dockerfiles provided for both backend (node container) and frontend (react container).
- Docker Compose setup in both folders (along with a top-level Makefile for “make start”) which helps orchestrate containers.
- Documentation:

##### Relationships and Data Flow
- Users interact with the Frontend (React app) via a web browser.
- The Frontend sends user requests (e.g., logins, setting preferences, fetching feeds) to the Backend API.
- The Backend handles these requests:
- It authenticates users (using Firebase integration).
- It retrieves and aggregates content from external services (Google News, Reddit, and Twitter) using dedicated API endpoints.
- It interfaces with MongoDB to store and retrieve user preferences.
- Docker is used to containerize and manage both the frontend and backend services. The docker-compose files indicate a dependency where both containers need to be started together.

##### Architectural Patterns and Design Principles
- Separation of concerns: Clear division between the frontend (presentation) and the backend (business logic and API integrations).
- Modular API design: Each feed (news, reddit, tweets) has its own dedicated subdirectory/API module under the backend.
- Use of containerization: Enhances isolated environments for easier deployment and scaling.
- External integration: Clearly defined interfaces with third-party services (social media APIs and Firebase).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User Browser"):::external

    subgraph "Frontend Layer"
        subgraph "Frontend Docker Container"
            FE_A("React App"):::frontend
            FE_P1("Google News Page"):::frontend
            FE_P2("Reddit Page"):::frontend
            FE_P3("Twitter Page"):::frontend
            FE_C1("Dashboard Component"):::frontend
            FE_C2("Login Component"):::frontend
            FE_C3("Signup Component"):::frontend
            FE_F("Firebase (Client)"):::frontend
            FE_D("Dockerfile (Frontend)"):::docker
        end
    end

    subgraph "Backend Layer"
        subgraph "Backend Docker Container"
            BE_S("Node.js Server"):::backend
            BE_A1("News API Endpoint"):::backend
            BE_A2("Reddit API Endpoint"):::backend
            BE_A3("Tweets API Endpoint"):::backend
            BE_A4("Preferences API Endpoint"):::backend
            BE_F("Firebase (Backend)"):::backend
            BE_M("MongoDB Integration"):::backend
            BE_T("Twitter Client"):::backend
            BE_D("Dockerfile (Backend)"):::docker
        end
    end

    subgraph "External Services"
        EXT_GN("Google News API"):::external
        EXT_RE("Reddit API"):::external
        EXT_TW("Twitter API"):::external
        EXT_FA("Firebase Auth"):::external
        EXT_MG("MongoDB Database"):::external
    end

    DOC("Documentation"):::external
    DOCKER_COMPOSE("Docker Compose"):::docker

    User -->|"uses"| FE_A
    FE_A -->|"navigates"| FE_P1
    FE_A -->|"navigates"| FE_P2
    FE_A -->|"navigates"| FE_P3
    FE_A -->|"renders"| FE_C1
    FE_A -->|"renders"| FE_C2
    FE_A -->|"renders"| FE_C3
    FE_A -->|"integrates"| FE_F

    FE_A -->|"API_request"| BE_S

    BE_S -->|"aggregates"| BE_A1
    BE_S -->|"aggregates"| BE_A2
    BE_S -->|"aggregates"| BE_A3
    BE_S -->|"aggregates"| BE_A4

    BE_A1 -->|"fetches"| EXT_GN
    BE_A2 -->|"fetches"| EXT_RE
    BE_A3 -->|"fetches"| EXT_TW

    BE_S -->|"auth_check"| BE_F
    BE_F -->|"verifies"| EXT_FA

    BE_S -->|"stores_retrieves"| BE_M
    BE_M -->|"connects"| EXT_MG

    BE_S -->|"calls"| BE_T

    DOCKER_COMPOSE --> FE_D
    DOCKER_COMPOSE --> BE_D
    DOCKER_COMPOSE --- FE_A
    DOCKER_COMPOSE --- BE_S

    click FE_A "https://github.com/mwaraic/my-web-feed/tree/main/frontend/"
    click FE_P1 "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/pages/googleNews/googleNews.js"
    click FE_P2 "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/pages/reddit/reddit.js"
    click FE_P3 "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/pages/twitter/twitter.js"
    click FE_C1 "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/component/dashboard/dashboard.js"
    click FE_C2 "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/component/login/login.js"
    click FE_C3 "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/component/signup/signup.js"
    click FE_F "https://github.com/mwaraic/my-web-feed/blob/main/frontend/src/firebase/firebase.js"
    click BE_S "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/server.js"
    click BE_A1 "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/apis/news/news.js"
    click BE_A2 "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/apis/reddit/reddit.js"
    click BE_A3 "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/apis/tweets/tweets.js"
    click BE_A4 "https://github.com/mwaraic/my-web-feed/tree/main/backend/src/apis/preferences/"
    click BE_F "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/client/firebase/firebase.js"
    click BE_M "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/client/mongodb/mongodb.js"
    click BE_T "https://github.com/mwaraic/my-web-feed/blob/main/backend/src/client/twitter/twitter.js"
    click BE_D "https://github.com/mwaraic/my-web-feed/tree/main/backend/docker/node/Dockerfile"
    click FE_D "https://github.com/mwaraic/my-web-feed/tree/main/frontend/docker/react/Dockerfile"
    click DOC "https://github.com/mwaraic/my-web-feed/tree/main/documentation/images/"

    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef external fill:#FFCC80,stroke:#F57C00,stroke-width:2px;
    classDef docker fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
```
