Kargho Documentation
website·Indexed 30 days ago
https://kargho-us-documentation.vercel.appTechnical guides, resources, and API references for developing the Kargho App, Backend, and Backoffice. Includes documentation on onboarding document uploads, load assignment, push notifications, background location tracking, and integrations with external services like Peruse and Safer. Built with React JS and TypeScript.
What's inside Kargho
- Docusaurus is powered by React, which allows developers to extend or customize the website layout. You can create custom components or modify the layout while maintaining consistent global elements like the header and footer.
Implement background location tracking for drivers
The application utilizes the Transistorsoft library to handle background location tracking. This functionality is active exclusively when a driver is on a trip and the standard tracking (based on the 'steps' configuration in the database) ceases to track the device.Kargho Project Overview and Technology Stack
Kargho is a mobile application for transport and logistics designed for truck drivers and carriers to manage loads. Key features include real-time load collection, trip tracking, carrier-driver relationship management, and 24/7 virtual assistance.
The project is built using the following technology stack:
- Mobile App: Ionic v6 and Angular v18
- Backend: Lumen (PHP v8)
- Backoffice: React JS and TypeScript
Retrieve carrier information using Safer
The system integrates with Safer to retrieve detailed information about carriers. The API returns a comprehensive object containing the entity type, legal and DBA names, contact addresses, USDOT number, operating status, power units, driver counts, and detailed safety inspection data for both the US and Canada.{ "entity_type": "CARRIER", "legal_name": "SNOW TRUCKING LLC", "dba_name": "", "physical_address": "1301 AVIATION BLVD GAINESVILLE, GA 30501-6827", "phone": "(470) 592-0497", "mailing_address": "6327 HULSEY RD CLERMONT, GA 30527-1705", "usdot": "2939308", "state_carrier_id": "", "mc_mx_ff_numbers": "MC-7533", "duns_number": null, "power_units": 26, "drivers": 26, "mcs_150_form_date": "03/05/2024", "mcs_150_mileage_year": { "mileage": "1231881", "year": "2023" }, "out_of_service_date": null, "operating_status": "AUTHORIZED FOR Property", "operation_classification": ["Auth. For Hire"], "carrier_operation": ["Interstate"], "cargo_carried": [ "General Freight", "Fresh Produce", "Meat", "Refrigerated Food", "Paper Products" ], "united_states_inspections": { "vehicle": { "inspections": "29", "out_of_service": "8", "out_of_service_percent": "27.6%", "national_average": "22.26%" }, "driver": { "inspections": "57", "out_of_service": "4", "out_of_service_percent": "7%", "national_average": "6.67%" }, "hazmat": { "inspections": "0", "out_of_service": "0", "out_of_service_percent": "%", "national_average": "4.44%" }, "iep": { "inspections": "0", "out_of_service": "0", "out_of_service_percent": "0%", "national_average": "N/A" } }, "united_states_crashes": { "tow": 1, "fatal": 0, "injury": 1, "total": 2 }, "canada_inspections": { "driver": { "out_of_service": 0, "out_of_service_percent": "0%", "inspections": 0 }, "vehicle": { "out_of_service": 0, "out_of_service_percent": "0%", "inspections": 0 } }, "canada_crashes": { "tow": 0, "fatal": 0, "injury": 0, "total": 0 }, "safety_rating_date": null, "safety_review_date": null, "safety_rating": null, "safety_type": null, "latest_update": "03/05/2024", "us_inspections": { "driver": { "out_of_service": 4, "out_of_service_percent": "7%", "national_average": "6.67%", "inspections": 57 }, "vehicle": { "out_of_service": 8, "out_of_service_percent": "27.6%", "national_average": "22.26%", "inspections": 29 }, "hazmat": { "out_of_service": 0, "out_of_service_percent": "%", "national_average": "4.44%", "inspections": 0 }, "iep": { "out_of_service": 0, "out_of_service_percent": "0%", "national_average": "N/A", "inspections": 0 } }, "url": "http://safer.fmcsa.dot.gov/query.asp?searchtype=ANY&query_type=queryCarrierSnapshot&query_param=USDOT&original_query_param=NAME&query_string=2939308" }Manage invitations between Drivers and Carriers
The DriverCarrier system allows for mutual invitations between Drivers and Carriers. Carriers can invite Drivers using email or social media. Drivers have a dedicated 'Join to Carrier' section. Invitations can be shared via email or WhatsApp (which opens the WhatsApp app with a pre-defined message). Drivers can also invite Carriers, and Carriers can review the driver's information and documentation upon receiving an invitation.Set up a multi-project VS Code workspace for App, Backend, and Backoffice
When working on Jira tasks that require changes across the app, backend, and backoffice simultaneously, it is recommended to group them into a single VS Code workspace to improve productivity.1. Clone the app, backoffice, and backend projects to your machine. 2. Open one of the projects in VS Code. 3. Go to File > Add Folder to Workspace and add the other two project folders. 4. Go to File > Save Workspace As to save the configuration file. 5. Open this workspace file in the future to resume work on the feature/fix.Understand Driver License document requirements and extraction fields
The system defines specific requirements for the 'Driver License' document (code:driver_license). This document type requires both sides to be uploaded (RequiresBothSides: 1). The system extracts several key fields from the document for validation, including the driver's first name, last name, address, sex, license class, and the driver's license number.{ "Description": "Driver License", "Code": "driver_license", "RequiresBothSides": 1, "requirement_fields": [ { "FieldName": "first_name", "ColumnName": "FirstName" }, { "FieldName": "last_name", "ColumnName": "LastName" }, { "FieldName": "address", "ColumnName": "Address" }, { "FieldName": "sex", "ColumnName": "Sex" }, { "FieldName": "class", "ColumnName": "Class" }, { "FieldName": "dl_number", "ColumnName": "LicenseNumber" } ] }Implement load recommendation logic for standby trucks
The recommendation engine matches available loads to trucks in 'Stand By' status. The process follows these validation steps:
- Location Retrieval: Identify trucks in 'Stand By' state and retrieve their current coordinates.
- Equipment Association: Identify the associated Equipment (Trailer and Driver) for the truck.
- Proximity and Compatibility Check: Search for available loads within a defined range (X) of the truck's location and verify the following:
- Dimensions & Weight: Load requirements must match the trailer's specifications.
- Carrier Requirements: Carrier constraints must align with the load requirements.
- Driver Requirements: Driver constraints must align with the load requirements.
- Recommendation Generation: If all criteria are met, create a record in the recommendations table.
Recommendation Lifecycle: Recommendations are assigned to one carrier at a time. If a recommendation expires without action from the carrier, the system must generate a new recommendation for another eligible carrier.
-- Recommendation Table Schema Table recommendations { id: UUID/Int, idload: ForeignKey, idcarrier: ForeignKey, idequipment: ForeignKey, fecha_hora_recomendacion: DateTime, fecha_hora_vencimiento: DateTime, estado: String }Perform a deep deletion of a user and their load history
To fully remove a user and their associated data, you must delete records in a specific order to satisfy foreign key constraints: start with images and values, then move up to transitions, loads, and finally the user/driver entities.-- 1. Delete images and values DELETE FROM LoadDataTransitionValueImage WHERE IdLoadDataTransitionValue=52 DELETE FROM LoadDataTransitionValue WHERE IdLoadDataTransition=116 -- 2. Delete data transitions DELETE FROM LoadDataTransition WHERE IdLoadStepTransition=114 -- 3. Delete step transitions and components DELETE FROM LoadStepTransitionComponent WHERE IdLoadStepTransition=120 DELETE FROM LoadStepTransition WHERE IdLoad='376F7F7E-D9D6-4448-B299-AC0698F46402' -- 4. Delete recommendations and loads DELETE FROM Recommendation WHERE IdLOAD='376F7F7E-D9D6-4448-B299-AC0698F46402' DELETE FROM [Load] WHERE Id='376F7F7E-D9D6-4448-B299-AC0698F46402' -- 5. Delete core entities DELETE FROM [equipment] WHERE Id=9 DELETE FROM [driver] WHERE Id='1D110CCC-CDDC-4FCD-BB67-CB34E3419FFC' DELETE FROM [user] WHERE email='pabloierino.kargho@gmail.com'Identify document requirement codes
The system uses specific internal codes to identify required documents during the onboarding process. Common requirement codes include:
driver_license: Driver's License (may require both sides).driver_license_back: Back side of the Driver's License.medical_card: Medical Card.form_w9: W9 Form.
Validate document upload requirements and matching
When uploading onboarding documents, ensure the following constraints are met to avoid automatic rejection:
- The document code in the column must exactly match the corresponding code in Peruse.
- If a document is uploaded that does not match the expected type or requirement, the system will automatically reject the submission.
Change user role from Carrier to Owner Operator
To change a user's role from Carrier to Owner Operator, the system must perform the following sequence of operations: create a driver record, create a user role, create a user entity, assign theIdDrivervalue to the User, and create a record inCarrierDriver. The driver created should inherit the same data previously held by the carrier.