Skip to content

About

Cash & Carry Mart is a full‑stack e‑commerce application demonstrating production‑style UI, REST APIs and advanced MySQL programming. Frontend uses React with React Router, Context API and Bootstrap; backend is Node.js/Express with mysql2. Authentication is JWT‑based and passwords are hashed with bcrypt.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛒 Cash & Carry Mart - E-commerce Platform

A full-stack e-commerce application built with React frontend and Node.js backend, featuring MySQL database with comprehensive product management, shopping cart, order processing, and admin dashboard.

🚀 Features

🛍️ Customer Features

  • Product Browsing: View products with search, filter, and sort options
  • Shopping Cart: Add, update, remove items with real-time inventory checks
  • User Authentication: Register, login, profile management
  • Order Management: Place orders, track status, view history
  • Categories: Browse products by categories
  • Responsive Design: Works on desktop, tablet, and mobile

👨‍💼 Admin Features

  • Dashboard: Overview of sales, orders, and inventory
  • Order Management: Update order status (pending → processing → shipped → delivered)
  • Inventory Control: Monitor stock levels and low-stock alerts
  • User Management: View and manage customer accounts
  • Sales Reports: Analytics and reporting features

🔧 Technical Features

  • RESTful API: Comprehensive backend API with proper error handling
  • JWT Authentication: Secure user authentication and authorization
  • Real-time Updates: Cart and inventory updates in real-time
  • Data Validation: Input validation on both frontend and backend
  • Error Handling: Comprehensive error handling and user feedback
  • Security: Password hashing, SQL injection prevention, CORS protection

📋 Prerequisites

  • Node.js (v16 or higher)
  • MySQL (v8.0 or higher)
  • Docker (optional, for containerized database)
  • Git

🛠️ Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd DBMS_Project

2. Setup Database (Docker)

# Start MySQL and phpMyAdmin
docker-compose up -d

# Wait for MySQL to be ready (1-2 minutes)
docker logs cash_carry_mysql

3. Setup Backend

cd backend
npm install
npm run db:reset  # Creates database, tables, and sample data
npm run dev       # Starts backend server

4. Setup Frontend

# In a new terminal, from project root
chmod +x setup-frontend.sh
./setup-frontend.sh  # Installs dependencies and creates necessary files
npm start            # Starts frontend development server

🌐 Access Points

🔑 Demo Credentials

Admin Account

  • Email: [email protected]
  • Password: secret
  • Features: Full admin access, order management, inventory control

Customer Account

  • Email: [email protected]
  • Password: secret
  • Features: Shopping, cart, orders, profile management

📊 Database Schema

Core Tables

  • users: Customer and admin accounts
  • categories: Product categories (8 categories)
  • suppliers: Product suppliers (4 suppliers)
  • products: Product catalog (16 sample products)
  • inventory: Stock management and tracking
  • shopping_cart: User shopping carts
  • orders: Order management and tracking
  • order_items: Individual order line items
  • payments: Payment processing and history
  • product_reviews: Customer reviews and ratings
  • wishlists: User wishlists

Sample Data

  • 8 Categories: Fruits & Vegetables, Dairy & Eggs, Meat & Seafood, etc.
  • 16 Products: Fresh produce, dairy, meat, bakery items
  • 4 Suppliers: Various food suppliers with contact details
  • Inventory: Full stock tracking for all products

🔄 Order Workflow

  1. Browse Products → Customer views product catalog
  2. Add to Cart → Products added with quantity validation
  3. Checkout → Order creation with customer details
  4. Payment → Demo payment processing
  5. Order Confirmation → Order placed successfully
  6. Admin Processing → Admin updates order status
  7. Shipping → Order marked as shipped
  8. Delivery → Order completed

📱 API Endpoints

Authentication

POST /api/auth/login       - User login
POST /api/auth/register    - User registration
GET  /api/auth/profile     - Get user profile

Products

GET  /api/products         - Get products (with filters)
GET  /api/products/:id     - Get single product
GET  /api/categories       - Get all categories

