Skip to content

bryanrg22/Swerve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Swerve – Agentic Procurement, Built for Real Operations

1st Place – Dryft AI Challenge @ HackTech 2025

Swerve Logo

Procurement shouldn’t be a spreadsheet marathon. Swerve turns inventory, orders, and supplier data into fast, agent-guided decisions.


Table of Contents


What is Swerve?

Swerve is an agentic AI co-pilot for industrial procurement and inventory operations, built as a comprehensive Voltway electric scooter procurement management system.

It helps teams:

  • manage parts inventory
  • track purchase orders
  • analyze sales signals
  • monitor supplier reliability
  • automate low-stock and reordering workflows

Swerve is designed for operational realismβ€”not just β€œchat with your database.” It combines dashboard-first visibility with LangChain-powered agents that can reason over inventory and supply constraints and produce actionable, auditable recommendations.


The Problem

Procurement teams face a familiar grind:

  • inventory data is fragmented
  • stock checks are manual
  • reorder timing is inconsistent
  • supplier reliability is hard to quantify quickly
  • notifications arrive late (or not at all)

Even in smaller industrial settings, these gaps create:

  • preventable downtime
  • over-ordering or under-ordering
  • long lead-time surprises
  • reactive rather than proactive planning

The Solution

Enter Swerve.

A unified procurement workspace that couples:

  1. Operational dashboards (inventory, sales, suppliers, orders)
  2. Automation triggers (low stock, blocked parts, lead-time risk)
  3. AI-assisted workflows that guide decision-making step-by-step

The result is a system that reduces human overhead while preserving operator control.


Traction & Awards

  • 1st Place – Dryft AI Challenge @ HackTech 2025 (Caltech’s hackathon)
  • Built as the Swerve – Voltway Procurement Management System
  • Post-hackathon, we were flown out by the Dryft team to their San Francisco Neo offices for continued collaboration (Neo-funded).

Winner Image

Swerve project image HackTech 2025 Dryft AI Challenge Winner

In-office Collaboration

Swerve project image Post-hackathon collaboration at Dryft's San Francisco office


πŸš€ Current Project Overview

  • Objective: Build an AI-assisted procurement control center that helps operations teams plan, order, and maintain parts inventory with higher confidence and lower effort.

  • Scope: A realistic inventory + order + supplier system for Voltway electric scooters, with automation and analytics layered on top of Firestore-backed operational data.

  • What makes it different: Swerve doesn’t just show dataβ€”it turns data into decisions using agentic workflows.


πŸŽ₯ Demo Video

A short walkthrough of the Swerve dashboard, inventory logic, and AI-guided procurement flows.

Swerve Demo Video


AI-Assisted Automation Workflows

Swerve uses LangChain-powered agents to automate repetitive procurement analysis while keeping decisions grounded in real operational data.

Workflow Modules

  1. Inventory Health Automation

    • Detects low stock, blocked parts, and min-stock violations.
    • Flags parts with high downstream impact via BOM relationships.
  2. Order Risk Automation

    • Tracks late-risk using expected vs actual delivery patterns.
    • Highlights parts whose delays would stall high-volume models.
  3. Supplier Reliability Automation

    • Ranks suppliers by reliability rating, lead time, and price signals.
    • Suggests fallback suppliers when risk increases.
  4. Demand-Aware Reorder Suggestions

    • Connects recent sales trends to projected consumption.
    • Recommends reorder quantity and timing aligned to reorder intervals.
  5. Slack Insight Automation

    • Converts key changes (low stock, delivery slippage, supplier risk) into concise team alerts.

🧠 LangChain Agents (What We Actually Built)

Yesβ€”Swerve used agents.

We integrated LangChain to orchestrate tool-using agents that can:

  • retrieve live operational data
  • reason across multiple collections
  • generate structured recommendations
  • trigger notifications
  • produce procurement-ready summaries

Why LangChain?

LangChain gave us a clean, modular way to:

  • define tools (Firestore reads, analytics helpers, alert builders)
  • chain reasoning steps across inventory + supplier + order signals
  • maintain structured outputs that fit a real ops workflow

Agent Behavior (High-Level)

Swerve’s procurement copilot is designed around a simple idea:

You ask a procurement question β†’ the system routes the task β†’ a specialist agent pulls the right data β†’ you get an actionable answer.

