Skip to main content

AttuneLogic API Architecture Overview

TEMP

Core Concepts​

Multi-Tenant Architecture​

  • Each tenant is represented by a Customer model
  • All models include a parentCompany field for tenant isolation
  • Industry-specific configurations stored in Customer model
  • Role-based access control per tenant

Industry Support​

  1. Trucking Industry

    • Route management (Leg, Route models)
    • Driver management (Driver model)
    • Manifest generation
    • Payout calculations
    • Mileage tracking
  2. Service/Repair Industry

    • Work order management (Job model)
    • Maintenance tracking
    • Parts inventory
    • Equipment management
    • Time tracking

Key Models​

Customer Management​

// Customer Model
{
name: String,
email: String,
industry: String, // "trucking" | "serviceRepair"
appType: String,
paymentStatus: String,
contacts: [User],
metadata: Mixed
}

Job Management​

// Job Model
{
client: Client,
status: String,
tasks: [Task],
assignedTo: [Employee],
// Industry-specific fields
legs: [Leg], // Trucking
maintenance: [Maintenance], // Service/Repair
accessories: [Accessory]
}

Financial Management​

// Invoice Model
{
client: Client,
jobs: [Job],
status: String,
totals: Mixed,
calculatedTotalCharges: Number
}

// Payout Model
{
driver: User,
legs: [Leg],
shifts: [Shift],
hourlyRate: Number,
mileageRate: Number
}

Common Patterns​

Status Management​

  • All models use consistent status tracking
  • Status transitions are logged
  • Approval workflows where applicable

Timestamps​

  • Consistent dateCreated and dateUpdated fields
  • Mongoose timestamp configuration

Parent Company Association​

  • Multi-tenant support through parentCompany field
  • Indexed for performance

Virtual Fields​

  • Computed properties for totals
  • Aggregated calculations
  • Formatted data

Database Features​

Indexing Strategy​

  • Parent company indexing
  • Text search capabilities
  • Reference field indexing

Mongoose Plugins​

  • mongoose-paginate-v2
  • mongoose-aggregate-paginate-v2
  • mongoose-lean-virtuals
  • mongoose-autopopulate

Data Validation​

  • Schema-level validation
  • Required fields
  • Enum restrictions
  • Custom validators

Security Considerations​

Multi-tenant Isolation​

  • Parent company scoping
  • Cross-tenant data protection
  • Access control enforcement

Audit Trail​

  • History tracking
  • Change logging
  • User attribution

API Design​

RESTful Endpoints​

  • Resource-based routing
  • Consistent response format
  • Error handling

Authentication​

  • JWT-based authentication
  • Role-based authorization
  • Session management

Rate Limiting​

  • Request throttling
  • API quotas
  • Rate limit headers

Development Guidelines​

Code Organization​

  • Feature-based structure
  • Modular components
  • Shared utilities

Error Handling​

  • Consistent error format
  • Error logging
  • Client-friendly messages

Testing Strategy​

  • Unit tests
  • Integration tests
  • API tests

Deployment​

Environment Configuration​

  • Development
  • Testing
  • Staging
  • Production

Monitoring​

  • Error tracking
  • Performance monitoring
  • Usage analytics

Future Considerations​

Scalability​

  • Horizontal scaling
  • Caching strategy
  • Database optimization

Feature Roadmap​

  • Industry-specific enhancements
  • Integration capabilities
  • Mobile app support