Skip to content

akisma/CostFX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

169 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

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

 
 
 

Contributors