Skip to content

phu-boop/diamond-store-fullstack

Repository files navigation

πŸ’Ž Diamond Store - Full-Stack E-Commerce Platform

Live Demo PHP MySQL Docker Render License CI - Docker Build

⚠️ Note: The application is hosted on Render's free tier. The server may go to sleep after inactivity. Please wait ~60 seconds for the initial load if the site is slow.

🌐 Live Demo: https://diamond-store-web.onrender.com

A production-ready jewelry e-commerce platform with modern DevOps practices, payment integration, and cloud deployment.

🎯 Project Overview

Diamond Store is a comprehensive full-stack e-commerce application developed as a University Course Project (3 months). It simulates a real-world luxury jewelry store, demonstrating end-to-end development capabilities from system design to production deployment using modern cloud infrastructure.

πŸ“Ή Live Demo Video (YouTube)


πŸ–ΌοΈ Screenshots

Homepage

Homepage

Admin Dashboard

Admin


πŸš€ Key Features

Customer-Facing

  • πŸ›οΈ Product Catalog - Browse, search, and filter jewelry by category, price, and material
  • πŸ›’ Shopping Cart - Complete cart management with real-time updates
  • πŸ’³ Payment Integration - Multiple payment methods (VNPay, MoMo, Cash on Delivery)
  • πŸ“§ Email Notifications - Automated order confirmation emails via PHPMailer

Admin Dashboard

  • πŸ“Š Order Management - Track and update order status
  • πŸ“¦ Inventory Control - CRUD operations for products and categories
  • πŸ‘₯ Customer Management - View customer data and order history
  • πŸ“ˆ Analytics - Sales reports and business insights

πŸ” Test Credentials (For HR/Reviewers)

Admin Dashboard:

Customer Account:

  • Email: demo@gmail.com
  • Password: password123!
  • (Or you can register a new account freely)

πŸ› οΈ Tech Stack

Backend

  • PHP 8.0 - Core application logic
  • MySQL 8.0 - Relational database with Railway cloud hosting
  • Apache 2.4 - Web server with mod_rewrite
  • Composer - Dependency management (PHPMailer)

Frontend

  • HTML5/CSS3 - Responsive UI design
  • JavaScript (Vanilla) - Interactive features
  • Font Awesome - Icon library

DevOps & Deployment

  • Docker - Containerization with multi-stage builds
  • Render.com - Web application hosting (free tier)
  • Railway - MySQL database hosting (free tier)
  • Git/GitHub - Version control with CI/CD auto-deployment

Payment APIs

  • VNPay - Vietnamese payment gateway
  • MoMo - Mobile wallet integration

πŸ”Œ Integrations

  • VNPay - IPN callback handling for secure payments
  • MoMo - Mobile wallet payment verification
  • PHPMailer - SMTP service for order confirmations

πŸ“¦ Deployment Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   GitHub Repo   β”‚
β”‚  (Source Code)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ Auto-deploy on push
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Render.com    │◄────►│  Railway MySQL   β”‚
β”‚   (Docker App)  β”‚      β”‚  (Database Host) β”‚
β”‚   Port: 80      β”‚      β”‚  Port: 28967     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   End Users     β”‚
β”‚ (Public Access) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Local Development Setup

Prerequisites

  • Docker & Docker Compose
  • Git

Quick Start

# 1. Clone repository
git clone https://github.com/phu-boop/diamond-store-fullstack.git
cd diamond-store-fullstack

# 2. Start with Docker Compose
docker-compose up -d

# 3. Import database
docker exec -i diamond-store-db mysql -uroot -prootpassword web_mysqli < web_mysqli.sql

# 4. Access application
open http://localhost:8080

Admin Access

  • URL: http://localhost:8080/admincp/login.php
  • Username: admin
  • Password: 123

🌐 Production Deployment

Infrastructure Setup

Database (Railway)

# Connection URL format
mysql://root:password@host:28967/railway

Web Application (Render)

  • Runtime: Docker
  • Auto-deploy: Enabled on main branch
  • Environment Variables: 6 configured (DB credentials, BASE_URL)

Deployment Process

  1. Code Changes β†’ Push to GitHub
  2. Automatic Build β†’ Render detects commit and triggers Docker build
  3. Container Deploy β†’ New container replaces old one (zero-downtime)

CI/CD Pipeline:

  • CI (GitHub Actions): Automatically builds the Docker image on every push to ensure code integrity and build success.
  • CD (Render): Automatically deploys the successful build to the production environment.

πŸ’‘ Technical Highlights

