OptiBean is an enterprise-scale software system designed for the coffee roastery industry. The system combines the cognitive reasoning (Agentic AI) of Google AI Studio (Gemini) with high-performance algorithmic computing (HPC) on Google Cloud Platform (GCP) to solve the Batch Roasting Allocation Problem or Bin Packing Problem. The goal is to minimize capacity waste and improve roasting machine operational efficiency to nearly 100%.
This system is designed using an asynchronous microservices approach to avoid computational bottlenecks:
-
Global Ingress Layer (Frontend & Security)
- Cloud Storage & Cloud CDN: Globally distributed ReactJS (Next.js) application with low latency.
- Cloud Load Balancing & Cloud Armor: Protects the application from DDoS attacks.
-
API & Security Layer
- Cloud API Gateway / Cloud Run: A secure and validated REST API gateway before forwarding requests to the backend layer.
-
Serverless Compute & AI Orchestration
- Cloud Run (Next.js API Routes): Acts as the orchestrator that assembles dynamic prompts and manages workflows.
- Google AI Studio (Gemini 1.5 Pro / 2.5 Flash): A multi-role cognitive agent acting as a Q-Grader, Procurement Advisor, and sustainability orchestrator. It analyzes coffee profiles, recommends business strategies, and triggers the computation engine.
- Google Cloud Batch (Algorithmic Simulation): Executes purely optimization algorithms (First Fit Decreasing Heuristic) to find the best coffee roasting batch allocation patterns. This separation of concerns is crucial because LLMs are not designed for high-precision mathematical computations.
- Vertex AI: In addition to processing Vision AI for green bean defect inspection, Vertex AI provides Predictive Maintenance simulations and external signals (C-Market pricing, harvest origin weather fluctuations, and logistics disruptions).
-
Data & Analytics Layer
- AlloyDB for PostgreSQL: (Planned) Transactional database for daily work orders.
- BigQuery & Dataflow: (Planned / Simulated) Data warehouse that stores production waste data to generate real-time environmental insights.
The Dashboard Application uses an elegant "Natural Tones" design theme and features the following modules:
- Optimization Engine: Optimizes roasting machine utilization (Batch Allocation). Data is sent for processing through computational algorithms, represented alongside AI cognitive insights.
- Vision AI Quality: Utilizes Vision AI to scan raw coffee beans for physical defects via image uploads, outputting net yield estimates and recommended actions (e.g., manual sorting).
- AI Flavor Profiler: The AI Agent acts as a Master Roaster and Q-Grader. Takes inputs such as bean origin, elevation, and target roast level to formulate the ideal flavor notes profile and roast curve.
- Inventory Intelligence: Manages inventory flexibly (manual CRUD) while serving as a Procurement Advisor. It collaborates AI capabilities with external Vertex AI signals (market/weather) to formulate pre-purchase procurement guidelines.
- Cloud Batch Status: Monitors heavy computational jobs asynchronously, complete with a pseudo real-time terminal.
- Analytics & Vertex AI: A predictive maintenance module that processes turbine/drum telemetry logs to predict electrical wear and tear.
- AI Reasoning Logs: A comprehensive observability center for the entire decision-making timeline, latency, response speed, and tokens consumed by various agents (Vision, Profiler, Procurement).
- System Settings: A registry for configuring GCP parameters (Project, Dataset, etc.).
This application is built on Next.js 15 (App Router) with Tailwind CSS v4.
- Clone the application repository.
- Copy
.env.exampleto.envand configure your secrets (e.g.,GEMINI_API_KEY). - Run
npm installto download dependencies. - Run
npm run devto start the development server.
- Separation of Concerns: AI handles purely cognitive reasoning (strategic pattern recognition), while precision mathematical arrangements are fully managed by conventional compute engines (Cloud Batch).
- Sustainability: This solution does not merely pursue time efficiency but focuses on electricity/gas conservation and avoiding the waste of high-quality coffee beans.
- Observability First: Each module (Settings, Logs, Batch) is architected to allow SRE (Site Reliability Engineers) teams to easily understand what is happening inside the pipeline during execution.