# deepuchary03/secure-cloud-storage-mern architecture

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

- Interactive diagram: https://gitdiagram.com/deepuchary03/secure-cloud-storage-mern
- Repository: https://github.com/deepuchary03/secure-cloud-storage-mern

## Overview

##### Project Type and Purpose
- Secure-Cloud-Storage-MERN is a full-stack web application (MERN-style) that provides authenticated, access-controlled file storage in the cloud.
- The “client” directory holds a React+TypeScript single-page application (SPA) using Vite and Tailwind for UI.
- The “server” directory holds a Node.js/Express (TS) REST API that handles authentication, authorization, file upload/download, and persistence.
- The “shared” directory contains common schema definitions (used by both client and server), and “uploads” is the local file store for binary files.

##### File‐Structure Analysis
Top‐Level:
- client/ — React SPA
- server/ — Express API
- shared/ — shared TypeScript types/schema
- uploads/ — raw file storage
- drizzle.config.ts, tsconfig.json, vite.config.ts, tailwind.config.ts, theme.json — build/config files
Patterns:
– client/src/components/ui and components/layouts follow a component-based UI library pattern
– client/src/hooks and lib contain cross-cutting abstractions (auth, toasts, queryClient)
– server/middlewares.ts, auth.ts, routes.ts show an Express middleware→controller→service layering
– server/mongodb-storage.ts and server/storage.ts abstract file persistence (GridFS or FS)
– shared/schema.ts likely defines user, file, and access-control models

##### README Insights
– Title “Secure-Cloud-Storage-MERN” implies MERN stack (MongoDB, Express, React, Node)
– Screenshots (op1.png, op2.png, op3.png) likely show login, dashboard, file views

a. Main Components
1. Client (Browser SPA)
– React + TypeScript + Vite + Tailwind UI
– UI Components & Layouts, Hooks, Utilities
2. API Server
– Node.js + Express + TypeScript
– Authentication & Authorization Middleware
– RESTful Routes for user, file operations, access control
– Drizzle ORM (via drizzle.config.ts + shared/schema.ts) for metadata
– File Storage Module (server/mongodb-storage.ts or storage.ts)
3. Database
– MongoDB cluster for user credentials, file metadata, ACL
4. File Store
– Local directory under “uploads/” or GridFS (abstracted in code)
5. External Services (optional)
– Email or SMS for OTP, if implemented
– CDN for file delivery (not present but could be added)
b. Relationships & Data Flows
– User → SPA (login, upload, download)
– SPA → API Server (HTTPS requests, JWT in headers or cookie)
– API Server ↔ MongoDB (via Drizzle ORM) for CRUD on metadata
– API Server ↔ File Store for read/write raw files
– API Server → SPA (JSON responses)
c. Architectural Patterns & Principles
– Layered Architecture: Presentation (client), Application (server controllers/middleware), Data (DB & storage)
– Single-Page Application on the client, REST API on the server
– Separation of Concerns: UI components vs hooks vs utilities; routes vs middleware vs services
– Shared types/schema ensures type-safe contracts between client and server
d. Key Technologies & Libraries
– Frontend: React, TypeScript, Vite, Tailwind CSS
– Backend: Node.js, Express, TypeScript, Drizzle ORM
– Persistence: MongoDB, local filesystem or GridFS
– Utility: react-query (queryClient), custom hooks for auth and toast

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser SPA)"
        direction TB
        Browser["User Browser"]:::frontend
        Vite["Vite Bundler"]:::frontend
        ReactRouter["React Router"]:::frontend
        App["App Component"]:::frontend
        UIComponents["UI Components"]:::frontend
        Layouts["Dashboard Layout"]:::frontend
        Pages["Page Views"]:::frontend
        HooksAuth["use-auth Hook"]:::frontend
        HooksToast["use-toast Hook"]:::frontend
        HooksMobile["use-mobile Hook"]:::frontend
        QueryClient["Query Client"]:::frontend
        ProtectedRoute["Protected Route Utility"]:::frontend
        FileUtils["File Utilities"]:::frontend
        Utils["General Utilities"]:::frontend
        ThemeConfig["Tailwind & Theme Config"]:::frontend
        Browser -->|loads| Vite
        Vite -->|bundles| App
        App --> ReactRouter
        ReactRouter --> Pages
        App --> UIComponents
        App --> Layouts
        Pages --> HooksAuth
        Pages --> HooksToast
        Pages --> HooksMobile
        Pages --> QueryClient
        Pages --> ProtectedRoute
        Pages --> FileUtils
        Pages --> Utils
        ThemeConfig --> UIComponents
    end

    %% Shared Schema
    SharedSchema["Shared Schema Definitions"]:::shared

    %% Server Layer
    subgraph "Server (Express API)"
        direction TB
        ExpressApp["server/index.ts"]:::backend
        Middlewares["Express Middlewares"]:::backend
        AuthLogic["Authentication Logic"]:::backend
        Routes["API Routes"]:::backend
        StorageAbstraction["File Storage Abstraction"]:::backend
        MongoStorage["MongoDB Storage Implementation"]:::backend
        DrizzleConfig["Drizzle ORM Config"]:::backend
        ExpressApp --> Middlewares
        Middlewares --> AuthLogic
        Middlewares --> Routes
        Routes --> StorageAbstraction
        StorageAbstraction --> MongoStorage
        DrizzleConfig --> Routes
        SharedSchema --> Routes
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        MongoDB["MongoDB Cluster"]:::data
        FileStore["Local File Store (uploads/)"]:::data
        MongoStorage --> MongoDB
        StorageAbstraction --> FileStore
    end

    %% Interactions
    Browser -->|HTTPS/JSON| ExpressApp
    ExpressApp -->|JSON| Browser

    %% Click Events - Client
    click Browser "https://github.com/deepuchary03/secure-cloud-storage-mern/tree/main/client/"
    click Vite "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/vite.config.ts"
    click App "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/App.tsx"
    click UIComponents "https://github.com/deepuchary03/secure-cloud-storage-mern/tree/main/client/src/components/ui/"
    click Layouts "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/components/layouts/dashboard-layout.tsx"
    click Pages "https://github.com/deepuchary03/secure-cloud-storage-mern/tree/main/client/src/pages/"
    click HooksAuth "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/hooks/use-auth.tsx"
    click HooksToast "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/hooks/use-toast.ts"
    click HooksMobile "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/hooks/use-mobile.tsx"
    click QueryClient "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/lib/queryClient.ts"
    click ProtectedRoute "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/lib/protected-route.tsx"
    click FileUtils "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/lib/file-utils.ts"
    click Utils "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/client/src/lib/utils.ts"
    click ThemeConfig "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/tailwind.config.ts"
    click SharedSchema "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/shared/schema.ts"

    %% Click Events - Server
    click ExpressApp "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/server/index.ts"
    click Middlewares "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/server/middlewares.ts"
    click AuthLogic "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/server/auth.ts"
    click Routes "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/server/routes.ts"
    click StorageAbstraction "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/server/storage.ts"
    click MongoStorage "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/server/mongodb-storage.ts"
    click DrizzleConfig "https://github.com/deepuchary03/secure-cloud-storage-mern/blob/main/drizzle.config.ts"
    click FileStore "https://github.com/deepuchary03/secure-cloud-storage-mern/tree/main/uploads/"

    %% Styles
    classDef frontend fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef backend fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#FFD700,stroke:#333,stroke-width:1px
    classDef shared fill:#D8BFD8,stroke:#333,stroke-width:1px
```
