# Ladaer-Backend Business Domains

## Core Business Areas

### 1. Truck Management

- **Purpose**: Manage fleet of trucks and their operations
- **Key Features**:
  - Truck registration and maintenance
  - Driver assignment and tracking
  - Operating status management (Running/Parked)
  - Fuel refill tracking with ODO readings
  - Check-in/check-out with image documentation
- **Main Controllers**: TruckController
- **Database Tables**: Trucks, TruckActivity, TruckActivityMedia

### 2. Driver & Attendance Management

- **Purpose**: Track driver attendance and work hours
- **Key Features**:
  - Automatic check-in/check-out detection
  - ODO reading capture
  - Image documentation for attendance
  - Dashboard with daily statistics
  - Truck assignment validation
- **Main Controllers**: AttendanceController
- **Database Tables**: Attendance, AttendanceMedia

### 3. Order & Logistics Management

- **Purpose**: Handle shipping orders and logistics operations
- **Key Features**:
  - Order creation and tracking
  - Package management
  - Fee calculation and financial tracking
  - Delivery status updates
  - Customer management
- **Main Controllers**: OrderController, PackageController
- **Database Tables**: Orders, OrderPackages, OrderFin, OrderTrack

### 4. User & Role Management

- **Purpose**: Manage system users and permissions
- **Key Features**:
  - User authentication via built-in ASP.NET Core Identity
  - JWT token-based authentication
  - Role-based authorization
  - Dynamic permission configuration
  - Agency-based access control
  - Founder bypass capabilities
- **Main Controllers**: UserController, RoleController
- **Database Tables**: User, Role, UserRole, RolePermissions

### 5. Media Management

- **Purpose**: Handle file uploads and media processing
- **Key Features**:
  - Image optimization and resizing
  - Video processing with FFmpeg
  - Multiple format support (WebP, JPEG, MP4)
  - Database integration with metadata
  - Structured file organization
- **Services**: UnifiedMediaService, NewMediaService
- **Database Tables**: Media, TruckActivityMedia, AttendanceMedia

### 6. Agency & Location Management

- **Purpose**: Manage business locations and coverage areas
- **Key Features**:
  - Agency registration and management
  - Service coverage areas
  - Location-based operations
  - Regional reporting
- **Main Controllers**: AgencyController, LocationController
- **Database Tables**: Agency, Location

### 7. Customer & Lead Management

- **Purpose**: Handle customer relationships and sales leads
- **Key Features**:
  - Customer registration and profiles
  - Lead tracking and conversion
  - Service history
  - Communication logs
- **Main Controllers**: CustomerController, LeadController
- **Database Tables**: Customer, Lead

### 8. Financial Management

- **Purpose**: Track financial transactions and reporting
- **Key Features**:
  - Order fee calculation
  - Driver commissions
  - Financial reporting
  - Payment tracking
- **Services**: OrderFinService, DriverFinService
- **Database Tables**: OrderFin, DriverFin

### 9. Configuration & Settings

- **Purpose**: System configuration and dynamic settings
- **Key Features**:
  - Dynamic configuration via database
  - Application settings management
  - Feature toggles
  - Environment-specific configs
- **Services**: AppConfigService
- **Database Tables**: AppConfigs

### 10. Notification Management

- **Purpose**: Handle system notifications and alerts
- **Key Features**:
  - Real-time notifications
  - Email/SMS integration
  - Push notifications
  - Template management
- **Separate Service**: Ladaer.NotificationManagement
- **Database Tables**: Notifications, NotificationTemplates

## Integration Points

- **ASP.NET Core Identity**: Built-in authentication system
- **Hangfire**: Background job processing
- **Google Maps**: Location services
- **OpenAI**: AI-powered features
- **LibreOffice**: Document conversion
- **FFmpeg**: Video processing

## Deprecated Components

- **LadaIdentity (IdentityServer4)**: Previously used for centralized authentication, now replaced by built-in ASP.NET Core Identity in the main API
