A comprehensive stock management application with conversational AI interface and intelligent invoice processing capabilities. Built for a 10-week final year CSE project.
- 🔐 JWT-based authentication with role-based access control
- 📦 Complete Product CRUD with search and filtering
- 🏢 Supplier management system
- 📊 Dashboard with inventory insights
- 🔍 Low stock alerts and monitoring
- 💾 PostgreSQL database with Prisma ORM
- 🎨 Responsive UI with Tailwind CSS and dark mode
- 💬 Real-time chat with WebSocket integration
- 🤖 Simple regex-based command parser
- 📝 Message history and context preservation
- 🔄 Real-time inventory updates
- 🧠 GPT-4 powered natural language processing
- 📈 Complex query handling and insights
- 🛒 Purchase order creation via chat
- 🎯 Intelligent supplier recommendations
- 📄 OCR with Google Document AI
- ✅ Intelligent invoice data extraction
- 🔍 GSTIN validation and GST calculations
- ⚡ Batch invoice processing
- 🔄 Duplicate detection and reconciliation
- 📊 Demand forecasting and analytics
- 🤖 Automated reorder suggestions
- 🎤 Voice input support
- 🐳 Docker deployment
- 🚀 CI/CD pipeline
Frontend:
- React 18 with TypeScript
- Tailwind CSS for styling
- Zustand for state management
- Socket.io-client for real-time communication
- Recharts for analytics
- React Hot Toast for notifications
Backend:
- Node.js with Express
- Socket.io for WebSocket
- JWT for authentication
- Bcrypt for password hashing
- Winston for logging
Database:
- PostgreSQL (primary database)
- Prisma ORM for type-safe queries
- Redis for session management and caching
AI Services:
- OpenAI GPT-4 API
- Google Document AI for OCR
- Node.js 20+ and npm
- PostgreSQL 16+
- Redis 7+
- OpenAI API key (for Phase 3)
- Google Cloud account with Document AI (for Phase 4)
```bash git clone cd Inventory ```
```bash cp .env.example .env ```
Edit .env and configure:
```env
DATABASE_URL="postgresql://username:password@localhost:5432/inventory_db"
REDIS_HOST=localhost REDIS_PORT=6379
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production JWT_EXPIRES_IN=7d
PORT=5000 NODE_ENV=development FRONTEND_URL=http://localhost:5173
OPENAI_API_KEY=sk-your-openai-api-key
GOOGLE_APPLICATION_CREDENTIALS=./path/to/service-account-key.json GOOGLE_PROJECT_ID=your-project-id GOOGLE_PROCESSOR_ID=your-processor-id ```
Option A: Using Docker Compose (Recommended)
```bash docker-compose up -d postgres redis ```
Option B: Local Installation
Make sure PostgreSQL and Redis are running on your system:
```bash
sudo service postgresql start
redis-server ```
```bash
npm run install:all ```
Or install individually:
```bash cd backend && npm install cd ../frontend && npm install cd ../ai-services && npm install ```
```bash cd backend
npx prisma generate
npx prisma migrate dev
npx prisma db seed ```
This will create:
- 2 demo users (admin and manager)
- 10 suppliers
- 50 products with realistic data
Option A: Start both together (from root directory)
```bash npm run dev ```
Option B: Start separately
Terminal 1 - Backend: ```bash cd backend npm run dev ```
Terminal 2 - Frontend: ```bash cd frontend npm run dev ```
The application will be available at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- API Health Check: http://localhost:5000/health
After seeding, you can login with:
Admin Account:
- Email:
admin@inventory.com - Password:
admin123 - Role: ADMIN (full access)
Manager Account:
- Email:
manager@inventory.com - Password:
manager123 - Role: MANAGER (limited access)
``` Inventory/ ├── backend/ # Express API server │ ├── src/ │ │ ├── config/ # Database, Redis, Logger configs │ │ ├── controllers/ # Route controllers │ │ ├── middleware/ # Auth, validation, error handling │ │ ├── routes/ # API routes │ │ ├── services/ # Business logic │ │ ├── utils/ # Helper functions │ │ └── index.ts # Entry point │ ├── database/ │ │ └── seed.ts # Database seeding │ ├── prisma/ │ │ └── schema.prisma # Database schema │ └── package.json ├── frontend/ # React application │ ├── src/ │ │ ├── components/ # Reusable components │ │ ├── pages/ # Page components │ │ ├── services/ # API client, Socket.io │ │ ├── store/ # Zustand state management │ │ ├── types/ # TypeScript types │ │ ├── utils/ # Helper functions │ │ ├── App.tsx # Main app component │ │ └── main.tsx # Entry point │ └── package.json ├── ai-services/ # AI integration services │ ├── src/ │ │ ├── openai/ # GPT-4 integration │ │ └── documentai/ # Google Document AI │ └── package.json ├── docs/ # Documentation ├── docker-compose.yml # Docker services ├── .env.example # Environment template └── README.md ```
npm run dev- Start both frontend and backend in development modenpm run build- Build both frontend and backend for productionnpm run test- Run all testsnpm run docker:up- Start Docker servicesnpm run docker:down- Stop Docker services
npm run dev- Start development server with hot reloadnpm run build- Build TypeScript to JavaScriptnpm start- Start production servernpm test- Run tests with Jestnpm run prisma:generate- Generate Prisma clientnpm run prisma:migrate- Run database migrationsnpm run prisma:seed- Seed database with sample datanpm run prisma:studio- Open Prisma Studio (database GUI)
npm run dev- Start Vite development servernpm run build- Build for productionnpm run preview- Preview production buildnpm test- Run tests
POST /api/auth/register- Register new userPOST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/me- Get current user
GET /api/products- Get all products (with pagination, search, filters)GET /api/products/:id- Get product by IDPOST /api/products- Create product (ADMIN/MANAGER)PUT /api/products/:id- Update product (ADMIN/MANAGER)DELETE /api/products/:id- Delete product (ADMIN)GET /api/products/low-stock- Get low stock productsGET /api/products/categories- Get all categoriesPOST /api/products/stock/update- Update stock (ADMIN/MANAGER)
GET /api/suppliers- Get all suppliersGET /api/suppliers/:id- Get supplier by IDPOST /api/suppliers- Create supplier (ADMIN/MANAGER)PUT /api/suppliers/:id- Update supplier (ADMIN/MANAGER)DELETE /api/suppliers/:id- Delete supplier (ADMIN)
The application uses 11 main models:
- Users - User accounts with role-based access
- Products - Inventory items with stock tracking
- Suppliers - Supplier information with GSTIN
- PurchaseBills - Invoice records with GST details
- BillLineItems - Individual items in purchase bills
- PurchaseOrders - Purchase order management
- POLineItems - Items in purchase orders
- ChatSessions - AI chat conversation sessions
- ChatMessages - Individual chat messages
- InventoryTransactions - Stock movement history
- StockAlerts - Low stock and reorder alerts
See backend/prisma/schema.prisma for complete schema details.
```bash docker-compose up -d ```
This starts:
- PostgreSQL on port 5432
- Redis on port 6379
- Backend API on port 5000
- Frontend on port 80
```bash docker-compose -f docker-compose.prod.yml up -d ```
```bash cd backend npm test ```
```bash cd frontend npm test ```
-
Verify PostgreSQL is running: ```bash docker ps # Check if postgres container is running
sudo service postgresql status # For local installation ```
-
Check DATABASE_URL in
.envmatches your setup -
Try resetting the database: ```bash cd backend npx prisma migrate reset ```
-
Check if Redis is running: ```bash redis-cli ping # Should return "PONG" ```
-
Verify REDIS_HOST and REDIS_PORT in
.env
Change the port in .env:
```env
PORT=5001 # Or any available port
```
And update frontend proxy in frontend/vite.config.ts
-
Create a new feature branch ```bash git checkout -b feature/your-feature-name ```
-
Make changes and test
- Backend: Add tests in
backend/src/__tests__ - Frontend: Add tests in component files
- Backend: Add tests in
-
Commit with meaningful messages ```bash git commit -m "feat: add product search functionality" ```
-
Push and create PR
- Implement Socket.io chat backend
- Create chat UI components
- Add regex-based command parser
- Implement message history
- Add real-time updates
- Set up OpenAI GPT-4 integration
- Implement NLP for inventory queries
- Add purchase order creation via chat
- Build supplier recommendation system
- Add conversation memory
- Integrate Google Document AI
- Build file upload system
- Create OCR processing pipeline
- Add GSTIN validation
- Implement duplicate detection
- Add demand forecasting
- Build analytics dashboard
- Implement voice input
- Performance optimization
- Production deployment
- Comprehensive testing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is created for educational purposes as a final year CSE project.
For issues and questions:
- Check the troubleshooting section
- Search existing issues on GitHub
- Create a new issue with detailed information
- OpenAI for GPT-4 API
- Google Cloud for Document AI
- Prisma for excellent ORM
- React and Node.js communities
Project Status: Phase 1 Complete ✅ | Current Phase: Phase 2 Development 🚧
Built with ❤️ for CSE Final Year Project 2024