System Design - Data Model Architecture
TEMP
Core Modelsβ
Customer & Organization Managementβ
-
Customer Model
- Primary tenant/organization model
- Supports multi-tenant architecture
- Industry-specific configuration (trucking/serviceRepair)
- Payment status tracking
- Contact management
-
Client Model
- Represents individual business clients
- Links to Customer (parent company)
- Contact information and rates
- Location management
- Text search capabilities
-
Organization Model
- Internal organization structure
- Employee management
- Meta information storage
User Managementβ
-
User Model
- Core user authentication
- Role-based access control
- Profile information
-
Employee Model
- Extended user information
- Department and position tracking
- Status management
- Parent company association
-
Driver Model
- Specialized user type
- Client association
- Organization assignment
Location Managementβ
-
Address Model
- Standardized address storage
- Geocoding support (lat/lng)
- Client association
- Full address formatting
-
Location Model
- Business location details
- Receiving hours
- Client association
- Address reference
Job Managementβ
-
Job Model
- Core job/work order entity
- Industry-agnostic base structure
- Status tracking
- Approval workflow
- Timeline tracking
- Client association
-
Leg Model (Trucking)
- Route segments
- Payout calculations
- Wait time tracking
- Custom rate handling
- Approval workflow
-
Maintenance Model (Service/Repair)
- Service details
- Parts tracking
- Time tracking
- Quote management
- Approval workflow
Financial Managementβ
-
Invoice Model
- Job aggregation
- Total calculations
- Status tracking
- Terms and due dates
-
Payout Model
- Driver/employee compensation
- Multiple rate types
- Shift and leg aggregation
- Total calculations
-
Manifest Model
- Driver route planning
- Leg aggregation
- Rate management
- Status tracking
Inventory Managementβ
-
InventoryItem Model
- Part tracking
- Stock management
- Supplier association
- Status tracking
-
Accessory Model
- Additional items
- Job association
- Pricing
Equipment Managementβ
- Equipment Model
- Asset tracking
- Maintenance history
- Status management
- Client association
Communication & Documentationβ
-
Message Model
- Internal communication
- Reference tracking
- Author association
-
Media Model
- File management
- URL generation
- Reference tracking
-
PDFTemplate Model
- Document templates
- Configuration storage
- Type-specific settings
Support & Feedbackβ
-
Feedback Model
- Issue tracking
- Message association
- Status management
- Priority handling
-
Notification Model
- System notifications
- Priority levels
- Expiration handling
- Read status tracking
Common Features Across Modelsβ
Timestampsβ
- Consistent
dateCreatedanddateUpdatedfields - Mongoose timestamp configuration
Parent Company Associationβ
- Multi-tenant support through
parentCompanyfield - Indexed for performance
Status Managementβ
- Standardized status tracking
- Status transition history
- Approval workflows where applicable
Virtual Fieldsβ
- Computed properties
- Aggregated calculations
- Formatted data
Indexing Strategyβ
- Parent company indexing
- Text search capabilities
- Reference field indexing
Pluginsβ
- Mongoose Paginate
- Mongoose Aggregate Paginate
- Mongoose Lean Virtuals
- Mongoose Autopopulate
Industry-Specific Featuresβ
Trucking Industryβ
- Route management
- Mileage tracking
- Driver assignments
- Payout calculations
- Manifest generation
Service/Repair Industryβ
- Maintenance scheduling
- Parts management
- Time tracking
- Quote generation
- Service history
Data Relationshipsβ
One-to-Manyβ
- Customer β Clients
- Client β Locations
- Job β Legs/Maintenance
- Invoice β Jobs
Many-to-Manyβ
- Job β Employees
- Maintenance β Parts
- Client β Contacts
One-to-Oneβ
- Location β Address
- Job β Invoice
Security Considerationsβ
Multi-tenant Isolationβ
- Parent company scoping
- Cross-tenant data protection
- Access control enforcement
Data Validationβ
- Schema-level validation
- Required fields
- Enum restrictions
- Custom validators
Audit Trailβ
- History tracking
- Change logging
- User attribution