Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VendorBridge - Procurement & Vendor Management ERP

An enterprise-grade procurement ERP system that manages the complete Procure-to-Pay lifecycle: Vendor Registration β†’ RFQ β†’ Quotation β†’ Evaluation β†’ Approval β†’ Purchase Order β†’ Invoice β†’ Payment Tracking β†’ Analytics.

πŸ—οΈ Architecture

Technology Stack

Backend:

  • Node.js with NestJS Framework
  • MySQL 8.x Database
  • Prisma ORM
  • JWT Authentication
  • bcrypt for password hashing

Frontend:

  • React.js + TypeScript
  • Material UI (MUI)
  • Tailwind CSS
  • React Hook Form + Zod
  • Redux Toolkit
  • Recharts for analytics
  • Axios for API calls

πŸ“‹ Prerequisites

  • Node.js (v18 or higher)
  • MySQL 8.x
  • npm or yarn

πŸš€ Setup Instructions

1. Clone the Repository

cd vendorBridge

2. Backend Setup

Navigate to the backend directory:

cd backend

Install dependencies:

npm install

Configure environment variables:

cp .env.example .env

Edit .env file with your configuration:

# Database
DATABASE_URL="mysql://root:password@localhost:3306/vendorbridge"

# JWT
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_ACCESS_TOKEN_EXPIRATION=15m
JWT_REFRESH_TOKEN_EXPIRATION=7d

# Server
PORT=3000
NODE_ENV=development

# Email (optional - for invoice emails)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password
SMTP_FROM=VendorBridge ERP <noreply@vendorbridge.com>

# Frontend URL
FRONTEND_URL=http://localhost:5173

# Approval SLA (in days)
APPROVAL_SLA_DAYS=3

Generate Prisma Client:

npx prisma generate

Run database migrations:

npx prisma migrate dev --name init

Start the backend server:

npm run start:dev

The backend will run on http://localhost:3000

3. Frontend Setup

Navigate to the frontend directory (in a new terminal):

cd frontend

Install dependencies:

npm install

Start the frontend development server:

npm run dev

The frontend will run on http://localhost:5173

πŸ“Š Database Schema

The database includes the following main entities:

  • Users - System users with role-based access (Admin, Procurement Officer, Vendor, Manager)
  • Vendors - Vendor profiles with GST validation and rating system
  • RFQ - Request for Quotation with status workflow
  • Quotations - Vendor quotations with automatic calculations
  • Approvals - Multi-level approval workflow with SLA
  • Purchase Orders - PO generation from approved quotations
  • Invoices - Invoice generation with PDF support
  • Activity Logs - Complete audit trail
  • Notifications - System notifications

πŸ” Authentication

The system uses JWT-based authentication with the following features:

  • Password hashing with bcrypt
  • Access tokens (15 minutes expiration)
  • Role-based access control (RBAC)
  • Protected routes with guards

Default Roles

  • ADMIN - Full system access, user management
  • PROCUREMENT_OFFICER - Create RFQ, manage vendors, generate PO
  • VENDOR - View RFQ, submit quotations
  • MANAGER - Approve/reject quotations

🎯 Key Features

Vendor Management

  • GST validation (format: 22AAAAA0000A1Z5)
  • Vendor rating formula: (Delivery Γ— 40%) + (Quality Γ— 40%) + (Response Γ— 20%)
  • Vendor status management (ACTIVE, INACTIVE, BLOCKED)

RFQ Module

  • Auto-generated RFQ numbers: RFQ-{YEAR}-{SEQUENCE}
  • Status workflow: DRAFT β†’ PUBLISHED β†’ QUOTATION_RECEIVED β†’ UNDER_REVIEW β†’ CLOSED
  • Validation before publishing (items required, vendors assigned, deadline valid)

Quotation Module

  • Automatic calculations (subtotal, discount, tax, grand total)
  • Quotation comparison with scoring
  • Status tracking (DRAFT β†’ SUBMITTED β†’ ACCEPTED/REJECTED)

Approval Workflow

  • Multi-level approval based on PO value:
    • Below β‚Ή50,000: Single approval
    • β‚Ή50,000 - β‚Ή5,00,000: Manager approval
    • Above β‚Ή5,00,000: Manager + Admin approval
  • SLA tracking (configurable days)
  • Approval deadline calculation

Purchase Order

  • PO generation only after approval
  • Auto-generated PO numbers: PO-{YEAR}-{SEQUENCE}
  • Status tracking: CREATED β†’ SENT β†’ ACCEPTED β†’ DELIVERED β†’ CLOSED

