# imabu0/cse327-project-nbm architecture

> Architecture diagram of the GitHub repository imabu0/cse327-project-nbm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imabu0/cse327-project-nbm
- Repository: https://github.com/imabu0/cse327-project-nbm

## Overview

##### Project type and purpose
- This is a full-stack, multi-client “Infinite Cloud” application for managing files across Google Drive, Dropbox, and your own server.
- It provides three client surfaces:
- A React/Vite web front-end (“client/”)
- An Android mobile app (“mobile-app/”)
- A bot interface (“bot/”, likely a chat or messaging bot)
- Backend is a Node.js/Express service (“server/”), backed by a SQL database (“database/db.sql”). It integrates with external storage APIs (Google, Dropbox) and an LLM utility.

##### File structure
- Top-level directories:
- bot/ – Node.js bot logic (bot.js, package.json)
- client/ – React SPA built with Vite (components, pages, Tailwind config)
- mobile-app/ – Android app in Kotlin using Retrofit, TokenManager, MVVM-style ui/
- server/ – Express server with layered MVC:
– config/ (db.js)
– models/ (auth, user, file, bucket, dropbox, google)
– middlewares/ (authMiddleware)
– routes/ (authRoutes, userRoutes, fileRoutes, dropboxRoutes, googleRoutes)
– utils/ (llm integration)
– server.js entry point
- database/ – SQL schema (db.sql)

##### README

a. Main components
- Web client (React SPA)
- Mobile client (Android app)
- Bot client (Node.js bot)
- Backend API server (Node.js/Express)
- Database (SQL)
- External storage services (Google Drive API, Dropbox API)
- LLM service (in-house or third-party)

b. Relationships & interactions
- All three clients send HTTP(S) requests (REST) to the API Server (auth, file, user, Google, Dropbox endpoints).
- The API server:
– Authenticates via authMiddleware
– Reads/writes metadata to SQL database
– Forwards file operations to Google or Dropbox APIs
– Uses llm.js for any AI-driven features
- The Android app uses RetrofitClient → TokenManager → API server.
- The bot uses bot.js to receive messages, then calls server APIs.

c. Architectural patterns & principles
- Layered MVC on the server
- Separation of concerns: distinct front-ends share a common REST API
- External API integration modules (Google, Dropbox) abstracted in models
- Middleware for cross-cutting concerns (authentication)

d. Key technologies & frameworks
- Server: Node.js, Express, JWT/authMiddleware, Sequelize or raw SQL via db.js
- Web: React, Vite, Tailwind CSS
- Mobile: Kotlin, Android MVVM, Retrofit
- Bot: Node.js
- Database: MySQL/Postgres (SQL schema in db.sql)
- External APIs: Google Drive, Dropbox
- AI: LLM utility (server/utils/llm.js)

##### Detailed capture of architecture
- Route Handlers → Middlewares → Models → External Integrations / DB
- Database schema entities (User, File, Bucket, Google, Dropbox) if space permits
- LLM utility as an external AI service or an internal micro-module

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients Layer
    subgraph "Clients"
        direction TB
        WebClient["Web Client<br/>(React/Vite)"]:::clients
        MobileClient["Mobile Client<br/>(Android MVVM)"]:::clients
        BotClient["Bot Client<br/>(Node.js)"]:::clients
    end

    %% API Server Layer
    subgraph "API Server (Node.js/Express)"
        direction TB
        subgraph "Routes"
            direction TB
            AuthRoutes["Auth Routes"]:::server
            UserRoutes["User Routes"]:::server
            FileRoutes["File Routes"]:::server
            GoogleRoutes["Google Routes"]:::server
            DropboxRoutes["Dropbox Routes"]:::server
        end
        subgraph "Middlewares"
            direction TB
            AuthMiddleware["Auth Middleware"]:::server
        end
        subgraph "Models"
            direction TB
            AuthModel["Auth Model"]:::server
            UserModel["User Model"]:::server
            FileModel["File Model"]:::server
            BucketModel["Bucket Model"]:::server
            GoogleModel["Google Model"]:::server
            DropboxModel["Dropbox Model"]:::server
        end
        subgraph "Utils"
            direction TB
            UtilsLLM["LLM Utility"]:::server
        end
    end

    %% Database and External Services
    Database["SQL Database"]:::database
    GoogleAPI["Google Drive API"]:::external
    DropboxAPI["Dropbox API"]:::external

    %% Connections
    WebClient -->|REST Requests| AuthRoutes
    WebClient -->|REST Requests| UserRoutes
    WebClient -->|REST Requests| FileRoutes
    WebClient -->|REST Requests| GoogleRoutes
    WebClient -->|REST Requests| DropboxRoutes

    MobileClient -->|REST Requests| AuthRoutes
    MobileClient -->|REST Requests| UserRoutes
    MobileClient -->|REST Requests| FileRoutes
    MobileClient -->|REST Requests| GoogleRoutes
    MobileClient -->|REST Requests| DropboxRoutes

    BotClient -->|REST Requests| AuthRoutes
    BotClient -->|REST Requests| UserRoutes
    BotClient -->|REST Requests| FileRoutes
    BotClient -->|REST Requests| GoogleRoutes
    BotClient -->|REST Requests| DropboxRoutes

    AuthRoutes -->|uses| AuthMiddleware
    UserRoutes -->|uses| AuthMiddleware
    FileRoutes -->|uses| AuthMiddleware
    GoogleRoutes -->|uses| AuthMiddleware
    DropboxRoutes -->|uses| AuthMiddleware

    AuthMiddleware -->|queries| AuthModel
    AuthMiddleware -->|queries| UserModel

    AuthModel -->|SQL Queries| Database
    UserModel -->|SQL Queries| Database
    FileModel -->|SQL Queries| Database
    BucketModel -->|SQL Queries| Database

    FileRoutes -->|uses| FileModel
    FileModel -->|integrates| GoogleModel
    FileModel -->|integrates| DropboxModel

    GoogleRoutes -->|calls| GoogleModel
    GoogleModel -->|HTTP| GoogleAPI

    DropboxRoutes -->|calls| DropboxModel
    DropboxModel -->|HTTP| DropboxAPI

    GoogleModel -->|SQL Metadata| Database
    DropboxModel -->|SQL Metadata| Database

    UtilsLLM -->|enhances| FileModel

    %% Click Events for component mapping
    click WebClient "https://github.com/imabu0/cse327-project-nbm/tree/master/client/"
    click WebClient "https://github.com/imabu0/cse327-project-nbm/tree/master/client/src/"
    click WebClient "https://github.com/imabu0/cse327-project-nbm/blob/master/client/src/App.jsx"
    click WebClient "https://github.com/imabu0/cse327-project-nbm/tree/master/client/src/components/"
    click WebClient "https://github.com/imabu0/cse327-project-nbm/blob/master/client/index.html"
    click WebClient "https://github.com/imabu0/cse327-project-nbm/blob/master/client/vite.config.js"
    click WebClient "https://github.com/imabu0/cse327-project-nbm/blob/master/client/tailwind.config.js"

    click MobileClient "https://github.com/imabu0/cse327-project-nbm/blob/master/mobile-app/app/src/main/java/com/example/myapplication/ApiService.kt"
    click MobileClient "https://github.com/imabu0/cse327-project-nbm/blob/master/mobile-app/app/src/main/java/com/example/myapplication/RetrofitClient.kt"
    click MobileClient "https://github.com/imabu0/cse327-project-nbm/blob/master/mobile-app/app/src/main/java/com/example/myapplication/TokenManager.kt"
    click MobileClient "https://github.com/imabu0/cse327-project-nbm/blob/master/mobile-app/app/src/main/java/com/example/myapplication/MainActivity.kt"
    click MobileClient "https://github.com/imabu0/cse327-project-nbm/tree/master/mobile-app/app/src/main/java/com/example/myapplication/ui/"

    click BotClient "https://github.com/imabu0/cse327-project-nbm/blob/master/bot/bot.js"
    click BotClient "https://github.com/imabu0/cse327-project-nbm/blob/master/bot/package.json"

    click AuthRoutes "https://github.com/imabu0/cse327-project-nbm/blob/master/server/routes/authRoutes.js"
    click UserRoutes "https://github.com/imabu0/cse327-project-nbm/blob/master/server/routes/userRoutes.js"
    click FileRoutes "https://github.com/imabu0/cse327-project-nbm/blob/master/server/routes/fileRoutes.js"
    click GoogleRoutes "https://github.com/imabu0/cse327-project-nbm/blob/master/server/routes/googleRoutes.js"
    click DropboxRoutes "https://github.com/imabu0/cse327-project-nbm/blob/master/server/routes/dropboxRoutes.js"

    click AuthMiddleware "https://github.com/imabu0/cse327-project-nbm/blob/master/server/middlewares/authMiddleware.js"

    click AuthModel "https://github.com/imabu0/cse327-project-nbm/blob/master/server/models/auth.model.js"
    click UserModel "https://github.com/imabu0/cse327-project-nbm/blob/master/server/models/user.model.js"
    click FileModel "https://github.com/imabu0/cse327-project-nbm/blob/master/server/models/file.model.js"
    click BucketModel "https://github.com/imabu0/cse327-project-nbm/blob/master/server/models/bucket.model.js"
    click GoogleModel "https://github.com/imabu0/cse327-project-nbm/blob/master/server/models/google.model.js"
    click DropboxModel "https://github.com/imabu0/cse327-project-nbm/blob/master/server/models/dropbox.model.js"

    click UtilsLLM "https://github.com/imabu0/cse327-project-nbm/blob/master/server/utils/llm.js"
    click Database "https://github.com/imabu0/cse327-project-nbm/blob/master/database/db.sql"

    click ServerEntry "https://github.com/imabu0/cse327-project-nbm/blob/master/server/server.js"

    %% Styles
    classDef clients fill:#D0E6FF,stroke:#02437B,stroke-width:2px
    classDef server fill:#DFF2D8,stroke:#2F7A2C,stroke-width:2px
    classDef database fill:#F0F0F0,stroke:#666666,stroke-width:2px
    classDef external fill:#FFE5B4,stroke:#CC7000,stroke-width:2px
```
