Skip to content

akisma/CostFX

Repository files navigation

Restaurant AI Operations System - CostFX

An AI-powered restaurant operations optimization system that provides actionable insights on food waste, cost optimization, inventory management, and advanced demand forecasting.

✨ Key Features

🤖 3 Active AI Agents: Cost Analysis, Inventory Management, and Forecast Intelligence
📊 Real-time Analytics: Interactive dashboards with comprehensive data visualization
🔮 Predictive Forecasting: Demand, revenue, seasonal trends, and capacity optimization
📱 Modern UI: React-based responsive interface with professional design
🏗️ Production Ready: Enterprise-grade architecture with comprehensive testing

🚀 Quick Start

Prerequisites

  • Node.js 18+ and npm 8+
  • Docker and Docker Compose
  • OpenAI API key (for AI agents)
  • Pinecone account (optional, for advanced features)

Installation

  1. Clone and setup
npm install
  1. Environment configuration
cp .env.example .env
# Edit .env with your database credentials and API keys
  1. Start services
# Start database and Redis
npm run docker:up

# Run database migrations and seed data
npm run db:migrate
npm run db:seed

# Start development servers (backend + frontend)
npm run dev

The application will be available at:

Alternative Setup (One Command)

npm run setup

📁 Project Structure

CostFX/
├── backend/          # Node.js API server
│   ├── src/
│   │   ├── config/   # Database, Redis configuration
│   │   ├── models/   # Sequelize models
│   │   ├── routes/   # API routes
│   │   ├── controllers/ # Route handlers
│   │   ├── agents/   # AI agent implementations
│   │   ├── services/ # Business logic
│   │   └── middleware/ # Express middleware
│   └── tests/        # Backend tests
├── frontend/         # React application
│   ├── src/
│   │   ├── components/ # React components
│   │   ├── services/   # API services
│   │   ├── store/      # Redux store
│   │   └── hooks/      # Custom React hooks
│   └── tests/        # Frontend tests
└── shared/           # Shared types and utilities

🧠 AI Agents

The system includes specialized AI agents:

  1. Inventory Agent - Stock management, waste prediction, ordering optimization
  2. Cost Agent - Dish profitability analysis, cost-saving opportunities
  3. Forecast Agent - Demand prediction, prep time calculations
  4. Recipe Agent - Standardization, scaling, consistency monitoring

📊 Key Features

  • Food Waste Analysis - Track waste patterns and identify reduction opportunities
  • Cost Per Dish Calculation - Real-time profitability analysis
  • Intelligent Ordering - AI-powered purchase recommendations
  • Prep Time Forecasting - Optimize kitchen operations
  • Real-time Dashboard - Monitor key metrics and alerts

🛠 Development

Available Scripts

Root level:

  • npm run dev - Start both backend and frontend
  • npm run test - Run all tests
  • npm run build - Build for production
  • npm run setup - Complete setup from scratch

Backend:

  • npm run dev - Start development server with hot reload
  • npm test - Run backend tests
  • npm run db:migrate - Run database migrations
  • npm run db:seed - Seed database with sample data

Frontend:

  • npm run dev - Start Vite development server
  • npm test - Run frontend tests with Vitest
  • npm run build - Build for production

📈 Data Collection Format

For recipe and operational data collection:

Recipe Format

{
  "name": "Chicken Parmesan",
  "category": "main_course",
  "servingSize": 1,
  "prepTimeMinutes": 20,
  "cookTimeMinutes": 25,
  "ingredients": [
    {
      "name": "Chicken Breast",
      "quantity": 6,
      "unit": "oz",
      "preparationMethod": "pounded thin"
    }
  ]
}

Ingredient Database Structure

{
  "name": "Chicken Breast",
  "category": "protein",
  "unitType": "weight",
  "standardUnit": "lb",
  "avgCostPerUnit": 4.50,
  "storageType": "refrigerated",
  "shelfLifeDays": 5,
  "typicalWastePercentage": 0.03
}

🧪 Testing

# All tests
npm run test

# Watch mode
npm run test:watch

# With coverage
cd backend && npm run test:coverage
cd frontend && npm run test:coverage

🔧 Tech Stack

Backend

  • Node.js with Express
  • PostgreSQL for primary data storage
  • Redis for caching
  • Sequelize ORM
  • OpenAI API for AI agents
  • Winston for logging

Frontend

  • React 18 with Hooks
  • Vite for development and builds
  • Redux Toolkit for state management
  • React Query for server state
  • Tailwind CSS for styling
  • Recharts for data visualization

Development

  • Jest for backend testing
  • Vitest for frontend testing
  • ESLint for code quality
  • Docker for development environment
  • Review the API endpoints at /api/v1
  • Test the development environment with npm run dev

🚀 Production Deployment

Deployment Types

CostFX supports two deployment architectures:

Type Cost Best For Features
EC2 (Default) ~$51/mo Development, MVP Simple, cost-effective
ECS ~$126/mo Production Auto-scaling, load balancing, HA

Current Default: EC2 (simplified deployment)

Quick Deploy via GitHub Actions

  1. Go to Actions → "CostFX Infrastructure Deploy (Manual)"
  2. Click "Run workflow"
  3. Select:
    • Environment: dev or prod
    • Deployment type: ec2 (default) or ecs
  4. Click "Run workflow"

⏱️ Time: 15-20 minutes for EC2, 20-30 minutes for ECS

Access After Deployment

EC2: http://<elastic-ip> (from GitHub Actions output)
ECS: https://<load-balancer-dns> (from GitHub Actions output)

Documentation

Architecture:

  • EC2: Single instance with Docker Compose, RDS PostgreSQL
  • ECS: Fargate containers, ALB with HTTPS, RDS PostgreSQL, Auto-scaling

Built for restaurant operations optimization with AI-powered insights.

About

Cost savings and profit analysis tool for multiple industries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •