# perfectionist7/abb-online-bidding-system architecture

> Architecture diagram of the GitHub repository perfectionist7/abb-online-bidding-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/perfectionist7/abb-online-bidding-system
- Repository: https://github.com/perfectionist7/abb-online-bidding-system

## Overview

##### Project type and purpose
- This is a full‑stack online bidding (auction) system.
- Frontend: React + Vite single‑page application.
- Backend: Node.js + Express REST API.
- Database: MongoDB.
- Authentication: JWT for token‑based auth and bcrypt for password hashing.

##### File structure
- Top‑level split: `/frontend` and `/backend`.
- Backend
- index.js – entry point.
- routes/ – Express route handlers (auth.js, user.js).
- models/ – Mongoose schemas (user.js).
- db.js – MongoDB connection logic.
- .env – configuration (DB URI, JWT secret).
- Frontend
- src/pages – route‑level React pages (Home, Bidding, GetStarted, SignUpSuccess).
- src/components – reusable UI components (Buttons, Inputs, Product cards, Dropdowns, Portals).
- index.html + index.jsx – SPA bootstrapping.
- vite.config.mjs – build‑server configuration.

##### Key insights from the README
- REST API endpoints:
- POST /api/user -> register new user
- POST /api/auth -> login & return JWT
- Dev workflow: run backend server, run Vite dev server, frontend calls API.
- Tech stack: React, Vite, Express, Node, MongoDB, JWT, bcrypt.

a. Frontend Application
b. API Layer / Backend
- Express server (Node.js runtime).
- Controllers/Routes (auth.js, user.js).
- Business logic and middleware (JWT verification, password hashing).
c. Data Layer
- MongoDB cluster/instance.
- Mongoose ORM (models/user.js).
d. External Services
- Email or notification service (optional if in future).
- CDN or static file host for production build.

##### Relationships and data flows
1. User (browser) interacts with React UI.
2. UI issues HTTP requests (axios/fetch) to `https://<backend-host>/api/...`.
3. Express routes parse requests, call controllers, validate JWT (if protected).
4. Controllers use Mongoose to query/update MongoDB.
5. Responses (JSON + JWT tokens on login) flow back to SPA.
6. React stores JWT (e.g., localStorage) and uses it for subsequent secured API calls.

##### Architectural patterns and design principles
- Frontend: Component‑based UI, client‑side routing.
- Backend: MVC‑inspired separation (Routes → Controllers/Services → Models).
- Stateless REST API with token‑based authentication (JWT).
- One‐way data flow on frontend: UI dispatches actions → API calls → state updates.
- Single database for all data (could evolve to microservices & polyglot DBs).

##### Technologies and frameworks
- React, Vite, JSX, CSS modules.
- Node.js, Express, dotenv, nodemon (dev).
- MongoDB (hosted or local), Mongoose.
- JWT for auth, bcrypt for password hashing.

## Diagram (Mermaid)

```mermaid
graph TB

    %% Client Side
    subgraph "Client Side"
        FE_Browser["User Browser"]:::external
        FE_Browser -->|"Loads SPA"| index_html
        index_html["index.html"]:::frontend
        index_html --> src_index
        src_index["src/index.jsx"]:::frontend
        src_index --> App_jsx
        App_jsx["App.jsx"]:::frontend
        App_jsx --> vite_config
        vite_config["vite.config.mjs"]:::frontend

        subgraph "UI Layer"
            components["Components"]:::frontend
            pages_home["Home.jsx"]:::frontend
            pages_bidding["Bidding.jsx"]:::frontend
            pages_getstarted["GetStarted.jsx"]:::frontend
            pages_signup["SignUpSuccess.jsx"]:::frontend
        end

        App_jsx --> pages_home
        App_jsx --> pages_bidding
        App_jsx --> pages_getstarted
        App_jsx --> pages_signup

        pages_home -->|"HTTP POST/GET"| Express_Server
        pages_bidding -->|"HTTP POST/GET"| Express_Server
        pages_getstarted -->|"HTTP POST"| Express_Server
        pages_signup -->|"HTTP POST"| Express_Server
    end

    %% Server Side
    subgraph "Server Side"
        Express_Server["Express Server (Node.js)"]:::backend
        Express_Server --> auth_route
        Express_Server --> user_route
        Express_Server --> jwt_middleware
        Express_Server --> bcrypt_lib
        Express_Server --> db_js

        auth_route["auth.js"]:::backend
        user_route["user.js"]:::backend
        jwt_middleware["JWT Middleware"]:::backend
        bcrypt_lib["bcrypt"]:::backend
        db_js["db.js"]:::backend

        db_js --> mongo_db
        mongo_db["MongoDB"]:::database

        auth_route --> user_model
        user_route --> user_model
        user_model["user.js (Mongoose Model)"]:::database

        Express_Server --> env_file
        env_file[".env"]:::infra
    end

    %% Classes
    classDef frontend fill:#ADD8E6,stroke:#000000
    classDef backend fill:#90EE90,stroke:#000000
    classDef database fill:#FFA500,stroke:#000000
    classDef external fill:#D3D3D3,stroke:#000000
    classDef infra fill:#cccccc,stroke:#000000

    %% Click Events
    click index_html "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/index.html"
    click src_index "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/src/index.jsx"
    click App_jsx "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/src/App.jsx"
    click vite_config "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/vite.config.mjs"
    click components "https://github.com/perfectionist7/abb-online-bidding-system/tree/main/frontend/src/components/"
    click pages_home "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/src/pages/Home.jsx"
    click pages_bidding "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/src/pages/Bidding.jsx"
    click pages_getstarted "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/src/pages/GetStarted.jsx"
    click pages_signup "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/src/pages/SignUpSuccess.jsx"
    click Express_Server "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/index.js"
    click db_js "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/db.js"
    click auth_route "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/routes/auth.js"
    click user_route "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/routes/user.js"
    click user_model "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/models/user.js"
    click env_file "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/.env"
    click fe_pkg "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/frontend/package.json"
    click be_pkg "https://github.com/perfectionist7/abb-online-bidding-system/blob/main/backend/package.json"
```
