Skip to content

ftryyln/beverage-store-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงƒ Beverage Store: Enterprise CLI Management System

A production-ready command-line interface for beverage store operations
Built with Go, MySQL, and Clean Architecture principles

Go MySQL License


๐Ÿ“ Overview

Beverage Store CLI is a comprehensive management system designed for beverage retail operations. The application implements role-based access control (RBAC), complete CRUD operations, and advanced reporting capabilities through an intuitive command-line interface.

Developed as a Pair Programming Project by the BLACKMARKET Team for Hacktiv8's Fulltime Golang Program.


โœจ Key Features

๐Ÿ” Authentication & Authorization

  • User Registration: Secure account creation with password hashing
  • Login System: Session-based authentication
  • Role-Based Access: Separate permissions for Admin and Customer roles

๐Ÿ›๏ธ Product Management (Admin)

  • Inventory Control: Add, update, and delete beverage products
  • Category Assignment: Link products to multiple categories
  • Stock Monitoring: Track product availability

๐Ÿท๏ธ Category Management (Admin)

  • Dynamic Categories: Create custom beverage categories (Coffee, Tea, Juice, etc.)
  • Multi-Category Support: Products can belong to multiple categories

๐Ÿงพ Order Processing (Customer)

  • Shopping Cart: Add multiple items to cart
  • Order Placement: Complete purchase with order tracking
  • Order History: View past transactions

๐Ÿ“Š Business Intelligence Reports

  • Top Customer: Identify user with most orders
  • Best-Selling Product: Track most ordered beverage
  • Popular Category: Analyze category performance

๐Ÿ—๏ธ Architecture & Tech Stack

Backend Technologies

  • Language: Go (Golang) 1.20+
  • Database: MySQL 8.0+
  • Environment Config: godotenv
  • Testing: Go's built-in testing framework

Design Patterns

  • Clean Architecture: Separation of concerns (Handler โ†’ Entity โ†’ Config)
  • Repository Pattern: Database abstraction layer
  • MVC-like Structure: CLI (View) โ†’ Handler (Controller) โ†’ Entity (Model)

Project Structure

beverage_store/
โ”œโ”€โ”€ cli/              # Command-line interface & role-based menus
โ”‚   โ”œโ”€โ”€ menu.go
โ”‚   โ”œโ”€โ”€ menuAdmin.go
โ”‚   โ”œโ”€โ”€ menuCustomer.go
โ”‚   โ””โ”€โ”€ order.go
โ”œโ”€โ”€ config/           # Database connection configuration
โ”‚   โ””โ”€โ”€ db.go
โ”œโ”€โ”€ database/         # SQL schema (DDL) and sample data (DML)
โ”‚   โ””โ”€โ”€ beverage.sql
โ”œโ”€โ”€ docs/             # Documentation & ERD diagrams
โ”‚   โ””โ”€โ”€ ERD.png
โ”œโ”€โ”€ entity/           # Go structs (Database models)
โ”‚   โ”œโ”€โ”€ user.go
โ”‚   โ”œโ”€โ”€ product.go
โ”‚   โ”œโ”€โ”€ category.go
โ”‚   โ”œโ”€โ”€ order.go
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ handler/          # Business logic & database operations
โ”‚   โ”œโ”€โ”€ userHandler.go
โ”‚   โ”œโ”€โ”€ productHandler.go
โ”‚   โ”œโ”€โ”€ orderHandler.go
โ”‚   โ”œโ”€โ”€ reportHandler.go
โ”‚   โ””โ”€โ”€ *_test.go
โ”œโ”€โ”€ main.go           # Application entry point
โ”œโ”€โ”€ go.mod            # Go module dependencies
โ””โ”€โ”€ .env              # Environment variables

๐Ÿ—‚๏ธ Database Schema (ERD)

The application uses a normalized relational database with the following entities:

  • Users โ†’ User authentication data
  • UserDetails โ†’ Extended user information
  • Products โ†’ Beverage inventory
  • Categories โ†’ Product categorization
  • ProductCategories โ†’ Many-to-many relationship (Products โ†” Categories)
  • Orders โ†’ Customer purchase records
  • OrderItems โ†’ Individual items in each order

ERD Diagram


๐Ÿš€ Getting Started

Prerequisites

  • Go 1.20 or higher
  • MySQL 8.0 or higher
  • Git

Installation

  1. Clone the Repository

    git clone git@github.com:H8-FTGO-AOH-CLASSROOM-ALL-PHASE/p1-pair-project-beverage-store.git
    cd beverage_store
  2. Set Up Database

    # Create database and import schema
    mysql -u root -p < database/beverage.sql
  3. Configure Environment

    Create a .env file in the root directory:

    # Local Development
    DB_USER=root
    DB_PASS=your_password
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_NAME=beverage_store
  4. Install Dependencies

    go mod download
  5. Run the Application

    go run main.go

๐Ÿงช Testing

The project includes comprehensive unit tests for all core features:

# Run all tests
go test ./handler

# Run with verbose output
go test -v ./handler

# Run specific test file
go test -v ./handler/userHandler_test.go

Test Coverage

  • โœ… User authentication (success & failure cases)
  • โœ… Product CRUD operations
  • โœ… Category management
  • โœ… Order processing
  • โœ… Report generation

๐Ÿ“ฆ Dependencies

require (
    github.com/go-sql-driver/mysql v1.7.1
    github.com/joho/godotenv v1.5.1
)

๐ŸŽฏ Usage Examples

Admin Workflow

  1. Login as admin
  2. Add new beverage categories
  3. Create/update products
  4. View sales reports

Customer Workflow

  1. Register new account
  2. Browse available beverages
  3. Add items to cart
  4. Place order

๐Ÿ“Œ Key Implementation Details

  • Password Security: Hashed password storage (recommended: bcrypt)
  • Input Validation: Comprehensive validation for all user inputs
  • Error Handling: Graceful error messages and recovery
  • Database Transactions: ACID compliance for order processing
  • Buffered I/O: Efficient CLI input handling with bufio.Reader

๐Ÿ”ฎ Future Enhancements

  • REST API implementation
  • Web-based admin dashboard
  • Payment gateway integration
  • Inventory alerts (low stock notifications)
  • Customer loyalty program

๐Ÿง‘โ€๐Ÿ’ป Authors

Made with โค๏ธ by BLACKMARKET Team:

Hacktiv8 Fulltime Golang Program โ€“ Pair Programming Project (Phase 1)


๐Ÿ“„ License

This project is developed for educational purposes as part of Hacktiv8's curriculum.


Enterprise-Grade CLI, Built with Go ๐Ÿš€

About

Enterprise-grade beverage store management CLI built with Go & MySQL. Features: RBAC authentication, complete CRUD operations, order processing, business intelligence reports. Implements Clean Architecture, Repository Pattern, and comprehensive unit testing. Pair programming project.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages