Skip to content

harshit-kumar-dev/VyaparSetu

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ VyaparSetu

Kill the spreadsheet. Own the supply chain.

A production-grade, full-stack Procurement ERP that takes vendors from registration to paid invoice β€” fully automated, fully audited, fully yours.


Node.js React PostgreSQL Sequelize Socket.io Cloudinary Build License


Live Demo Β· Excalidraw Mockup Β· Report Bug Β· API Health


🎯 The Problem We're Solving

Most procurement in Indian SMEs and enterprises still runs on WhatsApp forwards, Excel tenders, and trust-based approvals. This leads to:

  • πŸ“§ Zero audit trails β€” Who approved what? Nobody knows.
  • πŸ“Š No bid comparison β€” Cheapest vendor? Just a gut feeling.
  • πŸ• Manual bottlenecks β€” POs taking days to generate instead of seconds.
  • πŸ’Έ No spend visibility β€” Finance teams flying blind.

VyaparSetu digitizes the entire procurement lifecycle on a single platform β€” structured, secure, and automated from the first RFQ to the final paid invoice.


✨ What VyaparSetu Does

One platform. Eight modules. Zero manual errors.

# Module What It Does
🏒 Vendor Registry Register suppliers with GST details, categories, and performance scores
πŸ“‹ Smart RFQ Engine Draft multi-item tenders, attach files, set deadlines, dispatch to vendors
πŸ’¬ Quotation Portal Vendors submit itemized bids with delivery timelines via secure portal
βš–οΈ Bid Comparison Matrix Side-by-side price and delivery analysis β€” lowest bid auto-highlighted
βœ… Approval Workflows Multi-step manager approval pipelines with full remark audit history
πŸ“¦ Purchase Order Gen Auto-number POs generated as Cloudinary-hosted PDFs in one click
🧾 Invoice Engine GST-aware tax invoices with subtotals, email delivery, and print support
πŸ“‘ Live Notifications Real-time Socket.io alerts for every procurement state change

πŸ—οΈ Architecture

System Overview

graph TB
    subgraph Client["πŸ–₯️ Client β€” Vite + React 18"]
        UI[Role-Based UI]
        DM[Dark / Light Mode]
        RT[Recharts Analytics]
    end

    subgraph Server["βš™οΈ API Server β€” Express.js + Node 22"]
        Auth[JWT + RBAC Middleware]
        Routes[8 Route Modules]
        Services[Business Logic Services]
        Sockets[Socket.io Engine]
    end

    subgraph Data["πŸ’Ύ Data & Storage"]
        DB[(PostgreSQL / Supabase)]
        CDN[Cloudinary CDN]
        SMTP[Gmail SMTP]
    end

    Client -->|REST + WebSocket| Server
    Server -->|Sequelize ORM| DB
    Services -->|Puppeteer β†’ Buffer| CDN
    Services -->|Nodemailer| SMTP
    Sockets -.->|Push Events| Client
Loading

End-to-End Procurement Flow

sequenceDiagram
    autonumber
    actor PO as πŸ§‘β€πŸ’Ό Procurement Officer
    actor V  as πŸͺ Vendor
    actor M  as πŸ‘” Manager

    PO->>+API: Register & onboard vendor
    PO->>API: Create RFQ (items + deadline + files)
    API-->>V: πŸ“§ Email β€” RFQ invitation
    V->>API: Submit itemized quotation
    PO->>API: Pull bid comparison matrix
    PO->>API: Initiate approval workflow
    API-->>M: πŸ“§ Email β€” approval pending
    M->>API: Approve with audit remarks
    API-->>PO: πŸ“‘ Socket event β€” approved
    PO->>+API: Generate Purchase Order
    API->>Puppeteer: Render PDF
    Puppeteer->>Cloudinary: Upload & get URL
    API-->>V: πŸ“§ PO PDF emailed
    V->>API: Generate Tax Invoice (18% GST)
    API->>Puppeteer: Render Invoice PDF
    Puppeteer-->>-API: Secure CDN URL
    API-->>-PO: πŸ“§ Invoice PDF delivered
Loading

πŸ” Security & Role Design

RBAC is enforced at the middleware level on every protected route β€” not just the UI.

ADMIN > PROCUREMENT_OFFICER > MANAGER > VENDOR
Permission Admin Proc. Officer Manager Vendor
Manage users & roles βœ… ❌ ❌ ❌
Register & approve vendors βœ… βœ… ❌ ❌
Create & publish RFQs βœ… βœ… ❌ ❌
Submit quotations ❌ ❌ ❌ βœ…
View bid comparison βœ… βœ… ❌ ❌
Initiate approval pipeline βœ… βœ… ❌ ❌
Approve / reject workflows βœ… βœ… βœ… ❌
Generate Purchase Orders βœ… βœ… ❌ ❌
Generate Tax Invoices βœ… ❌ ❌ βœ…
Full audit log access βœ… ❌ ❌ ❌

