# aniketsaliya/bubble architecture

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

- Interactive diagram: https://gitdiagram.com/aniketsaliya/bubble
- Repository: https://github.com/aniketsaliya/bubble

## Overview

##### Main Components
- Frontend: The “frontend” directory clearly shows a React-based application. It includes pages, components, state management, and static assets. This is the client-side layer where users interact with the application.
- Backend Servers: Two main backend components appear from the file structure:
- EC2: Contains Python scripts like app.py and various blog/question posting modules.
- Lambda Functions: The “lambda” directory holds numerous Python files (LF1, LF2, ... LF31) that represent serverless functions handling specific API endpoints and tasks.
- Machine Learning (ML): The “ML” directory houses notebooks, precomputed vector and metadata files, and other ML artifacts. This module is used for functionalities such as recommending similar blog posts, checking for explicit content, and sentiment analysis.
- AWS Infrastructure: As described in the README, the project leverages many AWS services (Cognito, API Gateway, S3, EC2, Lambda, IAM, Rekognition, SQS, Comprehend, CloudWatch, DynamoDB, OpenSearch). These enable authentication, secure API management, storage, server hosting, messaging, and search capabilities.

##### Relationships and Interactions
- The Frontend communicates with the backend via APIs. The API endpoints are managed via AWS API Gateway that routes requests to the appropriate backend service.
- Authentication: AWS Cognito is used to secure user authentication and possibly assist with user pool management. It should have a clear connection to the Frontend.
- EC2 as the hosting platform receives some requests directly (e.g., app.py, blog question posts) and might also serve as an application server.
- AWS Lambda functions handle discrete tasks (e.g., operations for professor reviews, content retrieval, vote handling) and are invoked either directly via API Gateway or via other services like AWS SQS.
- ML components operate alongside these core services. They may be invoked as separate API endpoints or triggered events, utilizing ML models to process content, suggest similar posts, and moderate content.
- AWS S3 could be used for storing static assets or user-generated content (e.g., images, attachments). AWS DynamoDB likely stores persistent application data such as user profiles, posts, and interactions. OpenSearch offers rich search capabilities over content.

##### Architectural Patterns and Design Principles
- Microservices/Serverless: With a distinct Lambda directory and many specific function scripts, the project follows a microservices or serverless paradigm where each Lambda function handles a separate concern.
- Separation of Concerns: The React frontend is decoupled from the backend logic (EC2 and Lambda). The ML functionalities are isolated in a separate directory.
- Integration via AWS API Gateway provides a unified API endpoint for front-end consumers to interact with both EC2-hosted services and Lambda serverless functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        A["User"]:::frontend
        B["React Frontend"]:::frontend
        C["AWS Cognito"]:::aws
    end

    %% Integration Layer
    subgraph "Integration Layer"
        D["API Gateway"]:::aws
    end

    %% Backend Services Layer
    subgraph "Backend Services"
        subgraph "EC2 Services"
            E["EC2 (Python App)"]:::backend
            E1["app.py"]:::backend
            E2["post_blog.py"]:::backend
            E3["post_question.py"]:::backend
            E --> E1
            E --> E2
            E --> E3
        end
        subgraph "Serverless Services"
            F["AWS Lambda Functions"]:::backend
        end
        G["Machine Learning Module"]:::ml
    end

    %% AWS Data & Services Layer
    subgraph "AWS Data & Services"
        H["AWS DynamoDB"]:::aws
        I["AWS S3"]:::aws
        J["AWS OpenSearch"]:::aws
        K["AWS CloudWatch"]:::aws
        L["AWS SQS"]:::aws
        M["AWS Infra Docs"]:::aws
    end

    %% Connections within Client Layer
    A -->|"interacts"| B
    B -->|"auth"| C
    C -->|"auth_response"| B

    %% Connection from Frontend to API Gateway
    B -->|"calls"| D

    %% API Gateway routes to backend services
    D -->|"routes"| E
    D -->|"routes"| F
    D -->|"routes"| G
    D -->|"auth_check"| C

    %% Backend to Data & Services connections
    E -->|"data_ops"| H
    E -->|"store_assets"| I
    E -->|"search"| J
    E -->|"logs"| K

    F -->|"async_calls"| L
    F -->|"logs"| K

    G -->|"model_data"| I

    %% Click Events
    click B "https://github.com/aniketsaliya/bubble/tree/main/frontend/"
    click E1 "https://github.com/aniketsaliya/bubble/blob/main/EC2/app.py"
    click E2 "https://github.com/aniketsaliya/bubble/blob/main/EC2/post_blog.py"
    click E3 "https://github.com/aniketsaliya/bubble/blob/main/EC2/post_question.py"
    click F "https://github.com/aniketsaliya/bubble/tree/main/lambda/"
    click G "https://github.com/aniketsaliya/bubble/tree/main/ML/"
    click M "https://github.com/aniketsaliya/bubble/blob/main/Architecture/README.md"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef aws fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef ml fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
