Skip to content

Insha-7/Vending_Machine

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vending Machine Project

This project is a full-stack vending machine application with a C++ backend and a React/MUI frontend.


Project Structure

vending_machine/
├── backend/      # C++ API server
└── frontend/     # React frontend

Prerequisites

Backend Dependencies

CMake and Make

C++ Compiler

OpenSSL

  • macOS:

    brew install openssl
  • Windows:

    • Download from OpenSSL for Windows
    • Install the full version (not light)
    • Add OpenSSL to your system PATH

Frontend Dependencies

Node.js and npm

Note: After installing Node.js, verify your installation:

node --version
npm --version

Quick Start

Option 1: Run Both Frontend and Backend Together

macOS/Windows

cd frontend
npm install
npm run dev:all

This will start both servers:

Option 2: Run Services Separately

Running the Backend

macOS/Windows
cd backend
make run

Available make commands:

  • make build - Build the project
  • make run - Build and run the server
  • make clean - Clean build files
  • make help - Show available commands

Running the Frontend

cd frontend
npm install
npm run dev

Development Workflow

  1. Start the Backend:

    • Use make run in the backend directory
    • The backend will automatically build if needed
  2. Start the Frontend:

    • The frontend will automatically connect to the backend
    • Hot reloading is enabled for development
    • Changes will be reflected immediately
  3. Making Changes:

    • Backend changes require a server restart (make run again)
    • Frontend changes are automatically reloaded
    • Both Windows and macOS users can work on the same codebase

Troubleshooting

Common Issues

  • Backend Won't Start?

    • Check if port 8080 is available
    • Verify OpenSSL is installed correctly
    • On Windows, ensure Visual Studio C++ tools are installed
    • Try make clean followed by make run
  • Frontend Can't Connect?

    • Ensure the backend is running
    • Check browser console for CORS errors
    • Verify both servers are using the correct ports

Platform-Specific Issues

Windows

  • If Make is not found:
    • Add Make to your system PATH
    • Restart your terminal
  • If OpenSSL is not found:
    • Add OpenSSL to your system PATH
    • Restart your terminal

macOS

  • If Xcode tools are missing:
    xcode-select --install
  • If Homebrew is not installed:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

API Endpoints

The backend provides the following endpoints:

  • GET /api/items - Get available items
  • POST /api/insert-money - Insert money (body: { amount: number })
  • POST /api/purchase - Purchase an item (body: { item: string, quantity: number })
  • POST /api/return-change - Return change

Contact / Support

If you have issues, please check the console output and error messages, then ask for help with the details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 68.3%
  • Makefile 28.6%
  • JavaScript 1.2%
  • C 1.1%
  • CMake 0.8%
  • Shell 0.0%