Additional security layers:

  • πŸ”’ bcryptjs password hashing (salt rounds: 10)
  • πŸͺ HTTP-only JWT cookies + refresh token rotation
  • πŸ›‘οΈ helmet HTTP headers hardening
  • 🚦 express-rate-limit β€” 100 req / 15 min per IP
  • βœ… express-validator schema validation on all inputs

πŸ“ Project Structure

VyaparSetu/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app.js              # Express setup, middleware stack
β”‚   β”‚   β”œβ”€β”€ server.js           # DB connect + Socket.io + HTTP boot
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   β”œβ”€β”€ database.js     # Sequelize multi-env config (dev/test/prod)
β”‚   β”‚   β”‚   └── cloudinary.js   # Multer-Cloudinary storage engine
β”‚   β”‚   β”œβ”€β”€ models/             # 19 Sequelize models with associations
β”‚   β”‚   β”‚   β”œβ”€β”€ user.js         # bcrypt hooks, scoped password exclusion
β”‚   β”‚   β”‚   β”œβ”€β”€ vendor.js       # GST, performance score, status enum
β”‚   β”‚   β”‚   β”œβ”€β”€ rfq.js          # DRAFTβ†’PUBLISHEDβ†’CLOSED state machine
β”‚   β”‚   β”‚   β”œβ”€β”€ quotation.js    # Per-item pricing + delivery timeline
β”‚   β”‚   β”‚   β”œβ”€β”€ approvalWorkflow.js  # Multi-step approver chain
β”‚   β”‚   β”‚   β”œβ”€β”€ purchaseOrder.js     # Auto-numbered POs, PDF URL
β”‚   β”‚   β”‚   └── invoice.js           # Subtotal + tax + grand total + due date
β”‚   β”‚   β”œβ”€β”€ controllers/        # Thin HTTP handlers β€” delegate to services
β”‚   β”‚   β”œβ”€β”€ services/           # All business logic lives here
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.service.js      # JWT sign/verify, refresh rotation
β”‚   β”‚   β”‚   β”œβ”€β”€ approval.service.js  # Workflow state machine
β”‚   β”‚   β”‚   β”œβ”€β”€ pdf.service.js       # Puppeteer render β†’ Cloudinary upload
β”‚   β”‚   β”‚   └── email.service.js     # Nodemailer template dispatch
β”‚   β”‚   β”œβ”€β”€ routes/             # 8 route modules mounted under /api
β”‚   β”‚   β”œβ”€β”€ middlewares/        # protect(), restrictTo(), errorMiddleware()
β”‚   β”‚   β”œβ”€β”€ validators/         # express-validator chains per route
β”‚   β”‚   β”œβ”€β”€ sockets/            # Socket.io event emitters
β”‚   β”‚   └── templates/          # EJS email & PDF templates
β”‚   β”œβ”€β”€ integration-test.js     # 7-phase E2E test (no test framework needed)
β”‚   └── clear-db.js             # Nuclear reset utility for dev
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.jsx            # Vite entry point
β”‚   β”‚   β”œβ”€β”€ App.jsx             # Global dark/light mode provider
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   └── LandingPage.jsx # Interactive mockup + role previews
β”‚   β”‚   └── styles/             # Glassmorphism CSS design system
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ db.js                       # Lightweight pg Pool helper (raw queries)
└── README.md

πŸ—„οΈ Data Model

19 tables, fully relational, with Sequelize association hooks:

