Thanks to visit codestin.com
Credit goes to github.com

Skip to content

re-trade/rt-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ Retrade Client Applications

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.

πŸ“‹ Table of Contents

πŸ—οΈ Architecture Overview

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        β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Applications

πŸ›οΈ Customer Application (@retrade/rt-client-customer)

  • 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

πŸͺ Seller Dashboard (@retrade/rt-client-seller)

  • 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

πŸ› οΈ Admin Dashboard (@retrade/rt-client-admin)

  • 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

πŸ› οΈ Tech Stack

Core Technologies

UI Components & Design System

State Management & Data Fetching

  • 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

Development & Build Tools

Specialized Libraries

πŸ“¦ Project Structure

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

⚑ Quick Start

Prerequisites

  • Node.js: >= 18.0.0
  • Yarn: >= 1.22.22
  • Docker: >= 20.0.0 (for containerized deployment)
  • Git: Latest version

Installation

# Clone the repository
git clone <repository-url>
cd retrade-client

# Install dependencies for all workspaces
yarn install

# Build shared packages
yarn build

Development

# 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:

Production Build

# 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

🐳 Docker Deployment

Local Development

# 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

Production Deployment

# 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)

πŸ”§ Configuration

Each application uses environment variables for configuration. Create .env.local files in each app directory:

Customer App (.env.local)

API_BASE_URL=https://api.retrade.local
SOCKET_URL=wss://socket.retrade.local
NEXT_PUBLIC_APP_ENV=development

Seller App (.env.local)

API_BASE_URL=https://api.retrade.local
SOCKET_URL=wss://socket.retrade.local
NEXT_PUBLIC_APP_ENV=development

Admin App (.env.local)

API_BASE_URL=https://api.retrade.local
SOCKET_URL=wss://socket.retrade.local
NEXT_PUBLIC_APP_ENV=development

πŸ“š Development Guidelines

Code Style & Standards

  • 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

Component Development

  • 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

API Integration

  • 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

State Management

  • 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

πŸ§ͺ Testing & Quality

# 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

Quality Assurance

  • 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

πŸ“ˆ Performance

Optimization Strategies

  • 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

Performance Monitoring

  • Built-in Next.js analytics and performance metrics
  • Custom performance tracking for critical user journeys
  • Bundle analyzer integration for bundle size monitoring

πŸ”’ Security

Security Measures

  • 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

Data Protection

  • Sensitive data encryption in transit and at rest
  • Proper session management and token handling
  • GDPR-compliant data handling practices

πŸš€ CI/CD Pipeline

GitHub Actions Workflows

Main Pipeline (main.yaml)

  • Triggers on push to main branch
  • Builds Docker images for all applications
  • Deploys to both staging and production environments

Build Process (build-image.yaml)

  • Matrix strategy for parallel builds (customer, seller, admin)
  • Separate builds for development and production environments
  • Pushes images to GitHub Container Registry (GHCR)

Deployment (deploy-dev.yaml)

  • Automated deployment to development and production servers
  • Docker Compose orchestration with proper profiles
  • Automatic cleanup of old images and containers

Deployment Environments

  • Development: Continuous deployment from main branch
  • Staging: Pre-production testing environment
  • Production: Stable production environment with manual approval

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following the coding standards
  4. Run tests and linting (yarn lint && yarn type-check)
  5. Commit your changes (git commit -m 'Add some amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request with detailed description

Pull Request Guidelines

  • 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

πŸ“„ License

This project is proprietary and confidential. All rights reserved by Retrade Platform.

About

This is a web application ui of retrade written by next js and ts with love

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages