# rautishz/rfp architecture

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

- Interactive diagram: https://gitdiagram.com/rautishz/rfp
- Repository: https://github.com/rautishz/rfp

## Overview

##### Project type and purpose
- This is a full-stack RFP (Request for Proposal) management web application.
- The provided repo contains the **frontend** (React + Vite); the **backend API** is external but required for full functionality (JWT-based authentication, RFP/Vendor endpoints).

##### File structure
- Top-level:
- public/, index.html
- src/ (all React code)
- vite.config.js, eslint.config.js
- src/ breakdown:
- assets/: static CSS, fonts, images, third-party libs
- components/: UI components, split into auth, layout, ui
- pages/: route-level views (Login, Dashboard, RFP, Vendors, etc.)
- services/: API service wrappers (api.js, authService, rfpService, vendorService), userState, utils
- constants/: environment and application constants
- App.jsx + main.jsx: SPA entrypoint, routing, root component

##### README for additional insights
- Technology stack: React 19, React Router, Bootstrap 5, Axios, React-Toastify, Vite
- Authentication: JWT stored in localStorage, user roles (Admin, Vendor)
- Workflow: Admin actions vs. Vendor actions
- External dependencies: backend REST API (base URL in services/api.js)

##### Main components
a. Frontend (Browser / React SPA)
- Entrypoint (main.jsx → App.jsx)
- Routing (React Router)
- Layout layer: Header, Sidebar, Footer (MainLayout)
- Auth layer: Login/Register pages, ProtectedRoute
- Pages: Dashboard, RFP list/detail, Vendor list, Quote submission
- UI components: Buttons, Tables, Modals, Forms
- State management: React Hooks + Context (userState)
- Service layer: Axios API client (api.js) + service wrappers (authService, rfpService, vendorService)
b. Backend REST API (external)
- Authentication endpoints (login, register, token refresh)
- Vendor endpoints (CRUD, approval)
- RFP endpoints (create, list, invite, close)
- Quote endpoints (submit, list, review)
- Uses JWT Bearer tokens for authorization
c. Database (external)
- Stores users (admin, vendor), RFP records, vendor registrations, quotes
d. External services / integrations
- React-Toastify (notifications)
- Bootstrap CSS

##### Relationships and interactions
- User (Admin or Vendor) interacts via Browser → React SPA
- SPA routes to pages → calls service layer → Axios issues HTTPS requests to Backend API
- API validates JWT → fetches/writes to Database → returns JSON
- SPA updates UI, dispatches notifications via React-Toastify
- Authentication flow: login → receive JWT → store in localStorage → attach to subsequent requests
- ProtectedRoute component inspects userState → restricts page access

##### Architectural patterns and principles
- Component-based UI (React)
- Container/presentation separation: pages vs. UI components
- Service layer abstraction over HTTP (api.js + service modules)
- Client-side routing and protected routes
- Token-based stateless authentication (JWT)
- Clear separation of concerns: assets vs. components vs. services vs. constants