erDiagram
    roles ||--o{ users : "has"
    users ||--o{ approval_steps : "approves"
    users ||--o{ rfqs : "creates"
    vendor_categories ||--o{ vendors : "classifies"
    vendors ||--o{ vendor_users : "has"
    vendors ||--o{ rfq_vendors : "invited to"
    vendors ||--o{ quotations : "submits"
    rfqs ||--o{ rfq_items : "contains"
    rfqs ||--o{ rfq_vendors : "sent to"
    rfqs ||--o{ quotations : "receives"
    quotations ||--o{ quotation_items : "has"
    quotations ||--o{ approval_workflows : "triggers"
    approval_workflows ||--o{ approval_steps : "has"
    quotations ||--o{ purchase_orders : "becomes"
    purchase_orders ||--o{ invoices : "generates"
Loading

⚑ Quick Start

Get the full ERP running in under 5 minutes.

Prerequisites

1 Β· Clone & configure

git clone https://github.com/harshit-kumar-dev/VyaparSetu.git
cd VyaparSetu

backend/.env β€” copy and fill in your values:

PORT=5000
NODE_ENV=development

DATABASE_URL=postgresql://<user>:<password>@<host>:5432/<db>

JWT_SECRET=<generate with: node -e "console.log(require('crypto').randomBytes(64).toString('hex'))">
JWT_REFRESH_SECRET=<another long random string>
JWT_EXPIRES_IN=1h
JWT_REFRESH_EXPIRES_IN=7d

CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_USER=your@gmail.com
SMTP_PASS=your_app_password

frontend/.env:

VITE_API_URL=http://localhost:5000/api

2 Β· Start the backend

cd backend
npm install --legacy-peer-deps   # resolves multer-storage-cloudinary peer dep
npm run dev                      # nodemon + auto DB sync on first start

Sequelize auto-syncs all 19 models on first boot. No manual migration needed.

3 Β· Seed the admin user

node -e "
const axios = require('axios');
axios.post('http://localhost:5000/api/auth/register', {
  firstName: 'Admin', lastName: 'User',
  email: 'admin@yourcompany.com',
  password: 'changeme123',
  roleName: 'ADMIN'
}).then(r => console.log('βœ… Admin ready:', r.data.data.user.email))
  .catch(e => console.error(e.response?.data));
"

4 Β· Start the frontend

cd ../frontend
npm install
npm run dev       # http://localhost:5173

5 Β· Verify the health endpoint

curl http://localhost:5000/api/health
# {"success":true,"message":"Server is up and running"}

πŸ§ͺ Testing

A self-contained 7-phase integration test exercises the entire procurement lifecycle against a live server β€” no test framework, no mocks:

# Make sure backend is running on :5000 first
cd backend
node integration-test.js
--- Phase 1: Auth ---
βœ… Login Successful

--- Phase 2: Vendor ---
βœ… Vendor Created: 5a144f02-c5ea-4cea-ac16-ae7717a4cd49

--- Phase 3: RFQ ---
βœ… RFQ Created: d483fa6a-c585-49a4-ac32-17ff8ccf78d8

--- Phase 4: Quotation ---
βœ… Quotation Submitted: cfccd191-8c75-403e-9a2e-0ef35b4ac3b4

--- Phase 5: Approval ---
βœ… Approval Workflow Initiated: 57a3887b-657d-42a0-bd1e-5c9d2f3bebbd
βœ… Quotation Approved (Workflow Step 1)

--- Phase 6: Purchase Order ---
βœ… PO Generated: 026020b6-5a0d-46b3-a3bb-b6b6b94c31d3

--- Phase 7: Invoice ---
βœ… Invoice Generated: d12b62e9-4ae3-4e8f-bff0-53cfce096795

--- TEST COMPLETE: SUCCESS ---

Reset between runs: node clear-db.js β€” drops and recreates the public schema.


πŸ”Œ API Surface

All routes under /api/* require Authorization: Bearer <token> except /api/auth/register and /api/auth/login.

Prefix Responsibility
/api/auth Register, login, logout, refresh token, forgot/reset password
/api/vendors Vendor CRUD, status management, category assignment
/api/rfqs RFQ creation, file upload, vendor assignment, status updates
/api/quotations Bid submission (Vendor), comparison fetch (Officer)
/api/approvals Workflow initiation, step approve/reject with remarks
/api/pos Purchase Order generation from approved quotations
/api/invoices GST invoice generation from issued POs
/api/notifications Real-time notification polling

πŸ›£οΈ Roadmap

  • Dashboard analytics β€” spending trends, vendor performance charts
  • Vendor self-registration portal β€” vendors onboard themselves
  • Multi-level approval thresholds β€” auto-route by PO value
  • Bulk RFQ import β€” CSV/Excel line-item upload
  • Mobile PWA β€” offline-ready for field procurement agents
  • Webhook integrations β€” ERP connectors (SAP, Tally, Zoho)

🀝 Contributing

# Fork, then:
git checkout -b feature/your-feature-name
git commit -m "feat: describe your change"
git push origin feature/your-feature-name
# Open a Pull Request

Please follow Conventional Commits for commit messages.


πŸ“„ License

MIT Β© 2026 VyaparSetu Team


Built with πŸ”₯ for the Hackathon

If this project helped you, drop a ⭐ β€” it means the world to us.

Deployment

Deployed on Vercel and Render.

About

A production-grade procurement ERP that automates the entire vendor-to-payment lifecycle with secure workflows, audit trails, bid comparison, and real-time procurement management.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages