# sudhirkumar6009/storagex architecture

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

- Interactive diagram: https://gitdiagram.com/sudhirkumar6009/storagex
- Repository: https://github.com/sudhirkumar6009/storagex

## Overview

##### Project Type & Purpose
- StorageX is a full-stack decentralized file-storage DApp.
- Frontend: React + TypeScript SPA (Vite/TailwindCSS) with Web3Auth/GoogleAuth.
- Backend: Node.js/Express handles encryption, IPFS via Filebase API, and MongoDB metadata.
- External services: IPFS (Filebase S3 gateway), MongoDB Atlas, Ethereum/Polygon via Infura, Web3Auth, Google OAuth.

##### File Structure
- Top-level split:
– /frontend: React components, contexts (Auth, Web3, Profile), UI libs, hooks, public assets, Vite config.
– /backend: Express server.js, modules for Filebase (IPFS), Mongo operations, Profile CRUD, Signin (Google OAuth), cryptoUtils.
- Config & deployment: vercel.json (frontend & backend), .env usage, package.json scripts.
- No microservices—single monolithic backend; SPA frontend.

##### Extract Architectural Insights from README
- DApp (client consults blockchain via Web3Auth/Infura + wallet).
- File uploads go through backend to IPFS/Filebase.
- Metadata (CID, profile data) stored in MongoDB Atlas.
- Authentication:
– Web3Auth (wallet login) on client.
– Optional Google OAuth → backend.
- Deployment: frontend on Vercel; backend on Render.

##### Main Components & Their Interactions
a. End User (Browser)
– UI (React + TS + Tailwind)
– Wallet connectors: Web3Auth, MetaMask, WalletConnect
– Google OAuth flow via backend
b. API Layer (Backend, Node.js/Express)
– Auth endpoints (Web3Auth token verification, Google OAuth)
– Filebase modules: uploadFile.js, deleteFile.js, listoutFiles.js
– Mongo modules: storePublicAddressMongo.js, cidMatchingMongo.js, mongoProfile.js
– Profile endpoints: fetchProfile.js, mongoProfile.js
– cryptoUtils.js for encrypt/decrypt
c. Data Stores & External Services
– IPFS via Filebase S3-compatible API
– MongoDB Atlas (metadata store)
– Ethereum/Polygon networks via Infura (for on-chain authentication if extended)
– Google OAuth (Web2)
d. Deployment & Infrastructure
– Frontend on Vercel (VITE_BACKEND_PORT_URL)
– Backend on Render (BACKEND_PORT_URL)
– Environment variables for credentials

##### Architectural Patterns & Design Principles
- SPA (Single-Page Application) decoupled from backend API
- “Thin” backend: orchestrates IPFS & Mongo calls, handles encryption
- Contexts in React provide global state (AuthContext, Web3Context, ProfileContext)
- Modular directory structure: separate Filebase, Mongo, Profile, Signin concerns
- Clear separation of concerns: UI, business logic, persistence, and external integrations

1) Client/UI Layer
2) API / Business Logic Layer
3) Data Layer
4) External Blockchains & Auth Providers
- Browser/React App
- Auth Module (Web3Auth & Google OAuth)
- Express API Server
- Filebase (IPFS Gateway)
- MongoDB Atlas
- Infura/Ethereum Network
– Browser → Express: HTTPS REST calls (Auth, Upload, Download, Profile)
– Browser ↔ Web3Auth/Infura: JSON-RPC calls for wallet operations
– Express → Filebase: HTTPS S3 API (upload/download)
– Express → MongoDB: MongoDB driver calls (insert, query)
– Express ↔ Google OAuth: OAuth2 redirects / token exchange
d. Data flows:
- File Upload: UI → Express → Filebase → CID → Express → MongoDB → UI
- File Fetch: UI → Express → MongoDB → Express → Filebase → UI
- Auth Flow: UI → Web3Auth/Infura (wallet sign) → Express → MongoDB (store address)
- Google Login: UI → Express (googleAccount.js) → OAuth endpoints → Express → UI
e. Technologies next to each component (e.g., “React + TS”, “Express + Node.js”, “MongoDB Atlas”, “Filebase IPFS API”, “Infura”).

