Enterprise Supply Chain Platform for Food Manufacturing
Developed for Skantha Technology Solutions
- Overview
- Features
- Tech Stack
- System Architecture
- Prerequisites
- Installation & Setup
- Environment Configuration
- Database Setup
- Running the Application
- Project Structure
- API Documentation
- User Roles & Permissions
- Key Modules
- Troubleshooting
- Development Guidelines
- Contributing
The Food Manufacturing SaaS Platform is an enterprise-grade application designed to manage the complete supply chain workflow for food manufacturing businesses.
This platform was developed as part of an AI development project for Skantha Technology Solutions, focusing on building scalable systems for manufacturing operations, inventory management, and financial tracking.
It provides role-specific dashboards for Admins, Manufacturers, and Retailers, enabling seamless tracking from production to point-of-sale with built-in GST compliance and commission management.
- Multi-Role System: Separate dashboards and permissions for Admin, Manufacturer, and Retailer roles
- Production Management: Track production batches, recipes, raw materials, and finished goods
- Inventory Control: Real-time stock tracking with SRN (Stock Requisition Note) and GRN (Goods Receipt Note)
- Material Catalog: Comprehensive catalog management for raw materials and finished products
- Dispatch Management: Order fulfillment and dispatch execution with tracking
- Invoice Generation: GST-compliant invoice creation with automatic tax calculations
- Commission Tracking: Multi-tier commission management for retailers and distributors
- Financial Reports: Comprehensive reporting for admins with revenue and sales analytics
- Authentication & Authorization: JWT-based secure authentication with role-based access control
- B2B & B2C Sales: Support for both business-to-business and direct consumer sales
- Stock Movements: Complete audit trail of all inventory movements
- Batch Tracking: Production batch recording with expiry date management
- Purchase Orders: End-to-end purchase order management
- Sales Analytics: Real-time dashboards with key performance indicators
- Commission Calculation: Automated commission calculations based on sales
- Framework: NestJS (Node.js framework)
- Language: TypeScript
- Database: PostgreSQL 16
- ORM: Prisma
- Authentication: JWT (JSON Web Tokens)
- Validation: class-validator, class-transformer
- API Documentation: Swagger/OpenAPI
- Framework: React 18
- Language: TypeScript
- Build Tool: Vite
- Styling: Tailwind CSS
- State Management: React Query (TanStack Query)
- Routing: React Router v6
- HTTP Client: Axios
- UI Components: Custom components with Tailwind
- Version Control: Git
- Package Manager: npm
- Database Management: PostgreSQL with Prisma Migrate
- Development: Hot reload for both frontend and backend
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Layer (Browser) β
β React + TypeScript + Tailwind CSS β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β HTTP/REST API
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β API Gateway Layer β
β NestJS Controllers + Guards β
β ββββββββββββββ¬βββββββββββββ¬ββββββββββββββ β
β β Admin βManufacturerβ Retailer β β
β β Routes β Routes β Routes β β
β βββββββ¬βββββββ΄βββββββ¬ββββββ΄βββββββ¬βββββββ β
βββββββββββββββββΌββββββββββββββΌβββββββββββββΌβββββββββββββββββββ
β β β
βββββββββββββββββΌββββββββββββββΌβββββββββββββΌβββββββββββββββββββ
β Service Layer β
β ββββββββββββ ββββββββββββ ββββββββββββ βββββββββββββββ β
β βProductionβ βInventory β β Invoice β β Commission β β
β β Service β β Service β β Service β β Service β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββββ¬βββββββ β
βββββββββΌβββββββββββββΌβββββββββββββΌββββββββββββββββΌβββββββββββ
β β β β
βββββββββΌβββββββββββββΌβββββββββββββΌββββββββββββββββΌβββββββββββ
β Data Access Layer β
β Prisma ORM β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β PostgreSQL Database β
β βββββββββββ βββββββββββ ββββββββββββ ββββββββββββββββ β
β β Users β βProducts β βProductionβ β Transactions β β
β β Roles β βInventoryβ β Batches β β Invoices β β
β βββββββββββ βββββββββββ ββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Before setting up the project, ensure you have the following installed on your system:
| Software | Version | Download Link | Purpose |
|---|---|---|---|
| Node.js | 18.x or 20.x | nodejs.org | Runtime for backend and build tools |
| npm | 9.x or higher | Comes with Node.js | Package manager |
| PostgreSQL | 16.x | postgresql.org | Database server |
| Git | Latest | git-scm.com | Version control |
| Tool | Purpose |
|---|---|
| pgAdmin 4 | PostgreSQL database GUI management |
| Postman | API testing |
| VS Code | Code editor with TypeScript support |
- OS: Windows 10/11, macOS 10.15+, or Linux
- RAM: Minimum 4GB (8GB recommended)
- Storage: At least 2GB free space
- Network: Internet connection for package installation
git clone https://github.com/harpreet-2146/FM-demo.git
cd FM-demo# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Generate Prisma Client
npx prisma generate
# Run database migrations
npx prisma migrate dev# Navigate to frontend directory (from project root)
cd ../frontend
# Install dependencies
npm installCreate a .env file in the backend directory:
# Database Configuration
DATABASE_URL="postgresql://postgres:your_password@localhost:5432/food_manufacturing_saas?schema=public"
# JWT Configuration
JWT_SECRET="my-super-secret-jwt-key-for-food-manufacturing-saas-2026"
JWT_EXPIRES_IN="24h"
# Server Configuration
PORT=3000
NODE_ENV=development
# CORS Configuration
CORS_ORIGIN="http://localhost:5173"| Variable | Description | Example Value |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | postgresql://user:pass@host:port/db |
JWT_SECRET |
Secret key for JWT token signing | Any strong random string (min 32 chars) |
JWT_EXPIRES_IN |
Token expiration time | 24h, 7d, 30d |
PORT |
Backend server port | 3000 |
NODE_ENV |
Environment mode | development, production |
CORS_ORIGIN |
Allowed frontend origin | http://localhost:5173 |
β οΈ IMPORTANT: Replaceyour_passwordwith your actual PostgreSQL password that you set during installation.
Create a .env file in the frontend directory:
# API Configuration
VITE_API_URL=http://localhost:3000- Download PostgreSQL 16 from postgresql.org
- Run the installer
- Set a password for the
postgresuser (remember this!) - Default port is
5432(keep this unless you have conflicts) - Install pgAdmin 4 (included in the installer)
- Complete the installation and ensure PostgreSQL service is running
# Using Homebrew
brew install postgresql@16
brew services start postgresql@16
# Create postgres user if needed
createuser -s postgressudo apt update
sudo apt install postgresql-16 postgresql-contrib-16
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Set password for postgres user
sudo -u postgres psql
\password postgres
# Enter your password twice
\q# Connect to PostgreSQL
# Windows (from Command Prompt or PowerShell)
psql -U postgres
# macOS/Linux
psql -U postgres
# Once connected, create the database
CREATE DATABASE food_manufacturing_saas;
# Verify database was created
\l
# Exit psql
\q# From backend directory
cd backend
# Ensure DATABASE_URL in .env is correct
# Run Prisma migrations
npx prisma migrate dev
# This will:
# 1. Create all tables
# 2. Set up relationships
# 3. Apply indexes and constraints
# Seed database (if seed file exists)
npx prisma db seed# Open Prisma Studio to view database
npx prisma studioThis will open Prisma Studio at http://localhost:5555 where you can view and edit database records.
cd backend
npm run start:devExpected Output:
[Nest] 12345 - 02/08/2026, 10:30:00 AM LOG [NestFactory] Starting Nest application...
[Nest] 12345 - 02/08/2026, 10:30:01 AM LOG [InstanceLoader] AppModule dependencies initialized
[Nest] 12345 - 02/08/2026, 10:30:01 AM LOG [RoutesResolver] AuthController {/auth}:
[Nest] 12345 - 02/08/2026, 10:30:01 AM LOG [NestApplication] Nest application successfully started
[Nest] 12345 - 02/08/2026, 10:30:01 AM LOG Application is running on: http://localhost:3000
The backend will start on http://localhost:3000
cd frontend
npm run devExpected Output:
VITE v5.x.x ready in 500 ms
β Local: http://localhost:5173/
β Network: use --host to expose
β press h to show help
The frontend will start on http://localhost:5173
cd backend
npm run build
npm run start:prodcd frontend
npm run build
# Preview production build
npm run preview- Backend API: Visit
http://localhost:3000/api(Swagger documentation) - Frontend: Visit
http://localhost:5173 - Database: Check with
npx prisma studiofrom backend directory
FM-demo/
βββ backend/ # NestJS Backend Application
β βββ src/
β β βββ auth/ # Authentication module
β β β βββ guards/ # JWT guards, role guards
β β β βββ decorators/ # Custom decorators (Roles, Public)
β β β βββ auth.controller.ts
β β β βββ auth.service.ts
β β β βββ auth.module.ts
β β βββ admin/ # Admin module
β β β βββ admin.controller.ts
β β β βββ admin.service.ts
β β β βββ admin.module.ts
β β βββ manufacturer/ # Manufacturer module
β β β βββ manufacturer-inventory.controller.ts
β β β βββ manufacturer-inventory.service.ts
β β β βββ manufacturer-production.controller.ts
β β β βββ manufacturer-production.service.ts
β β β βββ manufacturer.module.ts
β β βββ retailer/ # Retailer module
β β β βββ retailer-inventory.controller.ts
β β β βββ retailer-inventory.service.ts
β β β βββ retailer-sales.controller.ts
β β β βββ retailer-sales.service.ts
β β β βββ retailer.module.ts
β β βββ shared/ # Shared utilities
β β β βββ dtos/ # Data Transfer Objects
β β β βββ interfaces/ # TypeScript interfaces
β β βββ prisma/ # Prisma configuration
β β β βββ prisma.service.ts
β β β βββ schema.prisma # Database schema
β β βββ app.module.ts # Root module
β β βββ main.ts # Application entry point
β βββ .env # Environment variables
β βββ package.json
β βββ tsconfig.json
β
βββ frontend/ # React Frontend Application
β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ layout/ # Layout components (Header, Sidebar)
β β β βββ common/ # Common components (Button, Card, Table)
β β β βββ forms/ # Form components
β β βββ pages/ # Page components
β β β βββ auth/ # Login, Register
β β β βββ admin/ # Admin dashboard & reports
β β β βββ manufacturer/ # Manufacturer dashboard
β β β βββ retailer/ # Retailer dashboard
β β βββ services/ # API service layer
β β β βββ api.ts # Axios configuration
β β β βββ auth.service.ts
β β β βββ admin.service.ts
β β β βββ manufacturer.service.ts
β β β βββ retailer.service.ts
β β βββ hooks/ # Custom React hooks
β β β βββ useAuth.ts
β β β βββ useApi.ts
β β βββ context/ # React Context
β β β βββ AuthContext.tsx
β β βββ types/ # TypeScript type definitions
β β βββ utils/ # Utility functions
β β βββ App.tsx # Root component
β β βββ main.tsx # Application entry point
β β βββ index.css # Global styles
β βββ .env # Environment variables
β βββ index.html
β βββ package.json
β βββ tailwind.config.js
β βββ tsconfig.json
β βββ vite.config.ts
β
βββ .gitignore
βββ README.md # This file
Once the backend is running, visit: http://localhost:3000/api
The Swagger UI provides:
- Complete API endpoint documentation
- Request/response schemas
- Interactive API testing
- Authentication flow testing
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /auth/login |
User login | β |
| POST | /auth/register |
User registration | β |
| GET | /auth/profile |
Get current user profile | β |
| Method | Endpoint | Description | Role |
|---|---|---|---|
| GET | /admin/reports/sales |
Sales reports | Admin |
| GET | /admin/reports/inventory |
Inventory reports | Admin |
| GET | /admin/reports/commissions |
Commission reports | Admin |
| GET | /admin/users |
List all users | Admin |
| POST | /admin/users |
Create new user | Admin |
| Method | Endpoint | Description | Role |
|---|---|---|---|
| GET | /manufacturer/inventory |
Get inventory list | Manufacturer |
| POST | /manufacturer/inventory/srn |
Create Stock Requisition Note | Manufacturer |
| POST | /manufacturer/inventory/grn |
Create Goods Receipt Note | Manufacturer |
| GET | /manufacturer/production/batches |
List production batches | Manufacturer |
| POST | /manufacturer/production/batch |
Record production batch | Manufacturer |
| Method | Endpoint | Description | Role |
|---|---|---|---|
| GET | /retailer/inventory |
Get retailer inventory | Retailer |
| GET | /retailer/invoices |
List invoices | Retailer |
| POST | /retailer/sales/invoice |
Create sales invoice | Retailer |
| GET | /retailer/commissions |
View commissions | Retailer |
Full system access with oversight capabilities
β Can Do:
- View all system reports (sales, inventory, commissions)
- Manage users and assign roles
- View complete financial data
- Access analytics dashboards
- Configure system settings
- Approve/reject transactions
- Audit all system activities
β Cannot Do:
- Execute production batches (view only)
- Create invoices directly (oversight only)
Dashboard Components:
- Sales overview
- Revenue analytics
- Commission summaries
- User management
- System health monitoring
Production and inventory management
β Can Do:
- Create and manage production batches
- Track raw materials and finished goods
- Create SRN (Stock Requisition Notes)
- Create GRN (Goods Receipt Notes)
- View their own inventory levels
- Dispatch orders to retailers
- Record material consumption
- Track production costs
β Cannot Do:
- View financial data (commissions, profit margins)
- Access retailer sales data
- View system-wide reports
- Modify commission structures
- Access other manufacturers' data
Dashboard Components:
- Production batch overview
- Inventory status
- Material requisitions
- Dispatch tracking
- Production efficiency metrics
Sales and inventory for retail operations
β Can Do:
- View their assigned inventory
- Create sales invoices (B2C sales)
- View their own invoices
- Track their commissions
- Place orders with manufacturers
- View order history
- Generate sales reports (own data)
β Cannot Do:
- View other retailers' data
- Access production information
- View manufacturer inventory
- Access admin reports
- Modify commission rates
- View system-wide analytics
Dashboard Components:
- Inventory overview
- Sales summary
- Commission tracking
- Invoice history
- Order management
Features:
- Production batch recording with unique batch numbers
- Recipe management with BOM (Bill of Materials)
- Raw material consumption tracking
- Finished goods production
- Expiry date tracking and alerts
- Batch costing and profitability analysis
Workflow:
1. Create Production Batch
β
2. Record Raw Materials Used
β
3. Process Production
β
4. Update Finished Goods Inventory
β
5. Calculate Production Costs
β
6. Generate Batch Report
Key Fields:
- Batch Number (auto-generated)
- Production Date
- Raw Materials (with quantities)
- Finished Product
- Quantity Produced
- Manufacturing Cost
- Expiry Date
Features:
- Real-time stock tracking
- SRN (Stock Requisition Note) for material requests
- GRN (Goods Receipt Note) for material receipts
- Stock movement audit trail
- Low stock alerts and notifications
- Multi-location inventory support
- FIFO/LIFO stock valuation
Stock Movement Types:
- Purchase (IN) - Goods received from suppliers
- Production (IN/OUT) - Materials consumed, products created
- Sales (OUT) - Products sold to customers
- Dispatch (OUT) - Goods sent to retailers
- Adjustment (IN/OUT) - Stock corrections
- Return (IN) - Returned goods
SRN Workflow:
Manufacturer Creates SRN β Approval β Material Procurement β GRN Creation
GRN Workflow:
Goods Received β Quality Check β GRN Creation β Inventory Update
Features:
- GST-compliant invoice creation
- Automatic tax calculations (CGST, SGST, IGST)
- Invoice numbering system (sequential)
- PDF generation
- Invoice history tracking
- Payment status tracking
- Multi-currency support
GST Calculation:
Base Amount: βΉ10,000.00
CGST @ 9%: βΉ 900.00
SGST @ 9%: βΉ 900.00
βββββββββββββββββββββββββββββββββ
Total Invoice Amount: βΉ11,800.00
Invoice Structure:
- Invoice Number (auto-generated)
- Invoice Date
- Buyer Details (GST Number, Address)
- Seller Details (GST Number, Address)
- Line Items (Product, Quantity, Rate, Amount)
- Tax Breakdown (CGST, SGST, IGST)
- Total Amount
- Payment Terms
- Due Date
GST Types:
- Intrastate: CGST + SGST (9% + 9% = 18%)
- Interstate: IGST (18%)
Features:
- Multi-tier commission structure
- Automatic commission calculation
- Commission reports by period
- Payment tracking
- Commission history
- Commission rate management
- Performance-based bonuses
Commission Tiers:
| Role | Commission % | Calculation Base |
|---|---|---|
| Primary Retailer | 10% | Sales Amount |
| Distributor | 5% | Sales Amount |
| Referral Partner | 2% | Sales Amount |
| Regional Manager | 3% | Regional Sales |
Calculation Example:
Sale Amount: βΉ100,000
Primary Retailer (10%): βΉ10,000
Distributor (5%): βΉ5,000
Referral (2%): βΉ2,000
βββββββββββββββββββββββββ
Total Commissions: βΉ17,000
Commission Reports:
- Monthly commission summary
- Individual retailer performance
- Commission payment status
- Historical commission data
- Commission forecasting
Features:
- Order fulfillment tracking
- Dispatch note generation
- Delivery status tracking
- Vehicle assignment
- Proof of delivery
- Route optimization
- Delivery scheduling
Dispatch Workflow:
Order Placed
β
Inventory Check
β
Packing & Quality Check
β
Dispatch Note Generated
β
Vehicle Assignment
β
In-Transit Tracking
β
Delivered & POD Collected
Dispatch Statuses:
- Pending
- Packed
- Dispatched
- In Transit
- Out for Delivery
- Delivered
- Returned
Error:
Can't reach database server at localhost:5432
Solutions:
Check PostgreSQL Service:
# Windows
services.msc
# Look for "postgresql-x64-16" and ensure it's running
# macOS
brew services list | grep postgresql
# Linux
sudo systemctl status postgresqlVerify Connection:
# Test if PostgreSQL is accepting connections
pg_isready -h localhost -p 5432
# Expected output: localhost:5432 - accepting connectionsCheck .env Configuration:
# Ensure this matches your PostgreSQL setup
DATABASE_URL="postgresql://postgres:YOUR_ACTUAL_PASSWORD@localhost:5432/food_manufacturing_saas?schema=public"Test Direct Connection:
psql -U postgres -d food_manufacturing_saas
# If this works, your credentials are correctCommon Mistakes:
- Wrong password in DATABASE_URL
- PostgreSQL service not running
- Firewall blocking port 5432
- Database name misspelled
Error:
Error: listen EADDRINUSE: address already in use :::3000
Solutions:
Windows:
# Find process using port 3000
netstat -ano | findstr :3000
# Kill the process (replace <PID> with actual process ID)
taskkill /PID <PID> /FmacOS/Linux:
# Find and kill process using port 3000
lsof -ti:3000 | xargs kill -9
# Or for port 5173 (frontend)
lsof -ti:5173 | xargs kill -9Alternative Solution:
Change the port in .env file:
# Backend
PORT=3001
# Frontend (.env in frontend folder)
VITE_PORT=5174Error:
Cannot find module '@prisma/client'
or
PrismaClient is unable to be run in the browser
Solutions:
# Navigate to backend directory
cd backend
# Generate Prisma Client
npx prisma generate
# If schema has changed, migrate first
npx prisma migrate dev
# Then generate
npx prisma generate
# Restart the backend server
npm run start:devClear Prisma Cache (if still having issues):
# Delete node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
npx prisma generateError:
TypeScript compilation errors
or
Module not found errors
Solutions:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install
# Clear Vite cache
rm -rf node_modules/.vite
# Update dependencies
npm update
# If still failing, check TypeScript errors
npm run type-checkCommon TypeScript Errors:
- Missing type definitions:
npm install --save-dev @types/node - Import path errors: Check
tsconfig.jsonpaths configuration - Version conflicts: Ensure React and React-DOM versions match
Error:
Access to XMLHttpRequest has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present
Solutions:
Check Backend .env:
# Must match your frontend URL exactly
CORS_ORIGIN="http://localhost:5173"
# For multiple origins (production):
CORS_ORIGIN="http://localhost:5173,https://yourdomain.com"Verify Backend main.ts:
// Should have CORS enabled
app.enableCors({
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
credentials: true,
});Check Frontend API URL:
# Frontend .env
VITE_API_URL=http://localhost:3000
# No trailing slash!Restart Both Servers:
# Backend
cd backend
npm run start:dev
# Frontend (new terminal)
cd frontend
npm run devError:
Unauthorized
or
Invalid token
or
jwt malformed
Solutions:
Clear Browser Storage:
// Open browser console (F12) and run:
localStorage.clear();
sessionStorage.clear();
// Then refresh pageVerify JWT_SECRET:
# Backend .env - this should NEVER change
JWT_SECRET="my-super-secret-jwt-key-for-food-manufacturing-saas-2026"
# If you change this, all existing tokens become invalidCheck Token Expiration:
# Default is 24 hours
JWT_EXPIRES_IN="24h"
# For development, you might want longer:
JWT_EXPIRES_IN="7d"Re-login:
- Logout from the application
- Clear browser storage
- Login again with credentials
Error:
npm ERR! code ENOENT
or
npm ERR! network issues
Solutions:
# Clear npm cache
npm cache clean --force
# Delete lock file and node_modules
rm -rf node_modules package-lock.json
# Reinstall
npm install
# If still failing, try updating npm
npm install -g npm@latestNetwork Issues:
# Use a different registry
npm config set registry https://registry.npmjs.org/
# Check your internet connection
ping registry.npmjs.orgError:
Migration failed
or
Database schema is out of sync
Solutions:
# Reset database (WARNING: Deletes all data)
npx prisma migrate reset
# Create a new migration
npx prisma migrate dev --name fix_schema
# Force push schema (development only)
npx prisma db pushIf Migration History is Broken:
# Delete migrations folder
rm -rf prisma/migrations
# Recreate initial migration
npx prisma migrate dev --name initError:
Build fails with various errors
Solutions:
Backend:
# Clean build
rm -rf dist
npm run build
# Check for TypeScript errors
npm run buildFrontend:
# Clean build
rm -rf dist
npm run build
# Test build locally
npm run previewEnvironment Variables for Production:
# Backend .env
NODE_ENV=production
DATABASE_URL="your_production_database_url"
# Frontend .env
VITE_API_URL=https://your-api-domain.comError:
Can't create new connection: pool is exhausted
Solution:
Add to prisma.service.ts:
export class PrismaService extends PrismaClient {
constructor() {
super({
datasources: {
db: {
url: process.env.DATABASE_URL,
},
},
// Add connection pool settings
connection: {
pool: {
min: 2,
max: 10,
},
},
});
}
}{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"esModuleInterop": true
}
}| Type | Convention | Example |
|---|---|---|
| Variables | camelCase | productName, userId |
| Constants | UPPER_SNAKE_CASE | MAX_ITEMS, API_URL |
| Functions | camelCase | getUserById(), calculateTotal() |
| Classes | PascalCase | ProductService, UserController |
| Interfaces | PascalCase (prefix I) | IProduct, IUserResponse |
| Components | PascalCase | ProductCard, LoginForm |
| Files | kebab-case | user-service.ts, auth-guard.ts |
β Wrong:
const apiUrl = 'http://localhost:3000';
const taxRate = 0.18;β Correct:
const apiUrl = process.env.VITE_API_URL;
const taxRate = parseFloat(process.env.TAX_RATE || '0.18');CRITICAL: If a value has no source, FAIL LOUDLY
const apiUrl = process.env.VITE_API_URL;
if (!apiUrl) {
throw new Error('VITE_API_URL is not defined in environment variables');
}Backend (NestJS):
@Get(':id')
async getProduct(@Param('id') id: string) {
try {
const product = await this.productService.findOne(id);
if (!product) {
throw new NotFoundException(`Product with ID ${id} not found`);
}
return product;
} catch (error) {
this.logger.error(`Error fetching product: ${error.message}`);
throw error;
}
}Frontend (React):
try {
const response = await api.get(`/products/${id}`);
setProduct(response.data);
} catch (error) {
if (axios.isAxiosError(error)) {
toast.error(error.response?.data?.message || 'Failed to fetch product');
} else {
toast.error('An unexpected error occurred');
}
}# Create feature branch from main
git checkout main
git pull origin main
git checkout -b feature/add-invoice-module
# Make changes and commit
git add .
git commit -m "feat: add invoice generation module"
# Push to remote
git push origin feature/add-invoice-module
# Create Pull Request on GitHubFollow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, no logic change)refactor: Code refactoringtest: Adding or updating testschore: Build process or auxiliary tool changesperf: Performance improvements
Examples:
git commit -m "feat(auth): add password reset functionality"
git commit -m "fix(invoice): correct GST calculation for interstate sales"
git commit -m "docs: update README with database setup instructions"
git commit -m "refactor(inventory): optimize stock movement queries"
git commit -m "test(production): add unit tests for batch creation"# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run test coverage
npm run test:cov
# Run e2e tests
npm run test:e2eExample Test:
describe('ProductService', () => {
it('should create a product', async () => {
const productDto = {
name: 'Test Product',
price: 100,
};
const result = await service.create(productDto);
expect(result).toBeDefined();
expect(result.name).toBe(productDto.name);
});
});# Run all tests
npm run test
# Run with coverage
npm run test:coverage# Create a migration after schema changes
npx prisma migrate dev --name add_expiry_date_to_products
# This will:
# 1. Create a new migration file
# 2. Apply it to the database
# 3. Regenerate Prisma Clientinit- Initial database setupadd_<table>_table- New tableadd_<column>_to_<table>- New columnrename_<old>_to_<new>- Rename operationremove_<column>_from_<table>- Delete columnupdate_<table>_indexes- Index changes
# Development
npx prisma migrate dev
# Production
npx prisma migrate deploy
# Reset database (CAUTION: Deletes all data)
npx prisma migrate resetBefore submitting a PR, ensure:
- Code follows naming conventions
- No hardcoded values (all in .env)
- Proper error handling implemented
- TypeScript types properly defined
- No console.logs in production code
- API endpoints use proper HTTP methods
- Role-based authorization implemented
- Database queries optimized
- Comments added for complex logic
- Tests added for new features
- README updated if needed
- Commit messages follow convention
We welcome contributions! Here's how you can help:
-
Fork the repository
# Click "Fork" on GitHub -
Clone your fork
git clone https://github.com/YOUR-USERNAME/FM-demo.git cd FM-demo -
Add upstream remote
git remote add upstream https://github.com/harpreet-2146/FM-demo.git
-
Create a feature branch
git checkout -b feature/amazing-feature
-
Make your changes
- Follow the Development Guidelines
- Write clean, documented code
- Add tests for new features
-
Test your changes
# Backend cd backend npm run test npm run start:dev # Frontend cd frontend npm run test npm run dev
-
Commit your changes
git add . git commit -m "feat: add amazing feature"
-
Push to your fork
git push origin feature/amazing-feature
-
Create Pull Request
- Go to your fork on GitHub
- Click "Pull Request"
- Fill in the PR template
- Link related issues
- Title: Use conventional commit format
- Description: Clearly describe changes and motivation
- Screenshots: Add for UI changes
- Testing: Describe how you tested
- Breaking Changes: Clearly document any breaking changes
- Maintainer reviews your PR
- Address any requested changes
- Once approved, PR will be merged
- Your contribution is live! π
This project is proprietary software developed for food manufacturing businesses.
All Rights Reserved Β© 2026
For licensing inquiries, please contact the repository owner.
- Documentation: You're reading it! π
- GitHub Issues: Report bugs or request features
- Discussions: Ask questions and share ideas
When reporting bugs, please include:
- Environment: OS, Node version, PostgreSQL version
- Steps to reproduce: Clear steps to recreate the issue
- Expected behavior: What should happen
- Actual behavior: What actually happens
- Screenshots: If applicable
- Error logs: Console output, server logs
We love hearing your ideas! When requesting features:
- Describe the feature: What should it do?
- Use case: Why is this needed?
- Examples: Similar features in other apps
- Impact: Who would benefit from this?
- NestJS - Progressive Node.js framework
- React - UI library
- Prisma - Next-generation ORM
- PostgreSQL - Robust database
- Tailwind CSS - Utility-first CSS
- Vite - Lightning-fast build tool
- Open-source community for amazing tools
- All contributors who help improve this project
- Food manufacturing industry for inspiration
Current Version: 1.0.0
Status: Active Development
Built: 2026
Last Updated: February 2026
- Core authentication & authorization
- Role-based dashboards
- Production management
- Inventory control (SRN/GRN)
- GST-compliant invoicing
- Commission tracking
- Mobile app (React Native)
- Advanced analytics & ML
- Multi-warehouse support
- Integration with accounting software
- Automated email notifications
- QR code for batch tracking