# tanishq-raj/s8test architecture

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

- Interactive diagram: https://gitdiagram.com/tanishq-raj/s8test
- Repository: https://github.com/tanishq-raj/s8test

## Overview

##### Project type and purpose
- This is a full-stack auction platform (“s8”) with two separate React/Vite frontends—one for bank officers (BankOfficer) and one for regular users/clients (client s8)—and a Node/Express/MongoDB backend (server).
- The two frontends share similar component hierarchies (context providers, dashboards, sign-in, property/auction UIs), and both talk to the same backend over REST endpoints.

##### File structure
- Top-level directories:
- BankOfficer/ – React code for bank‐officer dashboard
- client s8/ – React code for customer auction pages
- server/ – Express application with routes, controllers, models, middlewares, utils
- Notice MVC-like separation in server/src (models, controllers, routes, middlewares).
- Configuration files: .env, vite.config.js, tailwind.config.js in both frontends; server/src/config/cloudinary.js; utils for email/token.

##### README

a. Main components
- BankOfficer Frontend (React/Vite + Tailwind)
- Client Frontend (React/Vite + Tailwind)
- API Server (Node.js + Express)
- Database (MongoDB via Mongoose)
- External Services:
– Cloudinary (image storage)
– Email/SMS provider (via utils/sendEmail.js)
– Google OAuth (middleware/googleAuth.js)
b. Relationships & data flows
- Both frontends → HTTP(S) requests → Server REST API
- Server → read/write → MongoDB
- Server → upload/download → Cloudinary
- Server → send email/token → Email provider
- Server ↔ Google OAuth endpoints for social sign-in
c. Architectural patterns & principles
- Frontend: component-based, context providers for global state, separate routes/pages for auction, profile, sign-in
- Backend: MVC (models/controllers/routes), middleware chain (authUser, bankUser, multer for file uploads)
- Security: JWT/email tokens, role-based access (bankUser vs. user)
- Scalability: stateless APIs, external file storage, managed DB
d. Key technologies & libraries
- React, Vite, Tailwind CSS, Context API
- Node.js, Express, dotenv, Mongoose
- Multer (file uploads), Cloudinary SDK
- JSON Web Tokens (sendToken), nodemailer or similar
- Google OAuth strategy

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontends"
        BO["BankOfficer UI<br/>(React/Vite, Tailwind, Context)"]:::ui
        CI["Client UI<br/>(React/Vite, Tailwind, Context)"]:::ui
    end

    %% API Server Layer
    subgraph "API Server"
        direction TB
        Entry1["app.js"]:::server
        Entry2["server.js"]:::server

        subgraph "Middlewares"
            direction TB
            Auth["authUser"]:::server
            BankRole["bankUser"]:::server
            GoogleMW["googleAuth"]:::server
            Multer["multer"]:::server
        end

        subgraph "Routes"
            direction TB
            UserR["userRouter"]:::server
            BankR["bankUserRouter"]:::server
        end

        subgraph "Controllers"
            direction TB
            UserC["userController"]:::server
            BankC["bankUserController"]:::server
        end

        subgraph "Utils"
            direction TB
            SendEmail["sendEmail"]:::server
            SendToken["sendToken"]:::server
        end

        subgraph "Config"
            direction TB
            CloudConfig["cloudinary.js"]:::server
        end

        subgraph "Models"
            direction TB
            UserM["userModel"]:::server
            BankM["bankUserModel"]:::server
            PropertiesM["PropertiesModel"]:::server
            ImageM["imageModel"]:::server
        end
    end

    %% Database
    DB[(MongoDB)]:::db

    %% External Services
    Cloudinary(("Cloudinary")):::external
    EmailProvider(("Email/SMS Provider")):::external
    GoogleOAuth(("Google OAuth Endpoint")):::external

    %% Connections
    BO -->|HTTPS Request| Entry1
    CI -->|HTTPS Request| Entry1

    Entry1 --> Entry2
    Entry2 --> Auth
    Auth --> BankRole
    BankRole --> GoogleMW
    GoogleMW --> Multer
    Multer --> UserR
    Multer --> BankR

    UserR --> UserC
    BankR --> BankC

    UserC --> UserM
    UserC --> SendToken
    UserC --> SendEmail

    BankC --> BankM
    BankC --> PropertiesM
    BankC --> ImageM

    UserC --> Cloudinary
    BankC --> Cloudinary
    UserC --> EmailProvider
    BankC --> EmailProvider

    UserC --> DB
    BankC --> DB

    CloudConfig -->|configures| Cloudinary
    SendEmail -->|uses| EmailProvider
    SendToken -->|generates| UserC

    %% External OAuth flow
    GoogleMW -->|redirects| GoogleOAuth
    GoogleOAuth -->|callback| Auth

    %% Database connection
    DB -->|via Mongoose| Entry2

    %% Click Events
    click BO "https://github.com/tanishq-raj/s8test/tree/main/BankOfficer/"
    click CI "https://github.com/tanishq-raj/s8test/tree/main/client s8/"
    click Entry1 "https://github.com/tanishq-raj/s8test/blob/main/server/src/app.js"
    click Entry2 "https://github.com/tanishq-raj/s8test/blob/main/server/src/server.js"
    click Auth "https://github.com/tanishq-raj/s8test/blob/main/server/src/middlewares/authUser.js"
    click BankRole "https://github.com/tanishq-raj/s8test/blob/main/server/src/middlewares/bankUser.js"
    click GoogleMW "https://github.com/tanishq-raj/s8test/blob/main/server/src/middlewares/googleAuth.js"
    click Multer "https://github.com/tanishq-raj/s8test/blob/main/server/src/middlewares/multer.js"
    click UserR "https://github.com/tanishq-raj/s8test/blob/main/server/src/routes/userRouter.js"
    click BankR "https://github.com/tanishq-raj/s8test/blob/main/server/src/routes/bankUserRouter.js"
    click UserC "https://github.com/tanishq-raj/s8test/blob/main/server/src/controllers/userController.js"
    click BankC "https://github.com/tanishq-raj/s8test/blob/main/server/src/controllers/bankUserController.js"
    click UserM "https://github.com/tanishq-raj/s8test/blob/main/server/src/models/userModel.js"
    click BankM "https://github.com/tanishq-raj/s8test/blob/main/server/src/models/bankUserModel.js"
    click PropertiesM "https://github.com/tanishq-raj/s8test/blob/main/server/src/models/PropertiesModel.js"
    click ImageM "https://github.com/tanishq-raj/s8test/blob/main/server/src/models/imageModel.js"
    click CloudConfig "https://github.com/tanishq-raj/s8test/blob/main/server/src/config/cloudinary.js"
    click SendEmail "https://github.com/tanishq-raj/s8test/blob/main/server/src/utils/sendEmail.js"
    click SendToken "https://github.com/tanishq-raj/s8test/blob/main/server/src/utils/sendToken.js"
    click DB "https://github.com/tanishq-raj/s8test/blob/main/server/src/db/index.js"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6
    classDef server fill:#D0FFD0,stroke:#006400
    classDef db fill:#FFE0B2,stroke:#E65100
    classDef external fill:#E0E0E0,stroke:#757575
```
