How nguyen1976/techshop works
Main Components
A. Client Layer
• External clients (Mobile/Web applications)
• Thunder Client/Postman for API testing
B. API Gateway Layer
• Routes (src/routes)
• Authentication Middleware (src/middleware/authMiddleWare.js)
C. Application Layer
• Controllers (src/controllers)
• Services (src/services)
• Models (src/models)
D. External Services
• MongoDB Database
• Google Authentication (indicated by verifyGoogleToken.js)
• Email Service (EmailService.js)
Component Relationships
Client → Routes → Controllers → Services → Models → Database
Detailed Architecture Elements
A. Authentication Flow:
• JWT token flow (access_token & refresh_token)
• Token storage (localStorage & cookies)
• Authentication middleware position
B. Core Business Domains:
• User Management
• Product Management
• Order Processing
• Address Management
• Visit Tracking
Component Details
A. Routes Layer:
• AddressRouter
• OrderRouter
• PaymentRouter
• ProductRouter
• UserRouter
• VisitRouter
B. Controller Layer:
• How controllers handle business logic
• Request/response processing
C. Service Layer:
• Business logic implementation
• External service integration (JWT, Email)
D. Model Layer:
• Data models
• MongoDB schema relationships
Security Flow
Authentication process:
Login Request → JWT Service → Access Token Generation →
Refresh Token Storage → Protected Routes
Additional Elements
• Error handling flows
• Data validation points
• Where middleware intercepts requests
• Public vs protected routes
External service integration points
Remember to:
• Notes for important security considerations
• Both synchronous and asynchronous operations
• Where data transformation occurs
This system design should reflect the RESTful nature of the API while highlighting the security measures implemented through JWT authentication and the separation of access and refresh tokens.