How hangxigood/erp-mes works
Main Components
a) Client Layer:
• Next.js Frontend (App Router architecture)
• Authentication Pages (/app/(authPage))
• Batch Record Pages (/app/(batchRecordPage))
• User Management Pages (/app/(userPage))
• React Components (/components)
b) API Layer:
• Next.js API Routes (/app/api)
• Authentication Endpoints
• Batch Record Management
• User Management
• Template Management
c) Service Layer:
• Authentication Service (NextAuth.js)
• Email Service (SendGrid)
• Change Stream Service (/lib/changeStream.js)
• Audit Logging Service
d) Data Layer:
• MongoDB Database
• Mongoose Models:
• BatchRecord
• BatchRecordData
• FieldValueHistory
• Template
• User
[Client Layer] → [API Layer] → [Service Layer] → [Data Layer]
Important Flows to Highlight
a) Authentication Flow:
Login Page → NextAuth → MongoDB → Session Management
b) Batch Record Processing:
Template Selection → Record Creation → Section Management → Signoff Process → Audit Logging
c) Change Management:
User Action → API Route → Change Stream → Audit Log → Database Update
Key Relationships to Emphasize
• Template to BatchRecord relationship
• User to BatchRecord permissions
• Audit log connections to all operations
• Change stream monitoring of database operations
Remember to:
• Notes for important business rules
• Error handling paths
• Scalability points
This system design should effectively communicate both the technical architecture and the business process flow of the ERP-MES system while maintaining clarity and accuracy.