Here’s the lifecycle:

  1. Engineer or ops user asks a question

    • Example: β€œAre we at risk of running out of P301 next week?”
    • Or: β€œWhich supplier is least reliable for motor assemblies?”
  2. A coordinator model identifies intent

    • It determines whether this is primarily inventory risk, order tracking, supplier reliability, or sales-driven demand.
  3. The request is routed to a specialized LangChain agent

    • Inventory Agent
    • Orders Agent
    • Supplier Agent
    • Sales/Forecast Agent
    • Notifications Agent (e.g., Slack summaries)
  4. That agent retrieves only task-relevant context

    • Instead of loading the whole database, it queries just what’s needed:

      • part metadata, stock + min-stock,
      • open orders + lead times,
      • supplier reliability,
      • recent sales linked to impacted models.
  5. The agent uses tools to compute + explain

    • The output is grounded in Firestore records and structured rules.
  6. Swerve returns a recommendation

    • Clear next steps, supporting numbers, and assumptions when needed.

This makes Swerve automation-first without being a black box.

Why Agents (Not Just One Chatbot)?

Agents let us:

  • constrain tool access by role
  • keep context narrow and relevant
  • isolate logic per domain
  • make the system easier to extend with new workflows.

Accuracy and Guardrails

Swerve is designed for operations-grade reliability, not generic chat.

We improve accuracy through:

  • Tool-grounded answers

    • Agents retrieve live, structured Firestore data rather than relying on memory.
  • Scoped context

    • Each agent only loads the records required for the current task.
  • Rule + data validation

    • Reorder suggestions check against:

      • min_stock,
      • blocked status,
      • lead time constraints,
      • BOM dependencies.
  • Structured outputs

    • Responses are shaped into consistent formats (risk summary β†’ evidence β†’ recommended next action).
  • Graceful fallback

    • When data is incomplete, Swerve surfaces assumptions explicitly and suggests what to verify next (e.g., missing orders or outdated supplier ratings).

Data Handling and Security

Swerve follows a least-privilege, operational-data-first approach:

  • Firestore as source of truth

    • Orders, parts, sales, and supplier metrics are stored with role-based access.
  • Secure auth

    • Access is gated through Firebase Authentication.
  • Isolated file handling

    • Any imported datasets or attachments are stored in Firebase Storage with scoped permissions tied to user roles.
  • Minimal AI data exposure

    • Agents pass only the task-relevant fields to the model (not entire collections or raw dumps).
  • Audit-friendly design

    • Recommendations can be traced back to part records, orders, supplier stats, and sales documents.

πŸ› οΈ Tech Stack at a Glance

πŸ–ΌοΈ Frontend

  • React.js
  • React Router
  • Tailwind CSS
  • Recharts
  • Lucide React
  • MapLibre GL

☁️ Backend

  • Python
  • Flask
  • Firebase Admin SDK

🧠 AI / Agents

  • LangChain – agent orchestration and tool routing
  • Hugo AI – custom procurement assistant layer
  • Slack Integration – automation-ready alerts and summaries

πŸ—„οΈ Database / Auth / Storage

  • Firebase Firestore
  • Firebase Authentication
  • Firebase Storage

🧱 System Architecture (High Level)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         OPERATIONS UI                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Procurement Dashboard                                      β”‚
β”‚  β€’ Parts + BOM Explorer                                       β”‚
β”‚  β€’ Orders & Delivery Tracking                                 β”‚
β”‚  β€’ Supplier Reliability & Map                                 β”‚
β”‚  β€’ AI Assistant Panel                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       REACT FRONTEND                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Charts, alerts, and workflow views                         β”‚
β”‚  β€’ Role-aware UX with Firebase Auth                            β”‚
β”‚  β€’ Calls Flask endpoints for analytics + AI                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        FLASK BACKEND                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Inventory + order APIs                                     β”‚
β”‚  β€’ Supplier analysis                                          β”‚
β”‚  β€’ LangChain agent runtime + tool registry                    β”‚
β”‚  β€’ Slack notification triggers                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FIREBASE DATA LAYER                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Firestore: parts, orders, sales, supply                    β”‚
β”‚  β€’ Storage: imports, assets                                   β”‚
β”‚  β€’ Auth: ops roles                                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”₯ Core Features

Dashboard

  • Overview of key metrics
  • Low stock alerts
  • Inventory status visualization
  • Sales charts
  • Supplier reliability analysis
  • Recent orders table

Products

  • View scooter models and their components
  • Track parts inventory for each model
  • Monitor stock levels and restock urgency

Parts Management

  • Track individual parts inventory
  • View part details and specifications
  • Monitor stock levels

Orders

  • Track purchase orders
  • Monitor delivery status
  • View order history

Supply Chain Map

  • Interactive global map
  • Visualize suppliers and warehouses
  • Track shipment routes

Hugo AI Assistant

  • AI-powered procurement assistant
  • Get insights on inventory status
  • Analyze supply chain data
  • Optimize procurement processes

Data Import

  • Import parts, orders, and sales data
  • Automatic database updates
  • AI-powered analysis after import

Notifications

  • AI-generated parts status updates
  • Low stock alerts
  • Integration with Slack for team notifications