Shopping Cart

GET    /api/cart           - Get user cart
POST   /api/cart           - Add item to cart
PUT    /api/cart/:id       - Update cart item
DELETE /api/cart/:id       - Remove from cart

Orders

GET  /api/orders           - Get user orders
POST /api/orders           - Create new order
GET  /api/orders/:id       - Get order details

Admin

GET /api/admin/dashboard   - Admin dashboard data
GET /api/admin/orders      - All orders management
PUT /api/admin/orders/:id/status - Update order status

🧪 Testing

Manual Testing

# Test API endpoints
curl http://localhost:5001/health
curl "http://localhost:5001/api/products?limit=5"
curl http://localhost:5001/api/categories

# Test login
curl -X POST http://localhost:5001/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "password": "secret"}'

Automated Tests

# Run database tests
cd backend
npm run debug:products
npm run test:login

# Run frontend tests
cd ..
npm test

🚀 Deployment

Backend Deployment

  1. Set environment variables for production
  2. Configure production database
  3. Run npm run build
  4. Deploy to cloud service (AWS, Heroku, etc.)

Frontend Deployment

  1. Update API base URL in production
  2. Run npm run build
  3. Deploy build folder to static hosting (Netlify, Vercel, etc.)

🔧 Development Scripts

Backend Scripts

npm run dev           # Start development server
npm run db:setup      # Setup database
npm run db:reset      # Reset database with fresh data
npm run db:check      # Check database status
npm run test:login    # Test login functionality
npm run debug:products # Debug products API

Frontend Scripts

npm start            # Start development server
npm run build        # Build for production
npm test             # Run tests

🐛 Troubleshooting

Common Issues

  1. Port 3306 already in use

    • Solution: Using port 3307 for MySQL in docker-compose.yml
  2. Frontend not loading products

    • Check backend is running on port 5001
    • Verify API calls in browser network tab
    • Check CORS configuration
  3. Login not working

    • Run npm run test:login to verify credentials
    • Check JWT token generation
  4. Database connection issues

    • Ensure Docker containers are running
    • Check database credentials in .env file
    • Wait for MySQL to fully start (1-2 minutes)

Debug Commands

# Check Docker containers
docker ps

# Check MySQL logs
docker logs cash_carry_mysql

# Test database connection
npm run db:check

# Test API endpoints
./debug-api.sh

📚 Project Structure

DBMS_Project/
├── backend/                 # Node.js backend
│   ├── config/             # Database and app configuration
│   ├── routes/             # API route handlers
│   ├── middleware/         # Authentication, validation
│   ├── utils/              # Helper functions
│   └── scripts/            # Database setup scripts
├── src/                    # React frontend
│   ├── components/         # Reusable components
│   ├── pages/              # Page components
│   ├── contexts/           # React contexts (Auth, Cart)
│   └── services/           # API service layer
├── database/               # SQL schema and seed data
├── public/                 # Static assets
└── docker-compose.yml      # Docker configuration

🎯 Key Technologies

  • Frontend: React 18, React Router, Bootstrap 5, Axios
  • Backend: Node.js, Express.js, MySQL2, JWT, bcrypt
  • Database: MySQL 8.0 with stored procedures and triggers
  • Development: Docker, phpMyAdmin, Nodemon
  • Authentication: JWT tokens with bcrypt password hashing
  • Styling: Bootstrap 5, Font Awesome, Custom CSS

📄 License

This project is created for educational purposes as part of a Database Management Systems course.

👥 Contributing

This is an educational project. Feel free to fork and modify for learning purposes.


Built with ❤️ for DBMS Project 2024

About

Cash & Carry Mart is a full‑stack e‑commerce application demonstrating production‑style UI, REST APIs and advanced MySQL programming. Frontend uses React with React Router, Context API and Bootstrap; backend is Node.js/Express with mysql2. Authentication is JWT‑based and passwords are hashed with bcrypt.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages