Skip to content

Repository files navigation

🛍️ The Snack Shop — E-Commerce Web Application

A full-stack e-commerce web application for purchasing snacks online, built with React on the frontend and AWS Lambda + API Gateway + RDS (MySQL) on the backend. Developed as part of CSE 5234.


📋 Table of Contents


Overview

The Snack Shop allows customers to:

  • Browse a product inventory fetched from AWS RDS via Lambda
  • Search for items by name
  • Add items to a cart and go through a multi-step checkout flow (shipping → payment → confirmation)
  • View a final order confirmation

Order processing is handled by AWS Lambda functions that validate inventory, process payments, create shipping records, and persist orders to a MySQL database hosted on Amazon RDS. Post-order events (e.g. shipping creation) are triggered via Amazon EventBridge.


Tech Stack

Frontend

TechnologyPurpose
React 19UI framework
React Router DOM 7Client-side routing
React Bootstrap 2 + Bootstrap 5UI components & styling
AxiosHTTP requests to API Gateway
Styled ComponentsComponent-level CSS
React IconsIcon library

Backend (AWS)

TechnologyPurpose
AWS Lambda (Python)Serverless business logic
AWS API GatewayREST API endpoints
Amazon RDS (MySQL 8.0)Relational database
Amazon EventBridgeEvent-driven shipping trigger
PyMySQLPython MySQL connector in Lambda
Boto3AWS SDK for EventBridge

Architecture

Architecture Diagram


Project Structure

E-Commerce/
├── public/ # Static assets (images, favicon)
├── src/
│ ├── App.js # Root router — all page routes defined here
│ ├── styles.css # Global styles
│ ├── components/
│ │ ├── home.js # Home page with image carousel
│ │ ├── navBar.js # Top navigation bar
│ │ ├── footer.js # Footer with links
│ │ ├── carousel.js # Auto-advancing image carousel
│ │ ├── AboutUs.js # About Us page with team bios
│ │ ├── ContactUs.js # Contact page with FAQ accordion
│ │ └── shop/
│ │ ├── purchase.js # Product listing / shop page
│ │ ├── paymentEntry.js # Payment form
│ │ ├── shippingEntry.js # Shipping address form
│ │ ├── viewOrder.js # Order review page
│ │ └── confirmation.js # Order confirmation page
├── lambda/
│ ├── InventoryGet.py # GET all inventory items
│ ├── InventoryItemByIdGet.py # GET a single item by ID
│ ├── InventoryItemsGet.py # GET items by name (search)
│ ├── OrderPost.py # POST — full order processing orchestrator
│ ├── PaymentPost.py # POST — process & record payment
│ └── ShippingPost.py # POST — create shipping record (triggered by EventBridge)
├── data/
│ ├── shopdb_ITEM.sql
│ ├── shopdb_CUSTOMER_ORDER.sql
│ ├── shopdb_CUSTOMER_ORDER_LINE_ITEM.sql
│ ├── shopdb_PAYMENT_INFO.sql
│ └── shopdb_SHIPPING_INFO.sql
├── package.json
└── README.md

Frontend Pages & Components

RouteComponentDescription
/HomeLanding page with auto-advancing product image carousel
/purchasePurchaseBrowse all inventory items fetched from Lambda
/purchase/shippingEntryShippingEntryCollect customer shipping address
/purchase/paymentEntryPaymentEntryCollect credit card details
/purchase/viewOrderViewOrderReview order summary before submitting
/purchase/viewConfirmationConfirmationOrder confirmation with token
/aboutAboutUsTeam bios page
/contactContactUsContact info and collapsible FAQ

Backend — AWS Lambda Functions

All Lambda functions connect to Amazon RDS (MySQL) via environment variables and are exposed through AWS API Gateway.

InventoryGet.py

  • Trigger:GET /inventory
  • Returns all items from the ITEM table.

InventoryItemByIdGet.py

  • Trigger:GET /inventory/items/{id}
  • Returns a single inventory item by its primary key ID.

InventoryItemsGet.py

  • Trigger:GET /inventory/items?name={query}
  • Returns items whose names match the provided search query (case-insensitive LIKE search).

OrderPost.py

  • Trigger:POST /orders
  • Main order orchestration function. It:
    1. Validates inventory availability for all items in the cart
    2. Calculates the total order amount
    3. Calls the Payment service (PaymentPost) via HTTP
    4. Persists the order and line items to CUSTOMER_ORDER and CUSTOMER_ORDER_LINE_ITEM
    5. Publishes an event to Amazon EventBridge to trigger shipping creation

Request body:

