A complete e-commerce trading platform with microservices architecture and frontend Monorepo, now upgraded to Platform v4.0 with SPI extension framework.
- Language: Golang 1.21+
- Web Framework: Hertz
- ORM: GORM
- Database: SQLite
- Authentication: JWT
- Architecture: Microservices + SPI Extension Framework
- Framework: React 18
- UI Component Library: Ant Design 5
- Routing: React Router v6
- HTTP Client: Axios
- Build Tool: Vite
- Language: TypeScript
- Package Manager: pnpm
- Architecture: Monorepo
trae_using_demo/
├── domain-services/
│ ├── api-gateway/ # API Gateway (Port 8080)
│ │ ├── cmd/server/
│ │ ├── internal/proxy/
│ │ └── go.mod
│ ├── common/ # Common packages
│ │ └── go/pkg/
│ │ ├── identity/ # Business Identity abstraction
│ │ ├── spi/ # SPI Extension Framework
│ │ ├── response/
│ │ └── utils/
│ ├── platform/ # Platform Core Services (v4.0)
│ │ ├── user-service/ # Port 9081 (planned)
│ │ ├── product-service/ # Port 9082 (planned)
│ │ └── trade-service/ # Port 9083 (planned)
│ └── extensions/ # Business Extensions
│ ├── id-market/ # Indonesia Market
│ ├── us-market/ # US Market
│ ├── pre-sale/ # Pre-Sale Feature
│ └── auction/ # Live Auction Feature
├── frontend/ # Frontend Monorepo
│ ├── apps/web/ # Main Web App
│ ├── packages/
│ │ ├── ui/ # Shared UI Components
│ │ ├── user/ # User Domain
│ │ ├── product/ # Product Domain
│ │ ├── trade/ # Trade Domain
│ │ └── auction/ # Auction Domain
│ └── pnpm-workspace.yaml
├── .trae/
│ ├── documents/ # Architecture plans
│ └── specs/ # Specifications
└── README.md
{Country}.{Mode}
Examples:
CN.normal - China Normal Trading
ID.normal - Indonesia Normal Trading
US.normal - US Normal Trading
CN.preSale - China Pre-Sale
CN.auction - China Live Auction
- ProductExtension: Product type extension, price calculation
- TradeExtension: Order creation, payment processing
- I18nExtension: Multi-language, currency formatting
- PaymentExtension: Payment gateway integration
common/go/pkg/
├── identity/ # Business Identity
│ ├── identity.go # BusinessIdentity struct
│ └── resolver.go # Identity resolver
└── spi/
├── extension.go # Extension point interfaces
├── registry.go # Extension registry
├── loader.go # Extension loader
└── usage_demo.go # Complete usage example
- User registration & login
- JWT Token authentication (24-hour validity)
- Password bcrypt encryption
- Merchant registration & editing
- Merchant list & detail view
- Product publishing & editing
- Product list & details
- Inventory management
- Multi-currency support (via SPI)
- Add/modify/delete cart items
- Cart list view
- Create orders
- Order list & details
- Order status management
- Automatic inventory deduction
- ID Market: Bahasa Indonesia, IDR currency, Midtrans/Doku payment
- US Market: English (US), USD currency, Stripe/PayPal payment, Sales Tax
- Pre-Sale: Deposit + balance payment mode
- Live Auction: Real-time bidding, WebSocket support
cd domain-services/api-gateway
go run cmd/server/main.goAPI Gateway starts at http://localhost:8080
# User Service (Port 8081)
cd domain-services/user-service
go run cmd/server/main.go
# Product Service (Port 8082)
cd domain-services/product-service
go run cmd/server/main.go
# Trade Service (Port 8083)
cd domain-services/trade-service
go run cmd/server/main.go
# Auction Service (Port 8084)
cd domain-services/auction-service
go run cmd/server/main.gocd frontend
pnpm install
pnpm devFrontend dev server starts at http://localhost:5173
import (
"ecommerce/common/pkg/identity"
"ecommerce/common/pkg/spi"
)
// 1. Initialize SPI
registry := spi.NewExtensionRegistry()
loader := spi.NewExtensionLoader(registry)
// 2. Load extensions
loader.LoadExtensions(
id_market.InitIDMarket,
us_market.InitUSMarket,
pre_sale.InitPreSale,
auction.InitAuction,
)
// 3. Use extension for specific business identity
id := identity.NewBusinessIdentity(identity.CountryCN, identity.ModePreSale)
if productExt, ok := loader.GetProductExtension(id); ok {
price, _ := productExt.CalculatePrice(ctx, product, id)
}POST /api/auth/register- User registrationPOST /api/auth/login- User login
GET /api/products- Get product listGET /api/products/:id- Get product details
POST /api/merchants- Create merchantGET /api/merchants- Get merchant listGET /api/merchants/:id- Get merchant detailsPUT /api/merchants/:id- Update merchant
POST /api/products- Create productPUT /api/products/:id- Update productDELETE /api/products/:id- Delete product
POST /api/cart- Add to cartGET /api/cart- Get cartPUT /api/cart/:id- Update cart itemDELETE /api/cart/:id- Delete cart item
POST /api/orders- Create orderGET /api/orders- Get order listGET /api/orders/:id- Get order detailsPUT /api/orders/:id/status- Update order status
GET /api/auctions- Get auction listGET /api/auctions/:id- Get auction detailsPOST /api/auctions- Create auctionPOST /api/auctions/:id/bid- Place bidWebSocket /api/ws/auctions/:id- Real-time bidding
- users: User accounts
- merchants: Merchant profiles
- products: Product information
- product_prices: Multi-currency prices
- carts: Shopping cart
- orders: Orders
- order_items: Order items
- auctions: Auction information
- bids: Bid records
- Legacy services continue on ports 8081-8084
- New platform services planned for ports 9081-9083
- SPI extensions enable business feature isolation
- Smooth migration with backward compatibility
- Implement extension point interface
- Provide
Init*()registration function - Register extension with business identity
- Load extension in platform service
MIT License