You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Git, GitHub, VS Code, Postman, pgAdmin, Supabase Studio
Database Design
Entity-Relationship Diagram
Data Profile
Table
Rows
Role
sellers
~50
Vendor registry
customers
~500
Customer profiles + geographic segmentation
products
~200
Product catalog with COGS
categories
~30
Hierarchical classification (self-referencing)
orders
~5,000
Order headers (total_amount trigger-synced)
order_items
~15,000
Line items — central join table for all analytics
payments
~5,500
Payment records (supports fraud detection)
shipping
~4,800
Delivery tracking
returns
~1,200
Return records for risk analysis
inventory
~400
Per-product per-warehouse stock levels
warehouses
~10
Physical locations
Key Design Decisions
Decision
Rationale
COGS in products
Enables profit margin calculation without a separate cost table
Self-referencing categories
Tree hierarchy (e.g., Electronics → Phones → Smartphones) without extra tables
Denormalized total_amount
Persisted in orders, synced via AFTER trigger — avoids expensive real-time aggregation
Per-row min_stock_level
Allows per-product, per-warehouse stock thresholds — used by enforcement trigger
Separate payments table
Supports multiple attempts per order (FAILED → SUCCESS) for fraud detection
SQL Objects Summary
Phase
Type
Object
Key Concepts
2
VIEW
daily_sales_view, quantity_sold_by_*
Date aggregation, COUNT DISTINCT
2
FUNCTION
get_revenue_per_seller
Explicit cursor (OPEN/FETCH/CLOSE)
3
FUNCTION
get_monthly_revenue_per_year
Cursor, TO_CHAR
3
FUNCTION
get_average_order_value
PERCENTILE_CONT, CTE
3
FUNCTION
get_customer_lifetime_value
Customer segmentation, CONCAT
4
FUNCTION
get_inactive_sellers_analytics
generate_series, json_build_object, NOT IN
5
VIEW
product_returns_analytics
COUNT FILTER, LEFT JOIN
6
FUNCTION
get_product_profit_margin
Cursor, COGS math, guarded division
6
FUNCTION
get_revenue_decrease_ratio
Self-join CTE, dual-CTE pipeline
6
FUNCTION
get_yoy_revenue_growth
Multi-CTE (4+), scalar subquery
6
FUNCTION
get_monthly_revenue_drop_analysis
generate_series, FOR loop, severity classification
7
TRIGGER
trigger_update_order_total
AFTER INSERT/UPDATE/DELETE, COALESCE
7
TRIGGER
trg_inventory_enforce_stock_limit_on_sale
BEFORE INSERT, RAISE EXCEPTION, auto-deduct
8
FUNCTION
get_multiple_failed_payments
HAVING, dynamic interval
8
FUNCTION
get_high_return_customers
Dual HAVING, NULLIF
8
FUNCTION
get_low_stock_products
Per-row threshold comparison
8
FUNCTION
get_fast_moving_products
Velocity rating, dynamic interval
8
FUNCTION
get_inventory_intelligence_score
Multi-factor scoring, days-of-stock formula
8
FUNCTION
get_warehouse_load_intelligence
Conditional COUNT, capacity tiers
API Reference
Core Dashboards
Method
Endpoint
Description
GET
/api/daily-sales
Daily sales with year filter
GET
/api/quantity-sold
Quantity by type (product/year/category)
GET
/api/revenue-per-product
Product revenue ranking
GET
/api/revenue-per-seller
Seller revenue ranking
GET
/api/revenue-per-category
Category revenue distribution
Time & Customer
Method
Endpoint
Description
GET
/api/monthly-revenue
Monthly revenue per year
GET
/api/monthly-order-count
Monthly order volume
GET
/api/average-order-value
AOV with median (PERCENTILE_CONT)
GET
/api/customer-lifetime-value
CLTV with segmentation
Analytics & Intelligence
Method
Endpoint
Description
GET
/api/analytics/inactive-sellers
Inactive sellers in date range
GET
/api/analytics/returns
Returns analytics (3 time views)
GET
/api/profit-margin/product
Product profit margins
GET
/api/profit-margin/category
Category profit margins
GET
/api/yoy/revenue-decrease-ratio
YoY revenue ratio
GET
/api/yoy/revenue-growth
YoY growth analysis
GET
/api/fraud/failed-payments
Multiple failed payments
GET
/api/fraud/high-return-customers
High return-rate customers
GET
/api/revenue-drop/monthly
Monthly revenue drops
GET
/api/inventory/low-stock
Low stock products
GET
/api/inventory/fast-moving
Fast-moving products
GET
/api/inventory/warehouse-load
Warehouse load metrics
GET
/api/inventory/intelligence-score
Inventory risk scoring
Data Management (CRUD)
Method
Endpoint
Description
GET
/api/data/:table
Read records (paginated)
POST
/api/data/:table
Create record
PUT
/api/data/:table/:id
Update record
DELETE
/api/data/:table/:id
Delete record
Application Pages
Page
Route
Description
Landing
/
Entry point
Overview
/dashboard/overview
KPI summary cards
Analytics
/dashboard/analytics
Multi-phase analytics hub
Data Management
/dashboard/data-management
CRUD interface for all 11 entities
Inactive Sellers
/dashboard/analytics/inactive-sellers-page
Seller activity analysis
Returns
/dashboard/returns
Returns & loss analysis
Integrity
/dashboard/integrity
Data integrity & fraud dashboards
Known Limitations
Limitation
Detail
Hardcoded reference date
Phase 8 functions use DATE '2025-12-31' instead of CURRENT_DATE (static dataset)
No authentication
No RBAC or auth layer — all endpoints are public
Client-side aggregation
Returns view aggregation done in JS for multi-view flexibility
No real-time updates
Dashboards fetch on mount only — no WebSocket/polling
No server-side pagination
Some dashboards load full result sets
Single inventory record
Stock trigger uses WHERE product_id = ... without warehouse qualifier
License
This project was developed as a course project for CSE 4532 — Database Management Systems Lab.
Built with PostgreSQL · Node.js · React · Recharts
About
A PostgreSQL-based e-commerce database system implementing complex business workflows, multiple payment methods, inventory management, and advanced RDBMS features .