1. User initiates action (e.g., “Create RFP” button)
2. Page component gathers form data
3. Calls rfpService.createRfp() → Axios.post(…api/rfps)
4. Backend Auth middleware validates JWT → Controller → Service → DB
5. Response propagates back → UI updates table → Toast notification

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        Browser["User Browser"]:::external
        LS["JWT in localStorage"]:::service

        main["main.jsx"]:::frontend
        App["App.jsx"]:::frontend

        subgraph "Routing & Layout"
            direction TB
            Router["React Router"]:::service
            AuthLayout["AuthLayout"]:::auth
            Protected["ProtectedRoute"]:::auth
            MainLayout["MainLayout"]:::frontend
            Header["Header"]:::frontend
            Sidebar["Sidebar"]:::frontend
            Footer["Footer"]:::frontend
        end

        subgraph "Pages"
            direction TB
            Login["Login.jsx"]:::frontend
            Register["Register.jsx"]:::frontend
            Dashboard["Dashboard.jsx"]:::frontend
            RFP["RFP.jsx"]:::frontend
            AddRFP["AddRFP.jsx"]:::frontend
            RFPQuotes["RFPQuotes.jsx"]:::frontend
            Vendors["Vendors.jsx"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            Button["Button.jsx"]:::ui
            Card["Card.jsx"]:::ui
            FormInput["FormInput.jsx"]:::ui
            Spinner["LoadingSpinner.jsx"]:::ui
            Pagination["Pagination.jsx"]:::ui
            RFPTable["RFPTable.jsx"]:::ui
            VendorTable["VendorTable.jsx"]:::ui
            ApplyModal["ApplyRFPModal.jsx"]:::ui
        end

        subgraph "Service Layer"
            direction TB
            APIClient["api.js"]:::service
            AuthService["authService.js"]:::service
            RFPService["rfpService.js"]:::service
            VendorService["vendorService.js"]:::service
            ServicesIndex["index.js"]:::service
            UserState["userState.js"]:::service
            Utils["utils.js"]:::service
        end

        Constants["constants/index.js"]:::service
        Assets["Static Assets & Styles"]:::external

        Browser --> main
        main --> App
        App --> Router
        App --> Constants
        App --> Assets
        Router --> AuthLayout
        Router --> MainLayout
        AuthLayout --> Login
        AuthLayout --> Register
        MainLayout --> Header
        MainLayout --> Sidebar
        MainLayout --> Footer
        MainLayout --> Dashboard
        MainLayout --> RFP
        MainLayout --> AddRFP
        MainLayout --> RFPQuotes
        MainLayout --> Vendors

        Dashboard --> Button
        RFP --> RFPTable
        RFP --> ApplyModal
        Vendors --> VendorTable
        AddRFP --> FormInput
        AddRFP --> Button

        Login --> AuthService
        Register --> AuthService
        Dashboard --> RFPService
        RFP --> RFPService
        RFPQuotes --> RFPService
        Vendors --> VendorService
        ApplyModal --> RFPService

        APIClient --> AuthService
        APIClient --> RFPService
        APIClient --> VendorService

        AuthService --> LS
        AuthService --> APIClient
        RFPService --> APIClient
        VendorService --> APIClient

    end

    %% Backend Layer
    subgraph "Backend REST API" 
        direction TB
        AuthAPI["Authentication Endpoints"]:::backend
        VendorAPI["Vendor Endpoints"]:::backend
        RFPAPI["RFP Endpoints"]:::backend
        QuoteAPI["Quote Endpoints"]:::backend
    end

    %% Data Layer
    DB["Database"]:::db

    %% External integrations
    Toastify["React-Toastify"]:::external
    Bootstrap["Bootstrap CSS"]:::external
    Icons["Material Design Icons"]:::external

    %% Data Flows
    APIClient -->|"HTTP Requests"| AuthAPI
    APIClient -->|"HTTP Requests"| VendorAPI
    APIClient -->|"HTTP Requests"| RFPAPI
    APIClient -->|"HTTP Requests"| QuoteAPI

    AuthAPI --> DB
    VendorAPI --> DB
    RFPAPI --> DB
    QuoteAPI --> DB

    AuthAPI -->|"JSON Responses"| APIClient
    VendorAPI -->|"JSON Responses"| APIClient
    RFPAPI -->|"JSON Responses"| APIClient
    QuoteAPI -->|"JSON Responses"| APIClient

    APIClient --> Toastify
    Assets --> Bootstrap
    Assets --> Icons

    %% Click Events
    click main "https://github.com/rautishz/rfp/blob/main/src/main.jsx"
    click App "https://github.com/rautishz/rfp/blob/main/src/App.jsx"
    click MainLayout "https://github.com/rautishz/rfp/blob/main/src/components/layout/MainLayout.jsx"
    click Header "https://github.com/rautishz/rfp/blob/main/src/components/layout/Header.jsx"
    click Sidebar "https://github.com/rautishz/rfp/blob/main/src/components/layout/Sidebar.jsx"
    click Footer "https://github.com/rautishz/rfp/blob/main/src/components/layout/Footer.jsx"
    click AuthLayout "https://github.com/rautishz/rfp/blob/main/src/components/auth/AuthLayout.jsx"
    click Protected "https://github.com/rautishz/rfp/blob/main/src/components/auth/ProtectedRoute.jsx"
    click Login "https://github.com/rautishz/rfp/blob/main/src/pages/Login.jsx"
    click Register "https://github.com/rautishz/rfp/blob/main/src/pages/Register.jsx"
    click Dashboard "https://github.com/rautishz/rfp/blob/main/src/pages/Dashboard.jsx"
    click RFP "https://github.com/rautishz/rfp/blob/main/src/pages/RFP.jsx"
    click AddRFP "https://github.com/rautishz/rfp/blob/main/src/pages/AddRFP.jsx"
    click RFPQuotes "https://github.com/rautishz/rfp/blob/main/src/pages/RFPQuotes.jsx"
    click Vendors "https://github.com/rautishz/rfp/blob/main/src/pages/Vendors.jsx"
    click Button "https://github.com/rautishz/rfp/blob/main/src/components/ui/Button.jsx"
    click Card "https://github.com/rautishz/rfp/blob/main/src/components/ui/Card.jsx"
    click FormInput "https://github.com/rautishz/rfp/blob/main/src/components/ui/FormInput.jsx"
    click Spinner "https://github.com/rautishz/rfp/blob/main/src/components/ui/LoadingSpinner.jsx"
    click Pagination "https://github.com/rautishz/rfp/blob/main/src/components/ui/Pagination.jsx"
    click RFPTable "https://github.com/rautishz/rfp/blob/main/src/components/ui/RFPTable.jsx"
    click VendorTable "https://github.com/rautishz/rfp/blob/main/src/components/ui/VendorTable.jsx"
    click ApplyModal "https://github.com/rautishz/rfp/blob/main/src/components/ui/ApplyRFPModal.jsx"
    click APIClient "https://github.com/rautishz/rfp/blob/main/src/services/api.js"
    click AuthService "https://github.com/rautishz/rfp/blob/main/src/services/authService.js"
    click RFPService "https://github.com/rautishz/rfp/blob/main/src/services/rfpService.js"
    click VendorService "https://github.com/rautishz/rfp/blob/main/src/services/vendorService.js"
    click ServicesIndex "https://github.com/rautishz/rfp/blob/main/src/services/index.js"
    click UserState "https://github.com/rautishz/rfp/blob/main/src/services/userState.js"
    click Utils "https://github.com/rautishz/rfp/blob/main/src/services/utils.js"
    click Constants "https://github.com/rautishz/rfp/blob/main/src/constants/index.js"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef backend fill:#FADBD8,stroke:#641E16,color:#641E16
    classDef db fill:#ABEBC6,stroke:#196F3D,color:#196F3D
    classDef external fill:#F9E79F,stroke:#7D6608,color:#7D6608
    classDef service fill:#D5F5E3,stroke:#145A32,color:#145A32
    classDef ui fill:#FCF3CF,stroke:#7E5109,color:#7E5109
    classDef auth fill:#E8DAEF,stroke:#512E5F,color:#512E5F
```
