# rahulreddyp/safe-deposit-cloud-plumbing-system architecture

> Architecture diagram of the GitHub repository rahulreddyp/safe-deposit-cloud-plumbing-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rahulreddyp/safe-deposit-cloud-plumbing-system
- Repository: https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system

## Overview

##### Project Type & Purpose
- This is a multi-cloud, serverless SaaS application for secure and scalable data processing. The system leverages both AWS and GCP services, along with Firebase Authentication to secure user access.
- From the README, we note the use of AWS Lambda (and, by implication, components like DynamoDB via AWS), Google Vision AI for machine learning tasks, and Firebase for authentication and Cloud Functions. Meanwhile, the file tree shows several backend service directories (e.g., Lex Code for AWS Lambda functions, ML_CloudFunction in Python for ML tasks, and Pub-Sub Code for messaging). The FrontEnd directory (under “safebox”) contains a React-based application with components for home, Lex, MachineLearning, PubSub, Visualization, and profile management.

##### Analyzing the File Structure
- BackEnd Directory:
- Contains several distinct service implementations:
▪ “Lex Code”: Contains a JavaScript file (lambda_function.js) likely representing AWS Lambda–style code.
▪ “ML_CloudFunction”: Written in Python (cloudFunction.py) and its requirements file, it handles machine learning tasks (for example, Google Vision AI integration).
▪ “Pub-Sub Code”: Contains several Node.js scripts (getmessages.js, pubsubtrigger.js, pushmessages.js) for handling messaging aspects via Pub/Sub patterns.
▪ “functions”: This directory includes additional serverless functions (Firebase Cloud Functions) with files for image uploads and main index.js, among others, plus Firebase configuration (firebase.json, firestore rules/indexes).
- The presence of Firebase configuration files and Firestore rules suggests that Firebase is used for authentication or even data storage in parts of the system.

- FrontEnd Directory:
- Contains a React app (under “safebox”) which houses multiple components:
▪ HomePage (likely for the landing dashboard),
▪ Lex component (possibly interfacing with AWS Lambda functions),
▪ MachineLearning component (for ML file uploads handling ML tasks),
▪ PubSub component (for real-time messaging),
▪ Visualization component (to render analysis and visual results),
▪ profileManagement (for login and registration pages).
- Standard assets such as index.html, CSS, and additional resources are included.

a. Main Components:
- Frontend (React Application – “safebox”)
- Backend Service Clusters:
- Lex Service (AWS Lambda based; “Lex Code”)
- ML Service (Google Cloud Function – “ML_CloudFunction”)
- Pub/Sub Service (Event-driven messaging – “Pub-Sub Code”)
- Firebase Functions (Additional serverless business logic and image uploads)
- Authentication Service (Firebase Authentication as mentioned in the README)
- External Cloud Services:
- AWS Services: Lambda, DynamoDB, Amplify (for deployment and CI/CD)
- GCP Services: Cloud Functions, Google Vision AI
- CI/CD via GitLab

b. Relationships & Interactions:
- The Frontend interacts with the Firebase Authentication to secure access.
- Post authentication, the Frontend calls various backend endpoints:
- Requests for data processing may trigger the Lex Service.
- ML-related operations are forwarded to the ML Service.
- Real-time messaging flows through the Pub/Sub Service.
- Additional image processing or related functionalities are handled by Firebase Functions.
- Backend services can also communicate with external cloud services:
- Lex Code might interface with AWS Lambda and, indirectly, with AWS DynamoDB.
- ML Cloud Function connects with Google Vision AI.
- The Pub/Sub scripts manage event-driven workflows using Google Cloud Pub/Sub.
- Continuous deployment and infrastructure management is handled via AWS Amplify and GitLab pipelines.

c. Architectural Patterns / Design Principles:
- Serverless & Event-Driven Design: Each service (Lambda functions, Cloud Functions, Pub/Sub scripts) is built to execute on-demand, triggered by events.
- Separation of Concerns: The project clearly separates UI (React Frontend) from business logic (multiple backend services).
- Multi-Cloud Integration: The architecture intentionally integrates distinct cloud providers (AWS, GCP, Firebase) for resilience and to leverage specialized services (e.g., ML and serverless functions).

d. Relevant Technologies & Frameworks:
- Frontend: React (JavaScript), with routing and component-based structures.
- Backend: Node.js and Python for serverless functions, with Firebase configurations (firebase.json, Firestore rules).
- Cloud Services: AWS Lambda, DynamoDB, Amplify; Google Cloud Functions, Pub/Sub, Vision AI; Firebase for authentication.
- CI/CD: GitLab pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        A["Frontend Client (React)"]:::client
    end

    %% Backend Services
    subgraph "Backend Services"
        B["Lex Service (AWS Lambda – lambda_function.js)"]:::backend
        C["ML Service (Google Cloud Function – cloudFunction.py)"]:::backend
        D["Pub/Sub Service (getmessages.js, pubsubtrigger.js, pushmessages.js)"]:::backend
        E["Firebase Functions (gcs-image-upload.js, index.js)"]:::backend
        F["Firebase Config (firebase.json & firestore.rules)"]:::backend
    end

    %% External Cloud Services
    subgraph "External Cloud Services"
        G["AWS Services (Lambda, DynamoDB, Amplify)"]:::external
        H["GCP Services (Cloud Functions, Vision AI, Pub/Sub)"]:::external
        I["Firebase Authentication"]:::external
        J["GitLab CI/CD"]:::external
    end

    %% Connections from Client to Backend and External
    A -->|"AuthRequest"| I
    A -->|"API_Call"| B
    A -->|"API_Call"| C
    A -->|"API_Call"| D
    A -->|"API_Call"| E

    %% Backend Internal Connection
    E -->|"UsesConfig"| F

    %% Connections from Backend Services to External Services
    B -->|"AWS_Processing"| G
    C -->|"ML_Processing"| H
    D -->|"Event_Trigger"| H
    E -->|"Data_Upload"| I

    %% CI/CD Deployment Flow
    J -->|"CI/CD_Deploy"| G

    %% Click Events for Component Mapping
    click A "https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system/tree/main/FrontEnd/safebox"
    click B "https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system/blob/main/BackEnd/Lex Code/lambda_function.js"
    click C "https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system/blob/main/BackEnd/ML_CloudFunction/cloudFunction.py"
    click D "https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system/tree/main/BackEnd/Pub-Sub Code"
    click E "https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system/tree/main/BackEnd/functions"
    click F "https://github.com/rahulreddyp/safe-deposit-cloud-plumbing-system/blob/main/BackEnd/firebase.json"

    %% Styles
    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
```
