🌟 Inspiration: Solving the SME Manufacturing Crisis

Manufacturing Small and Medium Enterprises (SMEs) generating $1M–$50M in revenue are the unsung backbone of the global supply chain. However, they are historically starved of modern, accessible technology. During our research, we discovered a massive operational crisis on the factory floor: managers are running multi-million dollar production lines using a fragile house of cards built out of fragmented Excel spreadsheets, WhatsApp group chats, and physical whiteboards.

This technological disconnect creates severe "silos," leading to what is known in supply chain management as the bullwhip effect. When sales orders are not instantly synced with warehouse inventory and production schedules, businesses suffer a 15–20% loss in revenue due to material stockouts, miscommunication, and delayed procurement.

We realized that existing ERPs (like SAP or Oracle) are far too expensive and complex for SMEs. We wanted to build a modern, AI-powered Business Operating System that completely eliminates these silos. Our vision was ForgeOS: a unified, intelligent platform where a customer clicking "Buy" on a B2C storefront would instantly, autonomously, and flawlessly orchestrate the entire B2B factory floor's logistics in real-time.


⚙️ What it does: The ForgeOS Ecosystem

ForgeOS is not a simple dashboard; it is a full-stack, production-grade B2B ERP system that manages the entire lifecycle of a manufacturing business.

1. The Autonomous "Make-to-Order" (MTO) Engine

The crown jewel of ForgeOS is its real-time automation engine. It seamlessly bridges the gap between customer sales and factory production:

  • The Storefront: Customers visit the integrated B2C Storefront (hosted on Vercel) and place an order.
  • The Brain: The moment the checkout completes, the ForgeOS backend instantly calculates physical inventory minus reserved inventory.
  • The Action: If the true stock is insufficient to fulfill the order, the engine intelligently triggers a Make-to-Order (MTO) pipeline. Without any human intervention, it automatically drafts Manufacturing Orders (MOs) for the factory floor and Purchase Orders (POs) for the exact raw materials required to fulfill the shortfall.

2. Enterprise-Grade Access Control

A factory has many departments, and data privacy is critical. ForgeOS utilizes strict JWT-based authentication to segment the application into 6 distinct roles:

  • Admin: Full system oversight.
  • Sales: Manages B2C orders and customer delivery.
  • Purchase: Manages vendor relationships and raw material intake.
  • Manufacturing: Tracks assembly lines, Bill of Materials (BOM), and production status.
  • Inventory: Handles stock movements, cycle counts, and warehouse logistics.
  • HR: Manages employee attendance and leave approvals. Users only see the data and UI elements permitted by their cryptographic role.

3. Forge AI: The Context-Aware Assistant

We integrated Google's Gemini 1.5 model directly into the ERP. Rather than being a generic chatbot, Forge AI has programmatic access to query the live AWS Aurora database. Managers can ask plain-English questions like "What products are currently running low on stock?" or "Summarize today's sales." The AI analyzes the live operational data and returns actionable business intelligence. Crucially, the AI respects the user's role—a Sales user cannot trick the AI into revealing HR payroll data.

4. Global Real-Time Sync

Using a custom Socket.io architecture, every single action taken on the factory floor is broadcast globally. If a warehouse worker receives inventory on an iPad, the Sales Manager's desktop dashboard updates instantly without a page refresh.


🏗️ How we built it: The Architecture

We engineered ForgeOS using a Micro-SaaS architecture to ensure enterprise-grade scalability and reliability.

The Database: Amazon Aurora PostgreSQL (AWS RDS)

Because our automation engine relies on cascading database transactions—simultaneously deducting stock, reserving inventory, checking Bill of Materials, and generating multiple order variants—we could not rely on a simple NoSQL database.

We utilized Amazon Aurora PostgreSQL. We modeled a highly complex, normalized relational schema consisting of 14 interconnected tables (Users, Products, SalesOrders, ManufacturingOrders, PurchaseOrders, StockLedger, Attendance, etc.). We heavily relied on Aurora's robust ACID compliance. By using Aurora's serverless auto-scaling capabilities, we ensured that high-traffic checkout events on the B2C storefront would never bottleneck the B2B factory operations. We mapped this database to our backend using the Prisma ORM for strict type safety and automated schema migrations.