Invoice Module

  • Invoice generation from PO
  • Auto-generated invoice numbers: INV-{YEAR}-{SEQUENCE}
  • GST calculation
  • PDF generation (to be implemented)
  • Email integration (to be implemented)

Reports & Analytics

  • Vendor reports
  • Purchase reports
  • Invoice reports
  • Spend analysis
  • Export to Excel/PDF (to be implemented)

Audit Logging

  • Complete audit trail for all actions
  • User, action, entity, timestamp tracking
  • Old value/new value comparison

πŸ“‘ API Endpoints

Authentication

  • POST /api/auth/login - User login
  • POST /api/auth/register - User registration
  • GET /api/auth/profile - Get current user profile

Users

  • GET /api/users - List all users (Admin only)
  • GET /api/users/:id - Get user by ID
  • POST /api/users - Create user (Admin only)
  • PUT /api/users/:id - Update user (Admin only)
  • DELETE /api/users/:id - Delete user (Admin only)

Vendors

  • GET /api/vendors - List all vendors
  • GET /api/vendors/:id - Get vendor by ID
  • POST /api/vendors - Create vendor
  • PUT /api/vendors/:id - Update vendor
  • DELETE /api/vendors/:id - Delete vendor (Admin only)

RFQ

  • GET /api/rfq - List all RFQs
  • GET /api/rfq/:id - Get RFQ by ID
  • POST /api/rfq - Create RFQ
  • PUT /api/rfq/:id - Update RFQ
  • POST /api/rfq/:id/publish - Publish RFQ
  • DELETE /api/rfq/:id - Delete RFQ

Quotations

  • GET /api/quotation - List all quotations
  • GET /api/quotation/rfq/:rfqId - Get quotations by RFQ
  • GET /api/quotation/:id - Get quotation by ID
  • POST /api/quotation - Create quotation (Vendor only)
  • PUT /api/quotation/:id - Update quotation (Vendor only)
  • POST /api/quotation/:id/submit - Submit quotation (Vendor only)

Approvals

  • GET /api/approval - List all approvals
  • GET /api/approval/pending - List pending approvals
  • GET /api/approval/:id - Get approval by ID
  • POST /api/approval/:id/approve - Approve quotation
  • POST /api/approval/:id/reject - Reject quotation

Purchase Orders

  • GET /api/po - List all POs
  • GET /api/po/:id - Get PO by ID
  • POST /api/po/quotation/:quotationId - Create PO from quotation
  • POST /api/po/:id/send - Send PO to vendor

Invoices

  • GET /api/invoice - List all invoices
  • GET /api/invoice/:id - Get invoice by ID
  • POST /api/invoice/po/:poId - Create invoice from PO
  • POST /api/invoice/:id/send - Send invoice
  • POST /api/invoice/:id/mark-paid - Mark invoice as paid

Reports

  • GET /api/reports/vendor - Vendor report
  • GET /api/reports/purchase - Purchase report
  • GET /api/reports/invoice - Invoice report
  • GET /api/reports/spend-analysis - Spend analysis

Audit

  • GET /api/audit - List all activity logs (Admin only)
  • GET /api/audit/entity/:entity/:entityId - Get logs by entity
  • GET /api/audit/user/:userId - Get logs by user

πŸ”§ Development Scripts

Backend

npm run start:dev    # Start in development mode
npm run build        # Build for production
npm run start:prod   # Start production server
npm run lint         # Run ESLint
npm run test         # Run tests
npm run prisma:generate  # Generate Prisma client
npm run prisma:migrate    # Run database migrations
npm run prisma:studio     # Open Prisma Studio

Frontend

npm run dev          # Start development server
npm run build        # Build for production
npm run preview      # Preview production build
npm run lint         # Run ESLint

πŸ§ͺ Testing

Run backend tests:

cd backend
npm run test

Run e2e tests:

cd backend
npm run test:e2e

πŸ“ Notes

  • The lint errors shown in the IDE are expected until npm packages are installed
  • Run npx prisma generate after installing dependencies to resolve Prisma-related errors
  • The frontend implementation is pending and will be added in the next phase
  • PDF generation and email integration for invoices are marked as TODO in the code
  • Security features (rate limiting, input sanitization) need to be implemented

🀝 Contributing

This is a comprehensive ERP system following SOLID principles, Clean Code, DRY, and the Repository Pattern.

πŸ“„ License

UNLICENSED - Private project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages