Welcome to the Retrade client applications repository! This monorepo contains all frontend applications for the Retrade e-commerce platform, built with modern web technologies and designed for scalability and performance.
- π Retrade Client Applications
- π Table of Contents
- ποΈ Architecture Overview
- π Applications
- π οΈ Tech Stack
- π¦ Project Structure
- β‘ Quick Start
- π³ Docker Deployment
- π§ Configuration
- π Development Guidelines
- π§ͺ Testing & Quality
- π Performance
- π Security
- π CI/CD Pipeline
- π€ Contributing
- π License
Retrade is a comprehensive e-commerce platform built with a microservices architecture. This repository contains three specialized frontend applications that interact with backend services through RESTful APIs, real-time WebSocket connections, and STOMP messaging.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Customer App β β Seller App β β Admin App β
β (Next.js 15) β β (Next.js 15) β β (Next.js 15) β
β Port: 3001 β β Port: 3002 β β Port: 3000 β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β Backend APIs β
β (Microservices)β
β + WebSocket β
β + STOMP β
βββββββββββββββββββ
- Port: 3001 (development)
- Purpose: Main e-commerce storefront for customers
- Key Features:
- π Product browsing and search
- ποΈ Shopping cart with real-time updates
- π³ Secure checkout and payment processing
- π€ User account management and profiles
- π¦ Order tracking and history
- π¬ Real-time chat with sellers
- π± Responsive mobile-first design
- π Real-time notifications
- π° Digital wallet integration
- β Product reviews and ratings
- π Address management
- π― Personalized recommendations
- Port: 3002 (development)
- Purpose: Comprehensive seller management portal
- Key Features:
- π Advanced analytics and reporting
- π¦ Product catalog management
- π Order processing and fulfillment
- π° Revenue tracking and financial reports
- π Sales performance metrics
- π¬ Customer communication tools
- π Shipping and logistics management
- π« Voucher and promotion management
- π± Mobile-responsive interface
- π Real-time order notifications
- π₯ Customer relationship management
- π Interactive charts and dashboards
- Port: 3000 (development)
- Purpose: Platform administration and management
- Key Features:
- π₯ User and seller management
- π’ Brand and category administration
- π Platform-wide analytics
- π° Financial oversight and platform fees
- π¨ Alert and monitoring systems
- π Report management
- βοΈ System configuration
- π Security and access control
- π Revenue and growth tracking
- π« Voucher system management
- πΈ Withdrawal request processing
- Framework: Next.js 15 with App Router & Turbopack
- Language: TypeScript 5.5+ (Strict mode)
- Styling: Tailwind CSS 4.1+ with DaisyUI
- Build Tool: Turbo 2.5+ (Monorepo management)
- Package Manager: Yarn 1.22+ with Workspaces
- Runtime: Node.js 18+
- Component Library: Radix UI (Accessible primitives)
- Icons: Lucide React, Heroicons, Tabler Icons
- Charts: Recharts 3.1+ (Admin), Recharts 2.15+ (Seller)
- Animations: Framer Motion 12+
- Notifications: Sonner
- Styling Utils: clsx, tailwind-merge
- HTTP Client: Axios 1.7+ with custom interceptors
- State Management:
- React Context API (Customer, Seller)
- Redux Toolkit 2.5+ (Admin)
- Real-time Communication:
- STOMP.js 7.1+ over WebSocket
- Socket.io Client 4.8+ (Utility package)
- Form Handling: Custom hooks with Joi validation
- Linting: ESLint 9+ with Next.js config
- Formatting: Prettier 3.5+ with plugins
- Git Hooks: Husky 9.1+
- Type Checking: TypeScript strict mode with custom configs
- Device Fingerprinting: FingerprintJS 4.6+
- File Processing: XLSX (Admin)
- Markdown: React Markdown with GFM
- Date Handling: date-fns 4.1+ (Customer)
- Color Processing: ColorThief 2.6+ (Customer)
- WebRTC: Custom WebRTC configuration for video calls
retrade-client/
βββ apps/
β βββ customer/ # Customer-facing e-commerce app
β β βββ app/ # Next.js App Router pages
β β βββ components/ # React components
β β βββ context/ # React Context providers
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API service layer
β β βββ utils/ # Utility functions
β βββ seller/ # Seller dashboard application
β β βββ app/ # Next.js App Router pages
β β βββ components/ # React components
β β βββ context/ # React Context providers
β β βββ hooks/ # Custom React hooks
β β βββ service/ # API service layer
β β βββ utils/ # Utility functions
β βββ admin/ # Admin dashboard application
β βββ app/ # Next.js App Router pages
β βββ components/ # React components
β βββ hooks/ # Custom React hooks
β βββ services/ # API service layer
β βββ lib/ # Utility functions
βββ packages/
β βββ components/ # Shared UI components
β βββ util/ # Shared utilities and APIs
β β βββ src/api/ # HTTP client configuration
β β βββ src/socket/ # WebSocket/STOMP configuration
β β βββ src/webrtc/ # WebRTC configuration
β β βββ src/file/ # File handling utilities
β βββ typescript-config/ # Shared TypeScript configurations
βββ .docker/ # Docker configurations
β βββ compose.yaml # Production deployment
β βββ compose.local.yaml # Local development
β βββ compose.build.yaml # Build configuration
βββ .github/ # GitHub Actions workflows
β βββ workflows/
β βββ main.yaml # Main deployment pipeline
β βββ deploy-dev.yaml # Development deployment
β βββ build-image.yaml # Docker image building
βββ .husky/ # Git hooks configuration
- Node.js: >= 18.0.0
- Yarn: >= 1.22.22
- Docker: >= 20.0.0 (for containerized deployment)
- Git: Latest version
# Clone the repository
git clone <repository-url>
cd retrade-client
# Install dependencies for all workspaces
yarn install
# Build shared packages
yarn build
# Start all applications in development mode with Turbopack
yarn dev
# Start specific application
yarn workspace @retrade/rt-client-customer dev
yarn workspace @retrade/rt-client-seller dev
yarn workspace @retrade/rt-client-admin dev
# Run with specific port (if needed)
yarn workspace @retrade/rt-client-customer dev -- --port 3001
Application URLs:
- Customer App: http://localhost:3001
- Seller Dashboard: http://localhost:3002
- Admin Dashboard: http://localhost:3000
# Build all applications
yarn build
# Build specific application
yarn workspace @retrade/rt-client-customer build
# Start production server
yarn workspace @retrade/rt-client-customer start
# Start all services locally with development profile
docker compose -f .docker/compose.local.yaml --profile dev up -d
# Start specific service
docker compose -f .docker/compose.local.yaml --profile customer up -d
docker compose -f .docker/compose.local.yaml --profile seller up -d
docker compose -f .docker/compose.local.yaml --profile admin up -d
# View logs
docker compose -f .docker/compose.local.yaml logs -f
# Deploy to staging environment
docker compose -f .docker/compose.yaml --profile stag up -d
# Deploy to production environment
docker compose -f .docker/compose.yaml --profile prod up -d
# Deploy specific service to production
docker compose -f .docker/compose.yaml --profile customer up -d
Production URLs:
- Customer:
https://retrade.local
(prod) /https://dev.retrade.local
(staging) - Seller:
https://seller.retrade.local
(prod) /https://seller-dev.retrade.local
(staging) - Admin:
https://admin.retrade.local
(prod) /https://admin-dev.retrade.local
(staging)
Each application uses environment variables for configuration. Create .env.local
files in each app directory:
API_BASE_URL=https://api.retrade.local
SOCKET_URL=wss://socket.retrade.local
NEXT_PUBLIC_APP_ENV=development
API_BASE_URL=https://api.retrade.local
SOCKET_URL=wss://socket.retrade.local
NEXT_PUBLIC_APP_ENV=development
API_BASE_URL=https://api.retrade.local
SOCKET_URL=wss://socket.retrade.local
NEXT_PUBLIC_APP_ENV=development
- Follow TypeScript strict mode with proper type definitions
- Use functional components with React hooks
- Implement proper error boundaries for robust error handling
- Follow the established folder structure and naming conventions
- Use ESLint and Prettier for consistent code formatting
- Use Radix UI primitives for accessible, unstyled components
- Implement responsive design with Tailwind CSS mobile-first approach
- Create reusable components in the shared packages when applicable
- Follow the compound component pattern for complex UI elements
- Use proper TypeScript interfaces for component props
- Use the shared API utilities from
@retrade/util
package - Implement comprehensive error handling with user-friendly messages
- Use TypeScript interfaces for all API request/response types
- Handle loading, success, and error states consistently across components
- Implement proper caching strategies for frequently accessed data
- Use React Context for application-wide state in Customer and Seller apps
- Use Redux Toolkit for complex state management in Admin app
- Implement proper state normalization for complex data structures
- Use custom hooks to encapsulate state logic and side effects
# Run linting across all workspaces
yarn lint
# Format code with Prettier
yarn format
# Type checking
yarn type-check
# Run specific linting
yarn workspace @retrade/rt-client-customer lint
- ESLint: Configured with Next.js and TypeScript rules
- Prettier: Automated code formatting with custom configuration
- Husky: Pre-commit hooks for code quality enforcement
- TypeScript: Strict mode enabled for type safety
- Bundle Optimization: Next.js automatic code splitting and tree shaking
- Image Optimization: Next.js Image component with remote pattern support
- Lazy Loading: Component-level code splitting with dynamic imports
- Caching: Proper HTTP caching headers and Next.js built-in caching
- Turbopack: Fast bundler for development with hot module replacement
- Built-in Next.js analytics and performance metrics
- Custom performance tracking for critical user journeys
- Bundle analyzer integration for bundle size monitoring
- Authentication: JWT-based authentication with refresh tokens
- Authorization: Role-based access control (RBAC)
- HTTPS: Enforced in production with proper SSL/TLS configuration
- Input Validation: Client and server-side validation with Joi schemas
- XSS Protection: Sanitized user inputs and CSP headers
- Device Fingerprinting: FingerprintJS for enhanced security
- Secure Headers: Comprehensive security headers configuration
- Sensitive data encryption in transit and at rest
- Proper session management and token handling
- GDPR-compliant data handling practices
- Triggers on push to
main
branch - Builds Docker images for all applications
- Deploys to both staging and production environments
- Matrix strategy for parallel builds (customer, seller, admin)
- Separate builds for development and production environments
- Pushes images to GitHub Container Registry (GHCR)
- Automated deployment to development and production servers
- Docker Compose orchestration with proper profiles
- Automatic cleanup of old images and containers
- Development: Continuous deployment from
main
branch - Staging: Pre-production testing environment
- Production: Stable production environment with manual approval
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes following the coding standards
- Run tests and linting (
yarn lint && yarn type-check
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request with detailed description
- Provide clear description of changes
- Include screenshots for UI changes
- Ensure all checks pass (linting, type checking)
- Update documentation if necessary
- Request review from relevant team members
This project is proprietary and confidential. All rights reserved by Retrade Platform.