The Backend: Node.js + Express

We built a monolithic Express API hosted on Render.com. To handle the real-time websocket broadcasts, we wrote a brilliant piece of global middleware. Instead of manually writing socket emit functions in all 15 of our API routes, our middleware intercepts the Express res.json() function. Whenever a database transaction successfully commits to AWS Aurora, the middleware automatically extracts the module name from the API route (e.g., /api/sales) and broadcasts a WebSocket event to all connected clients.

The Frontend: React + Vite on Vercel

We built two entirely separate frontend clients:

  1. The B2B ERP Application: A massive, multi-page React application utilizing React Router, TailwindCSS, and Axios.
  2. The B2C Storefront: A lightweight, consumer-facing shopping application. Both clients are deployed on Vercel's global edge network for maximum performance and instant content delivery.

🧗 Challenges we ran into

Building a system of this magnitude in a hackathon timeframe pushed our engineering skills to the absolute limit.

1. Mathematical Race Conditions in the MTO Engine

Calculating exact stock shortages dynamically is incredibly difficult. We had to account for physical stock versus reserved stock (stock that is physically in the warehouse, but promised to a pending order). Ensuring this math was perfect without introducing race conditions during high-traffic checkouts was a massive hurdle.

We solved this by leaning heavily into AWS Aurora's atomic transaction capabilities, implementing the following MTO shortage logic:

$$ S_{shortage} = \max(0, Q_{ordered} - (Q_{on_hand} - Q_{reserved})) $$

Where $S_{shortage}$ is the calculated shortfall that triggers an automated Manufacturing Order, $Q_{ordered}$ is the incoming storefront request, and $Q_{on_hand} - Q_{reserved}$ represents the true, free-to-use factory stock.

2. Cloud Networking and WebSockets

Maintaining a live-syncing automation engine across two entirely different Vercel domains and a Render backend introduced severe CORS and WebSocket handshake failures. Initially, cloud load balancers were dropping our WebSocket upgrades, causing the UI to freeze.

To solve this, we completely re-engineered our Socket.io middleware. We stripped restrictive credentials, applied wildcard origins, and engineered a robust fallback system. If the load balancers blocked the "fast lane" (WebSockets), our custom SocketContext would smoothly and invisibly fall back to the "slow lane" (HTTP Polling), ensuring the ERP remained synced no matter the network restrictions.

3. AI Data Security

Feeding live company data to an AI assistant is dangerous if not secured. A major challenge was ensuring the Gemini AI did not leak sensitive financial or HR data to lower-level employees. We overcame this by writing a role-based context injector; the backend verifies the user's JWT role before deciding which database schemas the AI is allowed to query.


🏆 Accomplishments that we're proud of

We are incredibly proud of successfully executing the Storefront-to-Factory Automation Pipeline. Watching a customer check out on the Vercel storefront, and then watching the ERP instantly calculate material shortages using our mathematical formulas to auto-generate factory work orders in less than a second is deeply satisfying.

We didn't just build a dashboard that displays data—we built an autonomous system that actively manages a business.


🧠 What we learned

This project was a masterclass in cloud architecture and relational database design.

  1. We learned the sheer power and reliability of Amazon Aurora. Trusting the database layer to handle highly complex, atomic transactions allowed us to focus our development time on the business logic rather than constantly worrying about data corruption or race conditions.
  2. We mastered WebSockets. We learned the intricate details of how HTTP Upgrades work, how load balancers intercept traffic, and how to build resilient real-time apps that survive harsh network environments.
  3. We learned how to design a deeply normalized SQL schema using Prisma, managing one-to-many and many-to-many relationships across 14 tables without degrading query performance.

🚀 What's next for ForgeOS

ForgeOS is fully functional, but our vision doesn't stop here. In the future, we plan to implement direct IoT integrations for factory machines.

We want ForgeOS to not only track Manufacturing Orders digitally but to connect directly to physical assembly line Programmable Logic Controllers (PLCs). By feeding live machine uptime, temperature metrics, and defect rates directly into our AWS Aurora database, the Forge AI assistant will be able to perform predictive maintenance, warning managers that a machine is likely to break down before it actually does.

ForgeOS is the future of SME manufacturing, and we are just getting started.

Built With

Share this project:

Updates