##### Final Checklist
- All components labeled clearly.
- Technology stacks noted.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client/UI Layer"
        direction TB
        FE_SPA["Frontend SPA<br/>(React + TypeScript + TailwindCSS)"]:::frontend
        subgraph "SPA Modules"
            direction TB
            AuthContexts["Auth Contexts<br/>(Web3Auth, MetaMask, WalletConnect)"]:::frontend
            ProfileCtx["Profile Context"]:::frontend
            UIComps["UI Components & Libraries"]:::frontend
            Hooks["Client Hooks"]:::frontend
        end
    end

    subgraph "API / Business Logic Layer"
        direction TB
        ExpressAPI["Express API Server<br/>(Node.js + Express)"]:::backend
        subgraph "Auth & Profile Endpoints"
            direction TB
            AuthGO["Google OAuth Endpoint"]:::backend
            ProfileFetch["Fetch Profile Endpoint"]:::backend
            ProfileMongo["Profile Mongo Module"]:::backend
        end
        subgraph "File & DB Modules"
            direction TB
            FilebaseMods["Filebase Modules<br/>(IPFS S3 API)"]:::backend
            MongoMods["MongoDB Modules"]:::backend
            CryptoUtils["Crypto Utilities"]:::backend
        end
    end

    subgraph "Data Layer"
        direction TB
        MongoAtlas["MongoDB Atlas"]:::datastore
        IPFSFilebase["IPFS via Filebase S3 Gateway"]:::datastore
    end

    subgraph "External Blockchains & Auth Providers"
        direction TB
        Infura["Ethereum/Polygon via Infura"]:::external
        Web3AuthProv["Web3Auth Provider"]:::external
        GoogleOAuthServ["Google OAuth Service"]:::external
    end

    %% Connections
    FE_SPA -->|"HTTPS REST calls"| ExpressAPI
    FE_SPA -->|"JSON-RPC eth_requestAccounts"| Infura
    FE_SPA -->|"Wallet Login"| Web3AuthProv
    FE_SPA -->|"Initiate Google Login"| AuthGO
    ExpressAPI -->|"S3 API calls"| IPFSFilebase
    ExpressAPI -->|"MongoDB driver calls"| MongoAtlas
    ExpressAPI -->|"OAuth2 token exchange"| GoogleOAuthServ
    ExpressAPI -->|"verify on-chain auth"| Infura
    AuthGO -->|"OAuth2 redirects"| GoogleOAuthServ

    %% Click Events
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/tree/main/frontend/src"
    click AuthContexts "https://github.com/sudhirkumar6009/storagex/tree/main/frontend/src/contexts"
    click ProfileCtx "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/src/contexts/ProfileContext.tsx"
    click UIComps "https://github.com/sudhirkumar6009/storagex/tree/main/frontend/src/components"
    click Hooks "https://github.com/sudhirkumar6009/storagex/tree/main/frontend/src/hooks"
    click ExpressAPI "https://github.com/sudhirkumar6009/storagex/blob/main/backend/server.js"
    click AuthGO "https://github.com/sudhirkumar6009/storagex/blob/main/backend/Signin/googleAccount.js"
    click ProfileFetch "https://github.com/sudhirkumar6009/storagex/blob/main/backend/Profile/fetchProfile.js"
    click ProfileMongo "https://github.com/sudhirkumar6009/storagex/blob/main/backend/Profile/mongoProfile.js"
    click FilebaseMods "https://github.com/sudhirkumar6009/storagex/tree/main/backend/Filebase"
    click MongoMods "https://github.com/sudhirkumar6009/storagex/tree/main/backend/Mongo"
    click CryptoUtils "https://github.com/sudhirkumar6009/storagex/blob/main/backend/cryptoUtils.js"
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/src/main.tsx"
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/src/App.tsx"
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/index.html"
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/vite.config.ts"
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/tailwind.config.js"
    click ExpressAPI "https://github.com/sudhirkumar6009/storagex/blob/main/backend/package.json"
    click ExpressAPI "https://github.com/sudhirkumar6009/storagex/blob/main/backend/vercel.json"
    click FE_SPA "https://github.com/sudhirkumar6009/storagex/blob/main/frontend/vercel.json"

    %% Styles
    classDef frontend fill:#b3d4fc,stroke:#0366d6,color:#000
    classDef backend fill:#d2f8d2,stroke:#28a745,color:#000
    classDef datastore fill:#fed8b1,stroke:#e36209,color:#000
    classDef external fill:#e3d4f8,stroke:#6f42c1,color:#000
```