πŸ—„οΈ Firebase Database Schema

firestore/
β”œβ”€β”€ orders/{order_id}                # e.g. orders/O5001
β”‚   β”œβ”€β”€ {order_id}
β”‚   β”‚   β”œβ”€β”€ order_date: string
β”‚   β”‚   β”œβ”€β”€ expected_delivery_date: string
β”‚   β”‚   β”œβ”€β”€ actual_delivered_at: string
β”‚   β”‚   β”œβ”€β”€ part_id: string             # FK β†’ parts/{part_id}
β”‚   β”‚   β”œβ”€β”€ supplier_id: string         # FK β†’ supply/{supply_id}
β”‚   β”‚   β”œβ”€β”€ quantity_ordered: number
β”‚   β”‚   └── status: string              # "pending" | "ordered" | "delivered"
β”‚
β”œβ”€β”€ parts/{part_id}                  # e.g. parts/P301
β”‚   β”œβ”€β”€ {part_id}
β”‚   β”‚   β”œβ”€β”€ part_name: string
β”‚   β”‚   β”œβ”€β”€ part_type: string           # "assembly" | "component"
β”‚   β”‚   β”œβ”€β”€ location: string
β”‚   β”‚   β”œβ”€β”€ stock_level: number
β”‚   β”‚   β”œβ”€β”€ min_stock: number
β”‚   β”‚   β”œβ”€β”€ blocked: boolean
β”‚   β”‚   β”œβ”€β”€ comments: string
β”‚   β”‚   β”œβ”€β”€ weight: number | null
β”‚   β”‚   β”œβ”€β”€ successor_part: string | null
β”‚   β”‚   β”œβ”€β”€ used_in_models: string[]    # e.g. ["S1_V1","S2_V1"]
β”‚   β”‚   β”œβ”€β”€ reorder_interval_days: number
β”‚   β”‚   β”œβ”€β”€ reorder_quantity: number
β”‚   β”‚   β”œβ”€β”€ bill_of_materials: array    # list of maps
β”‚   β”‚   β”‚   β”œβ”€β”€ [0]
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Part_ID: string
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Part_Name: string
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Qty: number
β”‚   β”‚   β”‚   β”‚   └── Notes: string
β”‚   β”‚   β”‚   β”œβ”€β”€ [1] { … }
β”‚   β”‚   β”‚   └── …
β”‚   β”‚   └── requirements: string[]      # e.g. ["Torque motor mounting …", "Run battery BMS …"]
β”‚
β”œβ”€β”€ sales/{sale_id}                  # e.g. sales/S6000
β”‚   β”œβ”€β”€ {sale_id}
β”‚   β”‚   β”œβ”€β”€ created_at: string
β”‚   β”‚   β”œβ”€β”€ accepted_request_date: string
β”‚   β”‚   β”œβ”€β”€ requested_date: string
β”‚   β”‚   β”œβ”€β”€ model: string
β”‚   β”‚   β”œβ”€β”€ version: string
β”‚   β”‚   β”œβ”€β”€ order_type: string          # "webshop" | "retail"
β”‚   β”‚   └── quantity: number
β”‚
└── supply/{supply_id}               # e.g. supply/SupA_P301
    β”œβ”€β”€ {supply_id}
    β”‚   β”œβ”€β”€ price_per_unit: number
    β”‚   β”œβ”€β”€ lead_time_days: number
    β”‚   β”œβ”€β”€ min_order_qty: number
    β”‚   └── reliability_rating: number

πŸ§ͺ Getting Started (Dev)

Prerequisites

  • Node.js (v16+)
  • npm or yarn
  • Python (v3.8+)
  • Firebase account

Frontend Setup

  1. Clone the repository

    git clone https://github.com/your-username/voltway-procurement.git
    cd voltway-procurement
  2. Install dependencies

    npm install
  3. Create a .env file in the root directory with your Firebase configuration

    NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key
    NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
    NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
    NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
    NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
    NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id

Backend Setup

  1. Navigate to the backend directory

    cd backend
  2. Create a virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Create a firebase-credentials.json file with your Firebase service account credentials

Running the Application

Frontend

npm run dev

The frontend will be available at http://localhost:3000.

Backend

python app.py

The backend API will be available at http://localhost:5000.


πŸ“ Project Structure

voltway-procurement/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”œβ”€β”€ pages/            # Page components
β”‚   β”œβ”€β”€ services/         # API and service functions
β”‚   β”œβ”€β”€ hooks/            # Custom React hooks
β”‚   β”œβ”€β”€ firebase.js       # Firebase configuration
β”‚   └── App.jsx           # Main application component
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py            # Flask application
β”‚   β”œβ”€β”€ routes/           # API routes
β”‚   └── services/         # Backend services
└── public/               # Static assets

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details. """

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published