Files
motovaultpro/docs/generic-record.md
Eric Gullickson 3d43cddd1f Data model work
2025-08-04 21:15:34 -05:00

122 lines
4.7 KiB
Markdown

# GenericRecord Data Model Analysis
## Overview
**GenericRecord** is a **C# class** defined in `Models/Shared/GenericRecord.cs` that serves as a **base class** in MotoVaultPro's architecture, implementing the Generic Record Pattern for shared vehicle maintenance record properties.
## Properties
The GenericRecord class has **10 properties**:
### Core Properties
- `int Id` - Primary key identifier
- `int VehicleId` - Foreign key linking to vehicle
- `DateTime Date` - When the record occurred
- `int Mileage` - Vehicle odometer reading
- `string Description` - Human-readable description
- `decimal Cost` - Monetary cost associated with record
- `string Notes` - Additional notes/comments
### Collection Properties
- `List<UploadedFiles> Files` - File attachments (Name, Location, IsPending)
- `List<string> Tags` - Categorization tags
- `List<ExtraField> ExtraFields` - Custom fields (Name, Value, IsRequired, FieldType)
- `List<SupplyUsageHistory> RequisitionHistory` - Supply usage tracking
## Architecture Role
GenericRecord implements the **Generic Record Pattern** mentioned in the architecture documentation. It serves as a **base class** that provides common properties shared across different record types, promoting code reuse and maintainability.
## Inheritance Pattern
### Classes that inherit from GenericRecord
- `ServiceRecord` - Maintenance and repair records
- `UpgradeRecord` - Vehicle modification records
### Classes with similar structure (not inheriting)
- `GasRecord` - Fuel tracking with additional properties (Gallons, IsFillToFull, MissedFuelUp)
- `TaxRecord` - Registration and tax records with recurring reminder fields
- `SupplyRecord` - Parts and supplies with specific properties (PartNumber, PartSupplier, Quantity)
- `PlanRecord` - Maintenance planning with priority/progress tracking
- `OdometerRecord` - Simplified for mileage tracking only
- `ReminderRecord` - Focused on reminder scheduling and intervals
## Supporting Classes
### UploadedFiles
Located in `Models/Shared/UploadedFiles.cs`:
- `string Name` - File name
- `string Location` - File storage path
- `bool IsPending` - Upload status flag
### ExtraField
Located in `Models/Shared/ExtraField.cs`:
- `string Name` - Field name
- `string Value` - Field value
- `bool IsRequired` - Required field flag
- `ExtraFieldType FieldType` - Field data type
### SupplyUsageHistory
Located in `Models/Supply/SupplyUsageHistory.cs`:
- `int Id` - Record identifier
- `DateTime Date` - Usage date
- `string PartNumber` - Part identifier
- `string Description` - Part description
- `decimal Quantity` - Amount used
- `decimal Cost` - Cost of usage
### ExtraFieldType Enum
Located in `Enum/ExtraFieldType.cs`:
- `Text` (0) - Text input
- `Number` (1) - Integer input
- `Decimal` (2) - Decimal input
- `Date` (3) - Date picker
- `Time` (4) - Time picker
- `Location` (5) - Location input
## Usage Throughout Application
GenericRecord is utilized extensively across MotoVaultPro:
### API Layer
- **GenericRecordExportModel** - JSON serialization for import/export operations
- **API endpoints** - Service and upgrade record CRUD operations
- **Webhook notifications** - WebHookPayload.FromGenericRecord for external integrations
### UI Layer
- **GenericRecordEditModel** - Bulk editing operations across multiple records
- **_GenericRecordModal** - Modal interface for multi-record editing
- **Sticker generation** - Vehicle maintenance stickers with record data
### Data Access Layer
- **Repository pattern** - Common interface for record operations
- **Database abstraction** - Unified storage across LiteDB and PostgreSQL
- **Data transformation** - Conversion between record types
### Business Logic
- **Record management** - Create, update, delete operations
- **Cost calculations** - Financial reporting and analysis
- **Mileage tracking** - Odometer progression validation
## Design Benefits
1. **Code Reuse** - Common properties defined once and inherited
2. **Maintainability** - Centralized structure for vehicle records
3. **Consistency** - Uniform data model across record types
4. **Extensibility** - Easy addition of new record types
5. **Bulk Operations** - Unified interface for multi-record editing
6. **API Consistency** - Standardized data exchange format
## Implementation Notes
- GenericRecord serves as both a base class and a standalone model
- Not all record types inherit from GenericRecord due to specialized requirements
- The pattern balances common functionality with type-specific needs
- File attachments, tags, and extra fields provide extensibility
- Supply usage tracking enables parts management integration
---
**Document Version**: 1.0
**Last Updated**: August 2025
**Related Documentation**: [Architecture Documentation](architecture.md), [Record Architecture](record-architecture.md)