Problem-Solving & DevOps Skills

  1. Containerization

    • Custom Dockerfile with optimized layer caching
    • Multi-stage builds for dependency management
    • Challenge: Configuring Apache to serve properly behind Render's load balancer and handling variable port bindings.
    • Solution: Reconfigured 000-default.conf to bind to 0.0.0.0 and optimized the Dockerfile with multi-stage builds to reduce image size and build time.
  2. Database Migration

    • Migrated from localhost MySQL to cloud Railway
    • Dynamic port configuration (28967 instead of default 3306)
    • Challenge: Handling secure database connections across different environments (Dev vs Prod).
    • Solution: Implemented robust environment variable management for DB credentials and successfully migrated data from local MySQL to Railway's cloud instance.
  3. Dependency Management

    • Composer integration for PHPMailer library
    • Proper autoloading instead of manual requires
    • .gitignore for vendor directory exclusion
  4. Network Configuration

    • Fixed Apache VirtualHost binding issues
    • Custom 000-default.conf for wildcard interfaces
    • Listen 0.0.0.0:80 for external accessibility

πŸ“‚ Project Structure

diamond-store-fullstack/
β”œβ”€β”€ admincp/              # Admin panel
β”‚   β”œβ”€β”€ config/          # Database configuration
β”‚   └── modules/         # Admin features (products, orders, etc.)
β”œβ”€β”€ pages/               # Customer-facing pages
β”‚   β”œβ”€β”€ main/           # Main shopping flow
β”‚   └── header.php      # Navigation
β”œβ”€β”€ assets/             # Static resources (CSS, JS, images)
β”œβ”€β”€ mail/               # Email functionality (PHPMailer)
β”œβ”€β”€ Dockerfile          # Container configuration
β”œβ”€β”€ docker-compose.yml  # Local development stack
β”œβ”€β”€ render.yaml         # Render.com deployment config
β”œβ”€β”€ composer.json       # PHP dependencies
└── web_mysqli.sql      # Database schema & seed data

πŸŽ“ Skills Demonstrated

Backend Development

βœ… PHP object-oriented programming
βœ… MySQL database design & optimization
βœ… RESTful API integration (VNPay, MoMo IPN handling)
βœ… Email automation (PHPMailer/SMTP)
βœ… Session management & authentication

DevOps & Infrastructure

βœ… Docker containerization
βœ… Cloud deployment (Render + Railway)
βœ… CI/CD pipeline setup
βœ… Environment variable management
βœ… Web server configuration (Apache)

Software Engineering

βœ… Git version control
βœ… Dependency management (Composer)
βœ… Configuration file management
βœ… Documentation writing
βœ… Problem-solving & debugging


πŸ“Š Database Schema

  • tbl_sanpham - Product catalog (130+ items)
  • tbl_danhmuc - Product categories
  • tbl_giohang - Shopping cart & orders
  • tbl_khachhang - Customer accounts
  • tbl_vanchuyen - Shipping information
  • tbl_khuyenmai - Promotional campaigns
  • tbl_admin - Admin users

Total Records: 200+ customers, 127+ orders, 130+ products

πŸ—„οΈ Entity Relationship Diagram

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ ORDER_DETAIL : contains
    PRODUCT ||--o{ ORDER_DETAIL : includes
    CATEGORY ||--o{ PRODUCT : categorizes
    ADMIN ||--o{ PRODUCT : manages
Loading

(Ascii representation of core relationships)


πŸ” Security Features

  • Password hashing (MD5)

⚠️ Security Note: MD5 hashing is used due to the specific constraints of this course project. In a real-world production environment, bcrypt or Argon2 would be implemented for enhanced security.

  • SQL injection prevention via prepared statements
  • Environment variable-based secrets (no hardcoded credentials)
  • .gitignore for sensitive files

πŸ“ˆ Performance Optimizations

  • Docker layer caching for faster builds
  • Composer autoloader optimization (--optimize-autoloader)
  • Apache mod_rewrite for clean URLs
  • Database indexing on foreign keys

πŸš€ Future Enhancements

  • Upgrade password hashing to bcrypt/Argon2
  • Implement Redis for session storage
  • Add unit tests (PHPUnit)
  • Migrate to Laravel/Symfony framework
  • Implement CI/CD testing pipeline
  • Add monitoring (Sentry/New Relic)

πŸ“š What I Learned

  • Cloud Deployment: Gained hands-on experience deploying containerized PHP applications on Render and managing remote SQL databases on Railway.
  • Payment Integration: Understood the complexities of integrating real-world payment gateways (VNPay, MoMo) including handling IPN callbacks and signature verification.
  • DevOps: Learned to optimize Dockerfiles with multi-stage builds and manage environment-sensitive configurations.
  • Troubleshooting: Developed strong debugging skills by resolving cross-environment issues (local vs cloud) such as Apache port binding and CORS.

πŸ‘¨β€πŸ’» Developer

Nguyα»…n LΓͺ Anh PhΓΊ


πŸ“ License

This project is licensed under the MIT License.


πŸ™ Acknowledgments

  • Payment integration: VNPay, MoMo APIs
  • Icons: Font Awesome
  • Hosting: Render.com (Web), Railway (Database)
  • Email: PHPMailer library

⭐ If you find this project interesting, please give it a star!

About

πŸ’Ž Full-stack e-commerce platform for a luxury jewelry store, built with PHP & MySQL, featuring admin dashboard, payment integration (VNPay, MoMo), Dockerized deployment, and cloud hosting on Render & Railway.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors