Σ
λ
[]

GlobalScart

Production-style FastAPI commerce backend featuring JWT authentication, inventory reservation, transactional checkout, payment state management, and PostgreSQL analytics.

FastAPIREST APIPostgreSQLRazorpayJWT & RBACAnalytics
SYSTEM METRICS & ABSTRACTION LAYERS
Backend Layer
FastAPI Router
Authentication
JWT + RBAC Security
Database
PostgreSQL Schemas
Deployment
Docker Containerized
CI/CD Pipeline
Render Webhooks
01 / Challenge

Identifying the technical gap

Many educational e-commerce applications simplify transaction handling, inventory consistency, and payment workflows. GlobalScart was built to explore the backend coordination these workflows require.

GlobalScart focuses on data integrity, API-driven architecture, and payment flow design.

02 / Goals

Project Objectives

01

Design a scalable e-commerce backend architecture

02

Implement secure user authentication with OTP verification

03

Handle cart-to-order state transitions with data integrity

04

Integrate Razorpay payment workflows for order creation and payment-state management

05

Maintain clean frontend–backend separation

06

Build comprehensive admin analytics and monitoring

03 / Architecture

System Design

Client BrowserFastAPI AppCommerce ServicesPostgreSQLRazorpay APIAnalytics Layer

Browser Client

  • Static shop and admin interfaces
  • REST API consumption
  • Client-side form validation
  • Bearer-token requests

FastAPI Application

  • Customer and admin routers
  • JWT authentication and RBAC
  • Validation and domain orchestration
  • Request logging and error handling

Commerce Services

  • Cart and checkout workflows
  • Inventory reservation lifecycle
  • Order and payment transitions
  • Cancellation and stock release

PostgreSQL

  • Customer and product dimensions
  • Order, item, and payment facts
  • Inventory reservations
  • Audit and funnel events

Razorpay Boundary

  • Provider order creation
  • Signature confirmation
  • Webhook endpoint
  • Test-mode public integration

Analytics Layer

  • KPI snapshots: Revenue, Average Order Value, Order Conversion Rate, Customer Retention, Repeat Purchase %
  • Revenue and conversion funnel analysis
  • Customer journey event logging
  • Protected admin endpoints and KPI reporting
04 / Pipeline

Data Flow Steps

01

User Authentication

User registers/logs in → OTP verification → JWT token issued

02

Product Discovery

Product data fetched via REST APIs with filtering and search

03

Cart Management

Cart persisted through backend APIs with client-side state synchronization.

04

Checkout Initiation

Checkout triggers order creation with address validation

05

Payment Processing

Razorpay payment intent generated for transaction

06

Order Completion

Order status updated based on payment response

Browser → FastAPI routers → JWT/RBAC → Commerce services → PostgreSQL → Analytics APIs
05 / Database Schema

PostgreSQL Database Dimensions and Facts

Customer, product, and payment lifecycles map to clean transactional and analytical tables.

Table NameDetailRelation
dim_customerCustomer identity and geography1 → many orders
dim_productCatalog, category, price, and cost1 → many order items
fact_ordersOrder totals, status, and customerparent of items and payments
fact_order_itemsQuantity, price, tax, and revenuejoins orders to products
fact_paymentsProvider, amount, and payment statemany payments → one order
order_inventory_reservationsReserved, consumed, or released stockorder + product lifecycle
dim_customer → fact_orders → fact_order_items ← dim_product
fact_orders → fact_payments · fact_orders → order_inventory_reservations ← dim_product
06 / Endpoints

API Design

Representative endpoints verified against the FastAPI routers

MethodEndpointResponsibility
POST/api/auth/loginAuthenticate a customer and begin the OTP/JWT flow
GET/api/customer/productsBrowse and filter the product catalog
PUT/api/customer/cartSynchronize customer cart quantities
POST/api/customer/checkout/startValidate checkout, create an order, and reserve inventory
POST/api/customer/orders/{order_id}/simulate-paymentConfirm or cancel an order based on payment simulation
POST/api/payments/razorpay/confirmVerify payment confirmation and finalize order state
GET/api/admin/kpis/latestReturn protected operational KPI data
07 / States

Checkout State Machine

Order, payment, and inventory transitions

Razorpay is integrated in test mode to demonstrate payment intent creation, transaction handling, and checkout flow.

Intentional Limitation: Live payment execution and webhook-based verification were intentionally not enabled due to deployment and KYC constraints. This mirrors real-world staging environments used before production rollout.
// Successful path
ORDER_CREATED + PAYMENT_PENDING + RESERVED
↓ confirm payment and consume reservation
ORDER_CONFIRMED + PAYMENT_SUCCESS + CONSUMED
// Failed payment path
ORDER_CANCELLED + PAYMENT_FAILED + RELEASED
08 / Rationale

Key Decisions

REST APIs for frontend independence

Decoupled architecture allows independent frontend/backend development and future mobile app integration

Stateless backend for scalability

JWT-based authentication enables horizontal scaling without session storage dependencies

Razorpay over dummy payments

Payment gateway integration demonstrates external-service handling and checkout state transitions

Modular service architecture

Clean separation of routers, services, and database layers improves maintainability and future scalability.

09 / Screenshots

Visual Showcase

Welcome Screen
fig.01 — Authenticated user welcome stateAUTH
Signup Form
fig.02 — User registration with password validationAUTH
Login OTP
fig.03 — OTP-based authentication flowAUTH
Product Listing
fig.04 — Product catalog with filteringSHOP
Wishlist
fig.05 — Saved items wishlist viewSHOP
Shopping Cart
fig.06 — Cart state with quantity managementCART
Checkout Form
fig.07 — Checkout with payment & addressCHECKOUT
Checkout Summary
fig.08 — Order summary with promo codeCHECKOUT
Orders List
fig.09 — Order history with status trackingORDERS
Inbox Notifications
fig.10 — Order confirmation notificationsORDERS
Admin Login
fig.11 — Admin dashboard authenticationADMIN
Admin Dashboard
fig.12 — KPI metrics and order monitoringADMIN
Analytics Dashboard
fig.13 — Revenue trends and conversion funnelANALYTICS
Audit Log
fig.14 — System audit trail for order changesADMIN
Journey Replay
fig.15 — Customer session timeline analysisANALYTICS
10 / Decisions

Real Engineering Decisions

01

Inventory Consistency

Problem

Concurrent purchases could oversell stock.

Solution

PostgreSQL transactions with row-level locking.

Result

Inventory remained consistent during checkout.

02

Request Validation

Problem

Malformed payloads caused checkout failures.

Solution

Pydantic request validation.

Result

Consistent API contracts and cleaner error handling.

03

Authentication

Problem

Protecting customer and admin endpoints.

Solution

JWT-based authentication and RBAC.

Result

Role-specific access control.

11 / Limits & Takeaways

Boundaries & Learnings

Limitations

  • Public Render deployment is a portfolio demo without a production SLA
  • Razorpay live credentials and payment execution are disabled in the public demo
  • Demo OTP implementation used for portfolio demonstration. Production SMS/email delivery was intentionally excluded.
  • No automated email notifications implemented
  • UI not optimized for animations or advanced interactions
  • Mobile responsiveness limited to core workflows

Key Learnings

  • End-to-end transaction flow design from cart to order completion
  • Payment gateway integration challenges including webhook handling
  • API contract discipline and version management
  • Debugging async frontend-backend communication issues
  • Handling partial system completeness in demo environments
  • Building admin observability tools for business metrics