
Backend API · Personal Project
H-Phsar — B2B Marketplace API
- Spring Boot 3
- Java 17
- MyBatis
- PostgreSQL
- Spring Security
- WebSocket
Project Summary
Problem
Wholesale trade between distributors and retailers still runs on phone calls and paper: orders get lost, prices stay opaque, and neither side has a record of what was agreed. H-Phsar (ផ្សារ — 'market' in Khmer) digitizes that relationship into one platform both sides can trust.
Approach
H-Phsar digitizes wholesale ordering between Cambodian distributors and retailers. Each role gets a focused API for store management, purchasing, fulfillment, reporting, and notifications.
What I Built
- Email OTP verification and JWT-secured sessions
- Distributor catalog, inventory, and store management
- Retailer carts, ordering, tracking, ratings, and bookmarks
- Explicit order transitions with real-time WebSocket notifications
Implementation
Spring Boot 3.2 and Java 17 with MyBatis, PostgreSQL, Flyway, Spring Security, WebSocket, and OpenAPI. Role-scoped controllers and queries keep distributor and retailer workflows separate.
architecture
Backend Evidence
Core data
Key endpoints
- POST
/authorizationSign up, log in, and password reset flows
- POST
/authorization/api/v1/otpGenerate and email a 4-digit OTP to verify an account
- POST
/api/v1/retailer/ordersAdd to cart, save drafts, and confirm a cart as a live order
- GET
/api/v1/distributor/reportsOrder activity reports by month and year
Engineering Decisions
Challenge
Modeling two user roles without duplicating marketplace logic
Decision
Separated role-specific APIs over one shared relational model
Challenge
Preventing invalid or out-of-order order status changes
Decision
Enforced every order transition through an explicit state machine
Takeaways
- An explicit state machine turns business rules into something you can read, test, and audit
- Designing the API per role keeps permissions simple — the URL already says who may call it
AuthHub — Reusable Authentication Service