{
"customerName": "Jane Doe",
"customerEmail": "jane@example.com",
"shipping": { "line1": "...", "city": "...", "state": "...", "postal_code": "..." },
"payment": { "cardNumber": "...", "expirationDate": "...", "cvvCode": "...", "cardHolderName": "..." },
"items": [{ "itemId": 1, "quantity": 2 }]
}

PaymentPost.py

  • Trigger: Called internally by OrderPost.py via HTTP POST
  • Simulates payment processing, stores only the last 4 digits of the card, and returns a paymentToken.

ShippingPost.py

  • Trigger: Amazon EventBridge event (published by OrderPost.py)
  • Creates a shipping record in the SHIPPING_INFO table with status Pending and a unique shippingToken.

Database Schema

The database is shopdb, hosted on Amazon RDS MySQL 8.0. SQL dumps are available in the data/ directory.

ITEM

ColumnTypeDescription
IDINT (PK)Auto-increment primary key
ITEM_NUMBERINT (UNIQUE)Product number
NAMEVARCHAR(255)Product name
DESCRIPTIONVARCHAR(500)Product description
IMAGEVARCHAR(1024)Image URL/path
AVAILABLE_QUANTITYINTStock quantity (≥ 0)
UNIT_PRICEDECIMAL(10,2)Price per unit (≥ 0)
CATEGORYVARCHAR(100)Product category

CUSTOMER_ORDER

ColumnTypeDescription
idINT (PK)Auto-increment primary key
order_tokenCHAR(36) (UNIQUE)UUID order identifier
customer_nameVARCHAR(100)Customer's name
customer_emailVARCHAR(255)Customer's email
shipping_info_id_fkINT (FK)References SHIPPING_INFO
payment_info_id_fkINT (FK)References PAYMENT_INFO
statusVARCHAR(255)Order status (default: New)

CUSTOMER_ORDER_LINE_ITEM

ColumnTypeDescription
idINT (PK)Auto-increment primary key
item_idINTReferences ITEM
item_nameVARCHAR(255)Snapshot of item name at purchase
quantityINTQuantity ordered
customer_order_id_fkINT (FK)References CUSTOMER_ORDER

PAYMENT_INFO

ColumnTypeDescription
idINT (PK)Auto-increment primary key
payment_tokenCHAR(36) (UNIQUE)UUID payment identifier
payment_methodVARCHAR(50)e.g., CreditCard
card_last4CHAR(4)Last 4 digits of card
provider_txn_idVARCHAR(100)Simulated provider transaction ID
amountDECIMAL(10,2)Charged amount
currencyCHAR(3)e.g., USD
statusVARCHAR(50)e.g., CONFIRMED

SHIPPING_INFO

ColumnTypeDescription
idINT (PK)Auto-increment primary key
business_idVARCHAR(50)Internal business reference
shipping_tokenCHAR(36) (UNIQUE)UUID shipping identifier
address_line1VARCHAR(255)Street address
address_line2VARCHAR(255)Apt/Suite (optional)
cityVARCHAR(100)City
stateVARCHAR(100)State
postal_codeVARCHAR(20)ZIP code
countryVARCHAR(100)Country (default: USA)
packet_countINTNumber of packages
packet_weightDECIMAL(10,2)Total weight
statusVARCHAR(50)e.g., Pending

Getting Started

Prerequisites

  • Node.js ≥ 18
  • npm

Install & Run

npm install
npm start

The app will run locally at http://localhost:3000.

Build for Production

npm run build

Environment Variables

Each Lambda function requires the following environment variables configured in the AWS Lambda console:

VariableDescription
DB_HOSTRDS endpoint (e.g. shopdb.xxxx.us-east-1.rds.amazonaws.com)
DB_USERDatabase username
DB_PASSWORDDatabase password
DB_NAMEDatabase name (e.g. shopdb)
PAYMENT_API_URLAPI Gateway URL for the Payment Lambda (OrderPost only)
INVENTORY_API_URLAPI Gateway URL for the Inventory Lambda (OrderPost only)
EVENT_BUS_NAMEEventBridge bus name (OrderPost only)

AWS Architecture

React Frontend (S3 / Local)
│
▼
AWS API Gateway
├── GET /inventory → InventoryGet.py
├── GET /inventory/items?name= → InventoryItemsGet.py
├── GET /inventory/items/{id} → InventoryItemByIdGet.py
└── POST /orders → OrderPost.py
│
┌──────────┴──────────┐
▼ ▼
PaymentPost.py Amazon EventBridge
(HTTP POST) │
│ ▼
│ ShippingPost.py
│
All Lambdas ──► Amazon RDS (MySQL — shopdb)

References

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages