π This is a fork of uppadhyayraj/my-basket-app with Windows compatibility improvements!
A modern, scalable retail application built with Next.js frontend and Node.js microservices architecture. This application has been transformed from a monolithic structure into a distributed microservices system.
This fork adds:
- πͺ Windows Command Prompt compatibility - All scripts work natively on Windows
- π¨ UTF-8 emoji support - Proper emoji display in Windows terminals
- π Enhanced documentation - Complete setup instructions for both platforms
- π Cross-platform npm scripts - OS-specific variants for seamless development
- π₯ Production-grade health monitoring - Advanced liveness/readiness probes and resource monitoring
- π§ͺ Automated API Testing - Comprehensive Playwright test suite for service reliability
The application consists of the following microservices:
- Next.js Application (Port 9002) - React-based frontend with server-side rendering
- API Gateway (Port 3000) - Central entry point, routing, rate limiting, and load balancing
- Product Service (Port 3001) - Product catalog management
- Cart Service (Port 3002) - Shopping cart operations (includes advanced health monitoring)
- Order Service (Port 3003) - Order processing and management
- AI Service (Port 3004) - AI-powered recommendations and suggestions
-
Install dependencies for all services:
npm install npm run microservices:install
-
Start all microservices:
npm run microservices:start
-
Start the frontend (in a new terminal):
npm run dev
-
Verify everything is running:
npm run microservices:health
The application will be available at:
- Frontend: http://localhost:9002
- API Gateway: http://localhost:3000
- Individual service health checks: http://localhost:300X/api/health
- Cart Service Liveness: http://localhost:3002/api/health/live
- Cart Service Readiness: http://localhost:3002/api/health/ready
-
Build and start all services:
npm run docker:build npm run docker:up
-
View logs:
npm run docker:logs
-
Stop all services:
npm run docker:down
npm run dev- Start Next.js frontend in development modenpm run dev:full- Start microservices and frontend togethernpm run build- Build the Next.js applicationnpm run start- Start the Next.js application in production mode
npm run microservices:install- Install dependencies for all microservicesnpm run microservices:start- Start all microservices in development modenpm run microservices:stop- Stop all running microservicesnpm run microservices:health- Check health of all microservices
For Windows users, OS-specific scripts are available:
npm run microservices:start:win- Start microservices using Windows batch filesnpm run microservices:stop:win- Stop microservices using Windows batch filesnpm run microservices:health:win- Health check using Windows batch files
Note: Windows batch files include UTF-8 encoding (chcp 65001) for proper emoji display in Command Prompt.
npm run docker:build- Build all Docker imagesnpm run docker:up- Start all services with Docker Composenpm run docker:down- Stop and remove all Docker containersnpm run docker:logs- View logs from all services
npm run lint- Run ESLintnpm run typecheck- Run TypeScript type checkingnpm run test:api- Run comprehensive Playwright API testsnpm run test:report- Generate HTML test reports for API tests
- 01 - Health Check QA Review
- 02 - Implementation Plan v1
- 03 - Health Check Implementation
- 04 - Consolidated API Testing Framework
Endpoints:
GET /health- Overall system health checkGET /info- Gateway and service information/api/products/*- Proxy to Product Service/api/cart/*- Proxy to Cart Service/api/orders/*- Proxy to Order Service/api/recommendations/*- Proxy to AI Service
Endpoints:
GET /api/products- List products with filtering and paginationGET /api/products/:id- Get specific productPOST /api/products- Create new productPUT /api/products/:id- Update productDELETE /api/products/:id- Delete productGET /api/categories- Get product categoriesGET /api/health- Service health check
Query Parameters for GET /api/products:
category- Filter by categoryminPrice- Minimum price filtermaxPrice- Maximum price filterinStock- Filter by stock availabilitysearch- Search in name/descriptionpage- Page number (default: 1)limit- Items per page (default: 10, max: 100)
Endpoints:
GET /api/cart/:userId- Get user's cartPOST /api/cart/:userId/items- Add item to cartPUT /api/cart/:userId/items/:productId- Update cart item quantityDELETE /api/cart/:userId/items/:productId- Remove item from cartDELETE /api/cart/:userId- Clear entire cartGET /api/cart/:userId/summary- Get cart summaryGET /api/health- Comprehensive service health check (diagnostics)GET /api/health/live- Liveness probe (process check)GET /api/health/ready- Readiness probe (dependency and resource check)
Endpoints:
POST /api/orders/:userId- Create new orderGET /api/orders/:userId- Get user's ordersGET /api/orders/:userId/:orderId- Get specific orderPUT /api/orders/:userId/:orderId/status- Update order statusPOST /api/orders/:userId/:orderId/cancel- Cancel orderGET /api/health- Service health check
Endpoints:
POST /api/recommendations/grocery-suggestions- Get grocery suggestionsPOST /api/recommendations/personalized- Get personalized recommendationsPOST /api/grocery-suggestions- Legacy endpointGET /api/health- Service health check
-
Start the services:
npm run microservices:start npm run dev
-
Test Product Service:
curl http://localhost:3001/api/products curl http://localhost:3001/api/products/1 curl http://localhost:3001/api/categories
-
Test Cart Service:
# Add item to cart curl -X POST http://localhost:3002/api/cart/user-123/items \ -H "Content-Type: application/json" \ -d '{"productId": "1", "quantity": 2}' # Get cart curl http://localhost:3002/api/cart/user-123
-
Test AI Service:
curl -X POST http://localhost:3004/api/recommendations/grocery-suggestions \ -H "Content-Type: application/json" \ -d '{"cartItems": ["apples", "chicken"]}'
-
Test through API Gateway:
curl http://localhost:3000/api/products curl http://localhost:3000/health
- Visit http://localhost:9002
- Browse products
- Add items to cart
- View cart and checkout
- Check order history
The application includes a professional API testing framework built with Playwright and TypeScript covering all microservices.
-
Navigate to the test directory:
cd my-basket-api-tests -
Run the full test suite:
npm install npm test -
Run tests for specific issues:
# Test dependency validation npm test -- tests/cart-service/health-audit/issue1-dependency.spec.ts
-
View test reports:
npx playwright show-report
-
Run challenge or specific tests:
# Run only the Challenge 1.3.4 order-service tests npx playwright test tests/order-service/order.spec.ts -g "1.3.4Challenge" --workers=1 # Run a single test by title (example) npx playwright test -g "1.3.4Challenge - rounding to cents succeeds"
Rate Limiting in Development:
- The API Gateway's rate limiter is set to 1,000,000 requests/15 minutes for development
- This is configured in
microservices/api-gateway/src/index.ts - Production uses strict 1,000 requests/15 minutes limit
- π¨ If rate limit is reduced in development: Tests will fail with HTTP 429 (Too Many Requests) errors
Test Execution:
- Test suite runs with sequential execution (1 worker) to avoid state conflicts
- This is configured in
my-basket-api-tests/playwright.config.ts - π¨ If changed to parallel execution: Tests may fail due to shared microservice state interference
- Sequential execution takes ~35 seconds; parallel would be ~16-20 seconds but with intermittent failures
Why These Settings Matter:
- Parallel test workers against shared microservice instances cause state conflicts (carts, orders, products interfering between tests)
- Low rate limits cause HTTP 429 rejections when multiple tests hit the gateway simultaneously
- These are development-only optimizations; production deployments maintain strict security limits
For CI/CD Pipelines:
# Override to parallel if services are isolated per worker
WORKERS=6 npm test
# Or keep sequential for stable results
npm test # Uses workers: 1 by defaultNEXT_PUBLIC_API_URL=http://localhost:3000
# Common
NODE_ENV=development
PORT=300X
# Service-specific
PRODUCT_SERVICE_URL=http://localhost:3001
CART_SERVICE_URL=http://localhost:3002
ORDER_SERVICE_URL=http://localhost:3003
AI_SERVICE_URL=http://localhost:3004
βββ src/ # Next.js frontend source
β βββ app/ # App router pages
β βββ components/ # React components
β βββ contexts/ # React contexts
β βββ lib/ # Utilities and API clients
β β βββ api/ # Microservice API clients
β βββ data/ # Sample data (fallback)
βββ microservices/ # Microservices directory
β βββ api-gateway/ # API Gateway service
β βββ product-service/ # Product management service
β βββ cart-service/ # Shopping cart service
β βββ order-service/ # Order management service
β βββ ai-service/ # AI recommendations service
βββ cart-service-api-tests/ # Playwright API test suite for Cart Service
βββ Assignments/ # Audit trail of AI prompts and reports
βββ scripts/ # Development scripts
βββ docker-compose.yml # Docker configuration
βββ README.md # This file
- Check if ports are available:
npm run microservices:stop - Install dependencies:
npm run microservices:install - Check Node.js version (requires Node 18+)
- Verify microservices are running:
npm run microservices:health - Check API Gateway is accessible:
curl http://localhost:3000/health - Verify environment variables in
.env.local
- Ensure Docker is running
- Clean up:
docker system prune -f - Rebuild:
npm run docker:build
Problem: Tests fail with "Too many requests from this IP" errors
- Check rate limit in
microservices/api-gateway/src/index.ts - Ensure it's set to
1000000(1 million) for development, NOT50000
Solution:
-
Restart API Gateway to apply rate limit changes:
cd microservices/api-gateway npm run build docker-compose down api-gateway docker-compose up -d api-gateway -
Verify rate limit is applied:
npm run microservices:health
Problem: Tests pass sometimes, fail other times
- Check test worker configuration in
my-basket-api-tests/playwright.config.ts - Ensure
workers: 1is set (sequential execution)
Solution:
-
Verify sequential execution:
grep "workers:" my-basket-api-tests/playwright.config.tsShould show:
workers: 1, -
Run test suite:
cd my-basket-api-tests npm test # Sequential execution (stable, ~35s)
-
If you need parallel testing, ensure service isolation per worker (advanced setup)
-
Build all services:
npm run docker:build
-
Deploy with Docker Compose:
npm run docker:up
-
For cloud deployment, consider:
- Container orchestration (Kubernetes, ECS)
- Service mesh (Istio, Linkerd)
- API Gateway (Kong, Ambassador)
- Monitoring (Prometheus, Grafana)
- Frontend: Add components in
src/components/ - API: Update service clients in
src/lib/api/ - Backend: Modify appropriate microservice
- Database: Each service manages its own data
- TypeScript for type safety
- ESLint for code quality
- Prettier for formatting (configure as needed)
- Each microservice can be scaled independently
- Use container orchestration for production
- Implement caching (Redis) for frequently accessed data
- Add monitoring and logging
- Consider message queues for async communication
This repository is a proper fork of uppadhyayraj/my-basket-app with Windows compatibility improvements.
β This is now a proper GitHub fork with full fork relationship established.
Forking Process:
Step 1: Create Your Fork
- Go to https://github.com/uppadhyayraj/my-basket-app
- Click the "Fork" button (top right)
- Select your GitHub account to fork it to
Step 2: Clone Your Repository
# Replace 'mjalav' with your actual GitHub username
git clone https://github.com/mjalav/my-basket-app
cd my-basket-appmjalav with your actual GitHub username before running the command!
Step 3: Add Upstream Remote (for getting updates from original)
git remote add upstream https://github.com/uppadhyayraj/my-basket-appStep 4: Update from Upstream (when needed)
git fetch upstream
git merge upstream/mainThis fork includes Windows-specific enhancements:
Files Added:
scripts/start-microservices.bat- Windows batch script for starting servicesscripts/stop-microservices.bat- Windows batch script for stopping servicesscripts/health-check.bat- Windows batch script for health checks
Key Features:
- UTF-8 encoding support for proper emoji display (
chcp 65001) - Windows Command Prompt compatibility
- OS-specific npm scripts (
:winand:unixsuffixes) - Cross-platform development workflow
Branch Structure:
main- Synced with upstream repositoryfix/windows-microservices-compatibility- Windows compatibility featuresfix/windows-emoji-display-utf8- UTF-8 encoding improvements
- Fork this repository to your GitHub account:
- Go to https://github.com/mjalav/my-basket-app
- Click "Fork" button
- Clone your fork:
# Replace 'your-username' with your actual GitHub username git clone https://github.com/your-username/my-basket-app cd my-basket-app
- Set up remotes for upstream synchronization:
git remote add upstream https://github.com/mjalav/my-basket-app git remote -v # Verify configuration - Create a feature branch:
git checkout -b feature/your-feature-name
- Make changes and test on your platform
- Commit with clear messages
- Push to your fork:
git push origin feature/your-feature-name
- Create a Pull Request against this repository
To keep your fork updated with the original repository:
# Add original repository as upstream (first time only)
git remote add original-upstream https://github.com/uppadhyayraj/my-basket-app
# Fetch and merge changes from original
git fetch original-upstream
git checkout main
git merge original-upstream/main
# Push updates to your fork
git push origin mainThis project is a fork of uppadhyayraj/my-basket-app with enhancements for Windows compatibility. 6. Push and create a pull request
To contribute back to the original repository, submit pull requests to uppadhyayraj/my-basket-app.
This project is for educational purposes. Feel free to use and modify as needed.