A Java-based e-commerce platform with modern frontend built using Jakarta Servlet, PostgreSQL, and HTML/CSS/JavaScript.
- Backend: Jakarta Servlet 6.0, JDBC
- Frontend: HTML, CSS, JavaScript
- Database: PostgreSQL 15.1
- Server: Apache Tomcat 10.1
- Build: Manual compilation with
javac
- Create the PostgreSQL database:
CREATE DATABASE jcart;- Run the seed script:
psql -d jcart -f seed/init_db.sqlEnsure
products.csvis in theseed/folder or update theCOPYpath ininit_db.sql.
Compile:
javac -cp "lib/*" -d WEB-INF/classes src/**/*.javaDeploy:
./build/deploy.sh- JNDI name:
java:comp/env/jdbc/JCart - Configure
context.xmlin Tomcat with your database credentials
JCart/
├── build/
│ └── deploy.sh # Deployment script
├── seed/
│ ├── init_db.sql # Database schema & seed data
│ └── products.csv # Initial product data
├── src/
│ ├── config/
│ │ ├── AsyncExecutor.java # Thread pool for async operations
│ │ └── TaskExecutor.java # Scheduled tasks (session, cart, order cleanup)
│ ├── controller/
│ │ ├── AddressController.java # Customer address management
│ │ ├── AdminController.java # Admin endpoints (login, profile, password)
│ │ ├── AdminManagementController.java # Admin management for admins (CRUD, search, stats)
│ │ ├── BaseController.java # Base controller with common methods
│ │ ├── CartController.java # Customer cart management
│ │ ├── CustomerController.java # Customer endpoints (register, login, profile)
│ │ ├── CustomerManagementController.java # Customer management for admins (search, view, deactivate)
│ │ ├── OrderController.java # Customer order endpoints (search, view, cancel, update address)
│ │ ├── OrderManagementController.java # Order management for admins (search, view, update status)
│ │ ├── ProductController.java # Customer product endpoints (search, view)
│ │ ├── ProductManagementController.java # Product management for admins (CRUD, search, stats)
│ │ ├── TransactionController.java # Customer transaction viewing (search, view)
│ │ └── TransactionManagementController.java # Transaction management for admins (search, view, stats, refund actions)
│ ├── dao/
│ │ ├── AddressDAO.java # Address database operations
│ │ ├── AdminDAO.java # Admin database operations with search filters
│ │ ├── CartDAO.java # Cart database operations
│ │ ├── CustomerDAO.java # Customer database operations with search filters
│ │ ├── OrderDAO.java # Order database operations with search filters
│ │ ├── OrderItemDAO.java # Order items database operations
│ │ ├── ProductDAO.java # Product database operations with search filters
│ │ ├── SessionDAO.java # Session database operations
│ │ └── TransactionDAO.java # Transaction database operations with search filters
│ ├── dto/
│ │ ├── AddressRequest.java # Address create/update DTO
│ │ ├── AdminLoginRequest.java # Admin login DTO
│ │ ├── AdminRegisterRequest.java # Admin registration DTO
│ │ ├── AdminSearchRequest.java # Admin search/filters DTO
│ │ ├── AdminUpdateRequest.java # Admin profile update DTO
│ │ ├── ApiResponse.java # Standard API response wrapper
│ │ ├── CartItemCreateRequest.java # Add to cart DTO
│ │ ├── CartItemUpdateRequest.java # Update cart quantity DTO
│ │ ├── CustomerLoginRequest.java # Customer login DTO
│ │ ├── CustomerRegisterRequest.java # Customer registration DTO
│ │ ├── CustomerSearchRequest.java # Customer search/filters DTO
│ │ ├── CustomerUpdateRequest.java # Customer profile update DTO
│ │ ├── DirectOrderRequest.java # Direct buy now order DTO
│ │ ├── OrderAddressUpdateRequest.java # Update order address DTO
│ │ ├── OrderRequest.java # Create order from cart DTO
│ │ ├── OrderResponse.java # Order details response with invoice
│ │ ├── OrderSearchRequest.java # Order search/filters DTO
│ │ ├── OrderStatusUpdateRequest.java # Order status update DTO
│ │ ├── PasswordChangeRequest.java # Password change DTO
│ │ ├── ProductCreateRequest.java # Product creation DTO
│ │ ├── ProductSearchRequest.java # Product search/filters DTO
│ │ ├── ProductUpdateRequest.java # Product update DTO
│ │ ├── TransactionActionRequest.java # Refund approve/reject DTO
│ │ └── TransactionSearchRequest.java # Transaction search/filters DTO
│ ├── filter/
│ │ ├── AdminAuthFilter.java # Authentication filter for admin endpoints
│ │ └── CustomerAuthFilter.java # Authentication filter for customer endpoints
│ ├── listener/
│ │ └── SessionCacheInitializer.java # Session cache initialization on app startup
│ ├── model/
│ │ ├── Address.java # Address entity with default flag
│ │ ├── Admin.java # Admin entity with permissions
│ │ ├── CartItem.java # Cart item entity with expiry
│ │ ├── Customer.java # Customer entity
│ │ ├── Order.java # Order entity with status and payment tracking
│ │ ├── OrderItem.java # Order item entity
│ │ ├── Product.java # Product entity with active status
│ │ ├── Session.java # Session entity with rolling expiry
│ │ └── Transaction.java # Transaction entity (payment & refund)
│ ├── service/
│ │ ├── AddressService.java # Address business logic
│ │ ├── AdminService.java # Admin business logic with search & stats
│ │ ├── CartService.java # Cart business logic
│ │ ├── CustomerService.java # Customer business logic with search & stats
│ │ ├── OrderService.java # Order business logic with search & stats
│ │ ├── PaymentGateway.java # Mock payment gateway
│ │ ├── ProductService.java # Product business logic with search & stats
│ │ └── TransactionService.java # Transaction business logic with search & stats
│ └── util/
│ ├── DBUtil.java # Database connection utility
│ ├── JsonUtil.java # JSON serialization/deserialization
│ ├── PasswordUtil.java # Password hashing & verification
│ ├── SessionCache.java # In-memory session cache with periodic persistence
│ └── SessionPersister.java # Background session persistence
├── WEB-INF/
│ ├── classes/ # Compiled .class files
│ └── web.xml # Servlet configuration
├── .gitignore
└── README.md
-
Initial Setup - build automation, database seeding, async executor, and JNDI connection pool
- Added
build/deploy.shfor deployment automation - Added
seed/init_db.sqlandseed/products.csvfor database initialization - Configured async executor with thread pool
- Set up database connection pool via JNDI
- Added
-
Customer Authentication - registration, login, session management, and profile operations
- Customer Registration - Create new customer account with hashed password
- Customer Login - Authenticate and create session with rolling 24-hour expiry
- Customer Logout - Invalidate session and clear cookie
- Session Management - Hybrid approach with in-memory cache + periodic DB persistence
- Profile Management - View and update customer profile (username, email, phone)
- Password Change - Change password with old password verification
- Account Deactivation - Soft delete (deactivate) customer account
- Session Cache - ConcurrentHashMap with background sync every 10 minutes
- Password Security - SHA-256 hashing with random salt
- JSON Utilities - Lightweight JSON parsing without external dependencies
- DTO Pattern - Clean separation between request/response and database entities
- Auth Filter - Protects all
/customer/*endpoints except login/register
-
Admin Authentication & Management - admin auth, role-based permissions, and customer management for admins
- Admin Login - Authenticate with superadmin seeded in database
- Admin Profile Management - View and update own profile
- Admin Password Change - Change password with old password verification
- Admin CRUD - List, get, create, update, and deactivate admins
- Role-Based Permissions - Array-based permission system (
admins:view,admins:create,admins:update,admins:delete,customers:viewcustomers:delete,products:view,products:create,products:update,products:delete,orders:view,orders:update,transactions:view,transactions:update) - Superadmin Protection - Superadmin cannot be deactivated or modified
- Customer Management - Admins can list, get, and deactivate customers
- Auth Filter - Protects all
/admin/*endpoints with separate filter - Soft Delete - Deactivation sets
is_active = falsefor admins, customers, and products
-
Product Catalog - product browsing, search, filtering, and admin management
- Product Browsing - Customers can search and view products with multi-field keyword search (name + location)
- Advanced Filtering - Filter by category, gender, age group, seasonality, price range, and stock availability
- Pagination & Sorting - Configurable page size and sorting options (price, name, creation date, etc.)
- Filter Options API - Dynamic filter options (categories, age groups, genders, locations) for UI dropdowns
- Product Management - Admins can create, update, view, and delete products
- Soft Delete - Deactivated products are hidden from customers but visible to admins
- Product Activation - Admins can reactivate previously deactivated products
- Active Status Filter - Admins can filter products by active/inactive status
- Consistent Ordering - Results sorted by
product_id DESCby default for deterministic pagination - Search Performance - Indexed on category, gender, age group, seasonality, location, and product name
-
Shopping Cart & Address Management - cart operations and address book for customers
- Cart Management - Add, update quantity, remove items, and clear cart
- Cart Expiration - Cart items automatically expire after 30 days
- Stock Status Display - Shows stock availability and warnings for low/out of stock items
- Quantity Limits - Maximum 50 items per product in cart
- Product Validation - Cannot add inactive or unavailable products to cart
- Address Management - Create, update, delete, and view shipping addresses
- Default Address - Each customer can have one default address, automatically managed
- Address Limits - Maximum 10 addresses per customer
- Address Validation - Required fields validation (recipient name, address line, city, postal code, country)
- Scheduled Cleanup - Background task removes expired cart items hourly
-
Order & Transaction Management - order creation, payment processing, and transaction tracking
- Order Creation - Create orders from cart or direct buy now with address selection (saved or one-time)
- Payment Processing - Mock payment gateway with transaction audit trail (INITIATED → COMPLETED/FAILED)
- Stock Management - Stock deducted at order creation, restored on cancellation or expiry
- Payment Deadline - 5-minute window for payment completion with automatic expiry cleanup
- Order Status Flow - PENDING → PROCESSING → SHIPPED → DELIVERED with validation rules
- Order Cancellation - Customer can cancel PROCESSING orders with automatic refund request
- Address Update - Customers can modify shipping address for PENDING/PROCESSING orders
- Admin Order Management - View all orders, update status (SHIPPED/DELIVERED) with permission checks
- Refund Management - Admin can approve or reject refund requests with transaction tracking
- Transaction History - Complete audit trail for payments and refunds with pagination and filters
- Invoice Generation - Auto-generated invoice numbers for each order
- Scheduled Cleanup - Background task cancels expired orders and restores stock every minute
- Status Validation - Enforced order and payment status transitions with proper error messages
- Filters & Pagination - Both orders and transactions support filtering by status, date, amount, and pagination
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/customer/register |
POST | Public | - | Create new customer account |
/customer/login |
POST | Public | - | Customer login and get session |
/customer/logout |
POST | Customer | Authenticated | Invalidate current session |
/admin/login |
POST | Public | - | Admin login and get session |
/admin/logout |
POST | Admin | Authenticated | Invalidate admin session |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/customer/profile |
GET, PATCH | Customer | Authenticated | Get or update profile |
/customer/password |
POST | Customer | Authenticated | Change password |
/customer/account |
DELETE | Customer | Authenticated | Deactivate own account |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/admin/profile |
GET, PATCH | Admin | Authenticated | Get or update own profile |
/admin/profile/password |
POST | Admin | Authenticated | Change own password |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/admin/admins |
GET, POST | Admin | admins:view \ create |
List all or create admin |
/admin/admins/{id} |
GET, PATCH, DELETE | Admin | admins:view \ update \ delete |
Get, update, or deactivate admin |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/admin/customers |
GET | Admin | customers:view |
List all customers |
/admin/customers/{id} |
GET, DELETE | Admin | customers:view \ delete |
Get or deactivate customer |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/products/search |
POST | Customer | Authenticated | Search products with filters |
/products/{id} |
GET | Customer | Authenticated | Get single product details |
/products/filter-options |
GET | Customer | Authenticated | Get available filter options for UI |
/admin/products/search |
POST | Admin | products:view |
Search products (active and inactive) |
/admin/products |
POST | Admin | products:create |
Create new product |
/admin/products/{id} |
GET, PATCH, DELETE | Admin | products:view \ update \ delete |
Get, update, or delete product |
/admin/products/{id}/activate |
PATCH | Admin | products:update |
Activate product (set active) |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/customer/cart |
GET, POST | Customer | Authenticated | Get cart items or add item to cart |
/customer/cart/{productId} |
PATCH, DELETE | Customer | Authenticated | Update quantity or remove from cart |
/customer/cart/clear |
POST | Customer | Authenticated | Clear entire cart |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/customer/addresses |
GET, POST | Customer | Authenticated | List all addresses or create new |
/customer/addresses/{id} |
GET, PATCH, DELETE | Customer | Authenticated | Get, update, or delete address |
/customer/addresses/default |
GET | Customer | Authenticated | Get default address |
/customer/addresses/{id}/default |
POST | Customer | Authenticated | Set address as default |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/customer/orders/cart |
POST | Customer | Authenticated | Create order from cart |
/customer/orders/direct |
POST | Customer | Authenticated | Create direct order (buy now) |
/customer/orders |
GET | Customer | Authenticated | List customer orders (paginated, filters) |
/customer/orders/{orderId} |
GET | Customer | Authenticated | Get order details with invoice |
/customer/orders/{orderId}/cancel |
POST | Customer | Authenticated | Cancel order (PROCESSING only) |
/customer/orders/{orderId}/address |
PATCH | Customer | Authenticated | Update shipping address |
/admin/orders |
GET | Admin | orders:view |
List all orders (paginated, filters) |
/admin/orders/{orderId} |
GET | Admin | orders:view |
Get order details |
/admin/orders/{orderId}/status |
PATCH | Admin | orders:update |
Update order status (SHIPPED/DELIVERED) |
| Endpoint | Method | Role | Permission | Description |
|---|---|---|---|---|
/customer/transactions |
GET | Customer | Authenticated | List customer transactions (paginated) |
/customer/transactions/{id} |
GET | Customer | Authenticated | Get transaction details |
/admin/transactions |
GET | Admin | transactions:view |
List all transactions (paginated, filters) |
/admin/transactions/{id} |
GET | Admin | transactions:view |
Get transaction details |
/admin/transactions/{id}/action |
POST | Admin | transactions:update |
Approve or reject refund request |
views/
├── index.html # Main landing page
├── styles.css # Global styles & theme variables
├── assets/
│ ├── favicon.svg # Custom JCart site favicon
│ └── image.svg # Default product placeholder image
├── shared/ # Reusable UI components
│ ├── navbar/ # Site navigation header with cart badge
│ ├── footer/ # Site footer component
│ ├── pagination/ # Reusable pagination component
│ ├── cart-modal/ # Shopping cart confirmation modal
│ └── admin-sidebar/ # Admin panel sidebar navigation with permissions
├── utils/ # Global utility functions
│ ├── auth.js # Authentication utilities & session management
│ └── toast.js # Toast notification system
└── features/ # Feature-specific pages
├── auth/
│ ├── customer/ # Customer authentication flows
│ │ ├── login/ # Customer login page
│ │ └── register/ # Customer registration page
│ └── admin/
│ └── login/ # Admin login page with credential validation
├── admin/ # Admin panel features
│ ├── dashboard/ # Admin dashboard with quick actions
│ ├── adminMt/ # Admin management (CRUD for admins)
│ ├── customerMt/ # Customer management for admins
│ ├── orderMt/ # Order management for admins
│ ├── productMt/ # Product management for admins
│ └── transactionMt/ # Transaction management for admins
├── products/customer/ # Product browsing & viewing
│ ├── search/ # Product search & listing page
│ └── detail/ # Individual product detail page
├── cart/ # Shopping cart management
├── orders/customer/ # Customer order management
│ ├── checkout/ # Order checkout page (cart & direct buy)
│ ├── list/ # Order history with filters & pagination
│ └── detail/ # Individual order details & invoice
├── transactions/customer/ # Customer transaction history
└── error/ # Error page handling
-
Customer Authentication, Home Page & Shared Components
- User registration and login with form validation
- Login Page - Secure authentication with error handling and loading states
- Registration Page - Account creation with password strength validation and terms popup
- Reusable UI components for consistent site-wide navigation and branding
- Navbar Component - Logo, navigation links, and user authentication status
- Footer Component - Company information and links with dynamic year update
- Main landing page with featured content and navigation
- Homepage Layout - Welcome section with easy access to key features
- Utility modules for authentication handling and toast notifications
-
Product Browsing, Shopping Cart & E-Commerce System
- Product Search & Filtering - Advanced search with category, price range, and availability filters
- Product Grid Display - Responsive grid layout with hover effects and pricing
- Product Detail Pages - Comprehensive product view with specifications and purchase options
- Shopping Cart Integration - One-click add to cart with quantity selection modal
- Cart Management - Full cart operations with real-time totals and quantity updates
- Cart Modal Component - Instant confirmation with product images and cart synchronization
- Pagination System - Reusable component supporting 15/30/45 items per page with URL state
- Real-time Cart Badge - Dynamic cart item count in navbar for authenticated users
- Error Handling Pages - Custom 404 and error pages with navigation options
-
Order & Transaction Management
- Checkout Page - Unified checkout for cart and direct buy with address selection
- Order History - Paginated list with filters (status, date range, sorting)
- Order Details - Complete order view with items, timeline, and invoice
- Order Cancellation - Cancel processing orders with automatic refund initiation
- Transaction History - Payment and refund tracking with status badges and detail modal
-
Session Caching, Admin Authentication, Dashboard & Admin Management
- Admin Login Page - Secure authentication with credential validation and loading states
- Session Management - In-memory session caching with periodic database persistence
- Admin Dashboard - Quick action cards for managing admins, customers, products, orders, and transactions
- Permission-based UI - Dashboard cards visible only for authorized admin roles
- Admin Sidebar Component - Consistent navigation across admin panel with permission-based menu items
- Admin Management Page (adminMt) - Full CRUD operations for administrator accounts
- Admin Search & Filters - Search by username/email/phone with role and status filters
- Admin Statistics - Real-time counts of active/inactive admins filtered by search criteria
- Permission Management - Granular module-level permissions (view, create, update, delete) with auto-selection dependencies
- Deactivate/Reactivate - Soft delete functionality for admin account management
- Sorting & Pagination - Sort by username, role, or status with 15/30/45 items per page
-
Product & Customer Management for Admins
- Customer Management Page (customerMt) - View-only customer listing with search and filters
- Customer Search & Filters - Search by username/email with active/inactive status filtering
- Customer Statistics - Real-time counts of active/inactive customers based on filtered data
- View Customer Details - Modal displaying customer information and account status
- Deactivate Customers - Soft delete functionality for customer accounts
- Product Management Page (productMt) - Full CRUD operations for product catalog
- Product Search & Filters - Advanced filtering by keyword, category, age group, gender, seasonality, price range, stock status
- Product Statistics - Dynamic counts showing active/inactive products and low stock items filtered by search criteria
- Stock Status Filtering - Filter by in-stock, out-of-stock, or low-stock products
- Create/Edit Product Modals - Comprehensive form with all product attributes and validation
- Stock Level Tracking - Real-time stock management with low-stock threshold (≤10 units)
- Deactivate/Reactivate Products - Soft delete for product catalog management
- Sorting & Pagination - Sort by name, category, price, or stock status with 15/30/45 items per page
-
Order & Transaction Management for Admins
- Order Management Page (orderMt) - Complete order oversight with search, filters, and status updates
- Order Search & Filters - Filter by order status, payment status, date range, and amount range
- Order Statistics - Real-time counts by status (pending, processing, shipped, delivered, cancelled) based on filtered data
- Order Status Updates - Update order status to shipped or delivered with permission checks
- Order Details View - Comprehensive order view with customer info, items, shipping address, and payment details
- Transaction Management Page (transactionMt) - Payment and refund tracking with search and filters
- Transaction Search & Filters - Filter by transaction type, payment status, payment method, and date range
- Transaction Statistics - Dynamic counts showing total transactions, payments, refunds, and pending refunds
- Refund Actions - Approve or reject refund requests with automatic status updates and transaction audit trail
- Transaction Details View - Complete transaction information including order reference, amount, method, and status timeline
- Sorting & Pagination - Sort by date, amount, or status with 15/30/45 items per page