Welcome to our Virtual Coffee Machine Simulation! This awesome project is your magical bridge to understanding computational thinking through a real-world coffee machine simulation. Think of it as bringing your coffee dreams to life with code! No more just thinking about algorithms – let's make them brew things!
- ✨・What is Coffee Machine Simulation?
- 🛠️・Getting Started
- ⚙️・Setup Google Sheets Database
- 🗺️・How to Use
- 🚀・Amazing Features
- 🆕・What’s New in Term 2 (Improvements)
- 📊・Computational Thinking Applied
- 💖・Contributing
- 📜・License
- 👋・About Us!
Our Virtual Coffee Machine Simulation is a super cool project designed to demonstrate computational thinking principles through a real-world coffee machine experience! 🚀 This is our final project for the Computational Thinking course at Institut Teknologi Bandung (ITB), specifically for the Matriculation Program ("Tahap Persiapan Bersama").
The simulation features:
- 🌐・Google Sheets Integration as a live database
- 🛒・Multi-order Management system
- 💳・Multiple Payment Methods (Cash & QRIS)
- 📱・QR Code Integration for order confirmation
- 🔐・Admin Panel with secure authentication
- 🎯・Real-time Stock Management
Get ready to see computational thinking in action through coffee brewing! ☕✨
Ready to bring your coffee machine to life? Here's how to get our simulation up and running in a flash:
-
Clone the magic! ✨
git clone https://github.com/ZulfaNurhuda/CoffeeMachine.project.git cd CoffeeMachine.project
-
Set Up Python Virtual Environment 🐍
# Navigate to the src directory cd src # Create virtual environment python -m venv CoffeeMachine.env # Activate virtual environment # On Windows: CoffeeMachine.env\Scripts\activate # On macOS/Linux: source CoffeeMachine.env/bin/activate
-
Install Dependencies 📦
pip install -r requirements.txt
-
Configure Environment Variables 🔐
# Copy environment template cp credentials/.env.example credentials/.env
Edit the
.env
file with your Google Sheets credentials (see next section for detailed setup).
Our coffee machine uses Google Sheets as its live database! Here's how to set it up:
- Visit our Database Template: Coffee Machine Database Template
- Make a Copy: Click "File" → "Make a copy" to create your own version
- Note the Spreadsheet ID: Copy the long string between
/d/
and/edit
in your new spreadsheet URL
Our spreadsheet contains these essential sheets:
PersediaanKopi
: Coffee types, prices, and stock informationPersediaanTambahan
: Additional ingredients and their stock levelsReferenceID
: Reference data and ID mappingsAntrianPesananQR
: QR code order queue and online order managementDataPenjualan
: Sales transaction records and order history
- Go to Google Cloud Console: Visit console.cloud.google.com
- Create New Project: Click "Select a project" → "New Project" → Enter project name → "Create"
- Enable Google Sheets API: Go to "APIs & Services" → "Library" → Search "Google Sheets API" → "Enable"
- Create Service Account: "APIs & Services" → "Credentials" → "Create Credentials" → "Service Account"
- Generate JSON Key: Click your service account → "Keys" → "Add Key" → "Create New Key" → Choose "JSON"
- Save Credentials: Save the downloaded file as
credentials.json
incredentials/
- Share Spreadsheet: Open your spreadsheet → "Share" → Add service account email → Give "Editor" permissions
Edit your .env
file:
# Path/file name of your service account json inside src/credentials
FILE_AKUN_LAYANAN=credentials.json
# Google Spreadsheet ID (string between /d/ and /edit)
ID_SHEET=your_sheet_id
Once everything is set up, you're just one command away from brewing virtual coffee!
You can run from the repository root or from src
:
cd src
python main.py
Then follow the interactive menu to:
- Browse Menu: View available coffee options with real-time stock
- Place Orders: Select coffee, customize composition, choose quantity
- Pick Temperature: Hot or cold - your choice!
- Make Payment: Choose between cash or QRIS payment
- QR Confirmation (Web): For QRIS, scan the ASCII QR shown to open the local page and confirm payment
- Scan Online Order: Use menu "Scan QR" to process website orders from the sheet queue
- Admin Access: Use admin code for restocking and system management
Notes:
- The app starts a local web service in the background at
http://0.0.0.0:5000
for QR confirmation pages. - Input prompts time out after 60s and return to the main menu automatically.
Our coffee machine simulation is packed with incredible features:
- 🌐 Google Sheets Integration: Real-time database connectivity
- 🛒 Multi-Order Management: Handle multiple orders simultaneously
- 🎛️ Customizable Menu: Dynamic menu based on available data
- 🌡️ Temperature Selection: Choose between hot and cold beverages
- 🧂 Custom Composition: Adjust sugar, milk, creamer, chocolate
- 💳 Dual Payment System: Cash and QRIS payment methods
- 📱 QR Code Integration: QRIS checkout with ASCII QR and local confirmation page
- 📊 Detailed Order Recording: Comprehensive transaction logging
- 🛡️ Error Handling: Robust error management system
- ℹ️ User-Friendly Interface: Clear information at every step
- ✅ Input Validation: Comprehensive user input validation
- 🔐 Admin Panel: Secure admin menu with authentication
- Modular Architecture: Clean separation into
apps/
packages (menu, orders, payments, admin, DB, webservice, utils). - Background Web Service: Flask server runs alongside CLI for QR confirmations (
/search
,/proses_cari
,/berhasil
,/gagal
). - QRIS Flow Upgrade: ASCII QR encodes a local URL; visiting the page updates status to "Selesai" automatically.
- 📱 Online Order Scanner (Webcam QR Scanning): Revolutionary new "Scan QR" menu feature that uses your webcam with OpenCV to scan QR codes from online orders! Process orders from the
AntrianPesananQR
queue automatically, intelligently handles partial inventory fills, and updates Google Sheets in real-time. Perfect for bridging online orders to your physical coffee machine! 🎥✨ - Input Timeout UX: Prompts auto-cancel after 60s and return to main menu.
- Bestseller Highlight: Menu marks most sold coffee (★) derived from
DataPenjualan
. - Queued + Periodic Sync: Batched cache updates to Sheets in the background, with safe synchronous paths for admin restock and admin code persistence (
credentials/admin_code.txt
). - Graceful Shutdown: CTRL+C triggers a final sync to persist pending updates.
This project demonstrates key computational thinking principles in action:
- 🧩 Decomposition: Breaking down coffee ordering into smaller, manageable tasks (selection → customization → payment → confirmation)
- 🔍 Pattern Recognition: Identifying common user behaviors and system patterns throughout the ordering process
- 🎯 Abstraction: Simplifying complex real-world coffee machine operations into clean, understandable code structures
- ⚙️ Algorithm Design: Creating step-by-step procedures for order processing, payment validation, and stock management
- 🔄 Iteration: Implementing loops for menu displays, order processing cycles, and user interactions
- 📊 Data Structures: Organizing information efficiently using lists, dictionaries, and objects for orders and coffee data
Get ready to see computational thinking brew some amazing results! ☕✨
GROUP 13 - CLASS 31, COMPUTATIONAL THINKING course
- Laurenisus Dani Rendragraha (19624272)
- Mineva Azzahra (19624227)
- Muhammad Faiz Alfada Dharma (19624244)
- Muhammad Zulfa Fauzan Nurhuda (19624258)
Just regular students studying Computational Thinking at ITB! 😄 Always excited to learn and build cool stuff through code! We're passionate about applying computational thinking principles to solve real-world problems, one virtual coffee at a time! ☕🚀