Skip to content

mikeshuh/OFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

266 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯¬ OFS (On-Demand Food Service) Application

A full-stack e-commerce platform for groceries in the San Jose Downtown area, featuring online shopping, automated delivery optimization, and inventory management.

Docker Node.js React MySQL


πŸ“š Table of Contents


πŸ“‹ Overview

OFS is a modern web application that enables customers to purchase organic foods online and have them delivered by simulated autonomous vehicles. The system includes inventory management, order processing, delivery optimization, and a comprehensive dashboard for store employees and managers.

✨ Key Features

πŸ›’ Customer Features

  • Browse and purchase organic foods (fruits, vegetables, groceries)
  • Virtual shopping cart with item weight tracking
  • Online payment processing with Stripe
  • Automatic delivery fee calculation
    • βœ… Free delivery for orders under 20 lbs
    • ⚠️ $10 delivery fee for orders 20+ lbs
  • Order tracking and simulated delivery

πŸ”’ Security Features

Authentication & Session Management

  • Secure user authentication with JWT cookies
  • JWT blacklisting on logout using Redis
  • HTTP-only cookies for sensitive data

Request Protection

  • CSRF token protection for all API endpoints
  • Rate limiting
  • Strict CORS policy with credentials

Data Security

  • Input validation and sanitization using Express Validator
  • Secure password hashing

🚚 Delivery System

  • Bull queue for delivery job processing
  • Capacity: 10 orders per robot trip (up to 200 lbs total)
  • Automated route optimization using Mapbox API

πŸ“Š Management Features

  • Admin inventory management dashboard
    • CRUD operations on products

πŸ›  Tech Stack

Category Technologies
Frontend React Vite TailwindCSS Nginx
Backend Node.js Express
Database MySQL Redis
Services Stripe Mapbox
Queue Bull
DevOps Docker Docker Compose

πŸ— Architecture Overview

graph TD
    A[Client - Port 6422] --> B[Server API - Port 6423]
    B --> C[MySQL - Port 6424]
    B --> D[Redis]
    B --> E[Stripe API]
    B --> F[Mapbox API]
Loading

The application consists of four main services orchestrated with Docker Compose:

Service Description Port
MySQL Primary relational data storage 6424
Redis JWT blacklisting & Bull queue management Default
Server Node.js/Express API backend 6423
Client React frontend served by Nginx 6422

πŸš€ Quick Start

Prerequisites

  • Docker Desktop installed (Download here)
  • Stripe CLI installed (Download here)
    • Stripe CLI is necessary for payment integration on a local development environment
  • While installing MySQL is not necessary to test our application, if you wish to inspect the database records, install MySQL Shell and Server (Download here)
  • Log in to Stripe with test account credentials. To obtain the Stripe test account credentials, please contact:
  • Environment variables configured (see Environment Setup)

Installation

  1. Clone the repository

    git clone git@github.com:mikeshuh/OFS.git

    Alternatively, just copy the docker-compose.yml file into a folder on your file system.

  2. Set up environment variables

    • Create .env file in root directory (where the docker-compose.yml file is)
    • Contact for credentials (see below)
  3. Start containers

    docker compose up -d
  4. Run Stripe CLI

    stripe login

    Make sure you log in on the OFS account in Test mode.

    image

    stripe listen --forward-to localhost:6423/api/payments/webhook

    Ensure the webhook signing secret displayed in the terminal matches the one we provide for your .env.

  5. Access the application

πŸ” Environment Setup

To obtain the necessary environment variables, please contact:

πŸ“§ Email: michael.stephen.huh@gmail.com
πŸ’¬ Discord: mikrelin

The environment file includes:

  • Database credentials
  • API keys (Stripe, Mapbox)
  • JWT secrets
  • Redis connection details
  • Other application-specific settings

πŸ—„ Database Access

To connect to the MySQL database directly:

# Connect to MySQL from your local machine
mysql -P 6424 -u root -p

When prompted for a password, enter the MYSQL_ROOT_PASSWORD value from your .env file.

This gives you direct access to manage the database, run queries, and inspect data.

πŸ“ Docker Compose

NOTE: If you are on a M1 Mac, uncomment the platform specification lines for each service.

services:
  mysql:
    image: mikeshuh/ofs-mysql:latest
    # platform: linux/amd64  # Uncomment this line if you are using a M1 Mac
    build:
      context: ./database
      dockerfile: Dockerfile
    env_file: .env
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "6424:3306"  # Maps host port 6424 to container port 3306
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p$${MYSQL_ROOT_PASSWORD}"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 30s

  redis:
    image: redis:7-alpine
    # platform: linux/amd64  # Uncomment this line if you are using a M1 Mac
    restart: unless-stopped
    command: ["redis-server","--appendonly","yes"]
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 3

  server:
    image: mikeshuh/ofs-server:latest
    # platform: linux/amd64  # Uncomment this line if you are using a M1 Mac
    build:
      context: ./server
      dockerfile: Dockerfile
    env_file: .env
    ports:
      - "6423:4000"
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL","curl -f http://localhost:4000/health || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 3

  client:
    image: mikeshuh/ofs-client:latest
    # platform: linux/amd64  # Uncomment this line if you are using a M1 Mac
    build:
      context: ./client
      dockerfile: Dockerfile
    ports:
      - "6422:80"
    depends_on:
      - server
    restart: unless-stopped
volumes:
  db_data:
  redis_data:

Ensure the host ports (6422, 6423, 6424) are not already in use.

πŸ’» Development

Building from Source

# Build all services
docker compose build

# Build specific service
docker compose build mysql
docker compose build server
docker compose build client

Viewing Logs

# All services
docker compose logs -f

# Specific service
docker compose logs -f server

Stopping Services

# Stop all services
docker compose down

# Stop and remove volumes (⚠️ deletes data)
docker compose down -v

πŸ” Health Checks

Service Check Method Interval
MySQL mysqladmin ping 5s
Redis redis-cli ping 5s
Server http://localhost:6423/health 30s

πŸ“ž Support

For assistance or to report issues:

Demo Video

https://drive.google.com/file/d/1nknXU9W_R50UTYkf0QjciaxxmUw7oNbm/view?usp=sharing


Need Environment Variables?
Contact Michael at michael.stephen.huh@gmail.com or on Discord (mikrelin)

About

A full-stack e-commerce platform for groceries, featuring online shopping, automated delivery optimization, and inventory management

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages