Skip to main content

Data Models & Schemas

This document outlines the core data models and database schemas used in the AttuneLogic API.

🏗️ Core Models

User Model

{
_id: ObjectId,
email: String,
firstName: String,
lastName: String,
role: String, // 'admin', 'manager', 'technician', 'driver'
company: ObjectId, // Reference to Company
isActive: Boolean,
createdAt: Date,
updatedAt: Date
}

Company Model

{
_id: ObjectId,
name: String,
industry: String, // 'trucking', 'hvac', 'plumbing', 'electrical'
settings: {
features: {
dispatch: Boolean,
scheduling: Boolean,
inventory: Boolean
},
approvals: {
required: Boolean,
levels: Number
}
},
createdAt: Date,
updatedAt: Date
}

Job Model

{
_id: ObjectId,
company: ObjectId,
customer: ObjectId,
assignedTo: ObjectId, // Reference to User
status: String, // 'pending', 'in_progress', 'completed', 'cancelled'
title: String,
description: String,
location: {
address: String,
coordinates: [Number, Number] // [longitude, latitude]
},
scheduledDate: Date,
completedDate: Date,
items: [JobItemSchema],
createdAt: Date,
updatedAt: Date
}

Equipment Model

{
_id: ObjectId,
company: ObjectId,
name: String,
type: String, // 'truck', 'van', 'hvac_unit', 'tool'
serialNumber: String,
status: String, // 'active', 'maintenance', 'retired'
assignedTo: ObjectId, // Reference to User
location: String,
maintenanceSchedule: [{
type: String,
frequency: String, // 'daily', 'weekly', 'monthly'
lastPerformed: Date,
nextDue: Date
}],
createdAt: Date,
updatedAt: Date
}

🔄 Relationship Patterns

Multi-Tenant Structure

All models include a company field to ensure data isolation between tenants.

User Assignments

Jobs and equipment can be assigned to users, creating clear responsibility chains.

Flexible Configuration

The Company model includes flexible settings that adapt the platform to different industry needs.

📋 Industry-Specific Extensions

Trucking Industry

  • Load Model: Cargo details, pickup/delivery locations
  • Route Model: Optimized routing and GPS tracking
  • Driver Model: License information, hours tracking

Service Industries

  • Service Model: Work order details, parts used
  • Customer Model: Service history, equipment serviced
  • Inventory Model: Parts and supplies tracking

🔐 Security Considerations

  • All models include tenant isolation via company field
  • Sensitive data is encrypted at rest
  • Access control enforced at the model level
  • Audit trails maintained for compliance