A comprehensive e-commerce platform integrating multiple microservices with a native mobile application. Built with .NET 9, React Native, Node.js, and MongoDB, implementing advanced architectural patterns including CQRS, BFF (Backend for Frontend), MVVM and offline-first mobile development.
The platform consists of multiple integrated services following Clean Architecture and microservices principles:
- Products Management - Product catalog with inventory management (.NET 9)
- Shopping Cart - CQRS-based cart and order system (.NET 9)
- Notifications System - Multi-channel notification delivery (.NET 9)
- Backend for Frontend (BFF) - Mobile-optimized aggregation layer (Node.js/TypeScript)
- Mobile Application - React Native app with offline support
- ProductsDB - MongoDB for product catalog
- CartDB_Write - MongoDB write model (source of truth)
- CartDB_Read - MongoDB read model (optimized queries)
- NotificationsDB - MongoDB for notification tracking
- Mobile SQLite - Local offline cache for products
- Native Mobile Experience: Cross-platform app for iOS and Android (Expo)
- MVVM Architecture: Clean separation with ViewModels, Services, and Views
- Offline Mode: SQLite-based local cache for browsing products without internet
- Smart Sync: Automatic online/offline detection with seamless fallback
- Cart Management: Add/remove products, view cart, manage quantities
- Modern UI: Glass-morphism design with gradient backgrounds
- Loading States: Proper handling of loading, error, and success states
- API Aggregation: Single endpoint combining data from multiple microservices
- Data Transformation: Mobile-optimized response formats
- Performance: Reduced round trips with aggregated responses
- Simplified Integration: Mobile app communicates only with BFF
- CartWithProductDetails: Enriched cart items with full product information
- ProductWithAvailability: Enhanced product data with stock indicators
- Cart Management: Create, view, and manage shopping carts per user
- Product Reservation: Products locked when added to cart via Products API
- Auto Expiration: Locks expire after 15 minutes of inactivity
- Cleanup Service: Background service removes abandoned carts
- Optimistic Locking: Version-based concurrency control
- Event Sourcing: Complete audit trail of cart operations
- CQRS Pattern: Separate write and read databases with eventual consistency
- Idempotent Checkout: Safe to retry checkout operations
- Product Catalog: Complete product management with categories
- Inventory Tracking: Real-time stock quantity management
- Reservation System: Lock products during cart operations
- Search & Filter: Category-based filtering and product lookup
- Stock Indicators: Low stock and availability flags
- Email Notifications: Order confirmation emails
- Push Notifications: Mobile push notification support
- Retry Mechanism: Reliable delivery with background retry workers
- Event Tracking: Complete notification audit trail
- Worker Services: Separate email and push notification workers
- Prometheus Metrics: System-wide performance monitoring
- Custom Metrics: Cart operations, checkouts, and business KPIs
- OpenTelemetry: Distributed tracing for HTTP requests
- Health Checks: Service health monitoring endpoints
- .NET 9 SDK
- Node.js (v18 or higher)
- Docker and Docker Compose
- MongoDB (via Docker or local installation)
- Expo CLI (for mobile app development)
- iOS Simulator (macOS) or Android Emulator/Device
git clone <repository-url>
cd shopping-systemCreate a .env file in the root directory:
MONGODB_CONNECTION_STRING=mongodb://localhost:27017
MONGODB_DATABASE_NAME=NotificationsDBStart all microservices using Docker Compose:
docker-compose up -dThis will start:
- Products Backend: http://localhost:5003
- Shopping Cart Backend: http://localhost:5001
- BFF (Backend for Frontend): http://localhost:5002
- Notifications Backend: http://localhost:5017
- Email Worker: http://localhost:9091
- Push Worker: http://localhost:9092
- Web Frontend: http://localhost
- Prometheus: http://localhost:9090
cd mobile-app
npm install
npx expo startThen:
- Press
ifor iOS Simulator - Press
afor Android Emulator - Scan QR code with Expo Go app on physical device
Edit mobile-app/app.json to set your host IP:
{
"expo": {
"extra": {
"apiHost": "192.168.1.100" // Your local IP address
}
}
}For Android emulator, the default 10.0.2.2 works automatically.
cd mobile-app
npm install
npx expo startArchitecture: MVVM pattern with React Native
- ViewModels:
ProductsViewModel,CartViewModel,ProductDetailsViewModel - Services:
productsService,cartService,productCacheRepository - Database: SQLite for offline cache
- API Config:
config/api.ts- BFF endpoint configuration
cd bff
npm install
npm run devThe BFF API will be available at http://localhost:5002
Key Components:
- Aggregation Service: Combines data from Products and Cart APIs
- Clients:
productsClient,cartClient - Routes:
/api/products,/api/carts,/api/home
cd shopping-cart/backend
dotnet restore
dotnet runThe API will be available at http://localhost:5001
cd shopping-cart/frontend
npm install
npm run devThe frontend dev server will start at http://localhost:5173
shopping-system/
├── mobile-app/ # React Native Mobile Application (Lab 4)
│ ├── app/ # Screens (Expo Router)
│ │ ├── index.tsx # Products list screen
│ │ ├── cart.tsx # Shopping cart screen
│ │ ├── product/[id].tsx # Product details screen
│ │ └── _layout.tsx # Root layout
│ ├── viewmodels/ # MVVM ViewModels
│ │ ├── ProductsViewModel.ts
│ │ ├── ProductDetailsViewModel.ts
│ │ └── CartViewModel.ts
│ ├── services/ # Business logic services
│ │ ├── productsService.ts # Products API communication
│ │ ├── cartService.ts # Cart API communication
│ │ ├── database.ts # SQLite initialization
│ │ └── productCacheRepository.ts # Offline cache
│ ├── config/
│ │ └── api.ts # BFF endpoint configuration
│ └── types/ # TypeScript type definitions
│
├── bff/ # Backend for Frontend (Node.js)
│ ├── src/
│ │ ├── index.ts # Express server setup
│ │ ├── config.ts # Environment configuration
│ │ ├── routes/ # API routes
│ │ │ ├── products.ts # Products aggregation endpoints
│ │ │ ├── cart.ts # Cart aggregation endpoints
│ │ │ └── home.ts # Home screen data endpoint
│ │ ├── services/
│ │ │ └── aggregationService.ts # Data aggregation logic
│ │ └── clients/ # Microservice clients
│ │ ├── productsClient.ts
│ │ └── cartClient.ts
│ └── Dockerfile
│
├── products-management/ # Products Service (Lab 1)
│ └── backend/
│ ├── Controllers/ # API controllers
│ ├── Models/ # Product entities
│ ├── Infrastructure/ # MongoDB configuration
│ └── Services/ # Business logic
│
├── shopping-cart/ # Shopping Cart Service (Lab 3)
│ ├── backend/
│ │ ├── Application/ # Use Cases (CQRS Commands/Queries)
│ │ │ └── UseCases/
│ │ │ ├── CreateCart/
│ │ │ ├── AddProductToCart/
│ │ │ ├── CheckoutCart/
│ │ │ └── ...
│ │ ├── Domain/ # Domain entities and logic
│ │ │ ├── Entities/ # Cart, CartItem, Order
│ │ │ ├── Events/ # Domain events
│ │ │ └── Services/ # Domain services
│ │ ├── Infrastructure/ # Infrastructure concerns
│ │ │ ├── Events/ # Event publishing
│ │ │ └── Metrics/ # Prometheus metrics
│ │ ├── Repositories/ # Data access layer
│ │ │ ├── CartRepository.cs # Write model
│ │ │ └── CartReadRepository.cs # Read model
│ │ └── Services/ # Application services
│ │ ├── BackgroundServices/
│ │ ├── ProductsApiClient.cs
│ │ └── NotificationsApiClient.cs
│ └── frontend/ # React web UI
│
├── notifications-system/ # Notifications Service (Lab 2)
│ ├── backend/ # Notifications API
│ ├── email-worker/ # Email worker service
│ ├── push-worker/ # Push notification worker
│ └── Shared/ # Shared libraries
│
├── docker-compose.yml # Orchestration for all services
├── prometheus.yml # Prometheus configuration
├── BFF_IMPLEMENTATION.md # BFF architecture documentation
└── README.md # This file
The mobile app supports full offline functionality for product browsing:
- Automatic Caching: Products are cached in SQLite when loaded
- Offline Detection: App automatically detects connection status
- Seamless Fallback: Switches to cache when API unavailable
- Visual Indicators: "Offline Mode" badge shown to users
- Cart Blocking: Cart operations disabled in offline mode
- Views: React Native components in
app/directory - ViewModels: State management and business logic
- Services: API communication and data persistence
- Repository: Data access abstraction for cache
- Products List (
/): Browse all products with offline support - Product Details (
/product/[id]): View details and add to cart - Shopping Cart (
/cart): Manage cart items and checkout - Orders (
/orders): View order history - Profile (
/profile): User settings