Skip to content

Shared Packages

The Majestic Transport monorepo leverages shared packages to promote consistency, code reuse, and efficient development across all applications.

Purpose

By centralizing common logic and definitions, shared packages ensure:

  • Type Safety: The Admin app, Driver app, and API all use the same data models.
  • Validation Consistency: Rules defined once are applied everywhere.
  • Developer Productivity: Reducing duplication and streamlining communication between different parts of the system.

Core Packages

🧩 @majestic-transport/schema

The foundation for all data validation and type definitions in the ecosystem. It contains:

  • Zod Schemas: Rules for validating trips, drivers, cars, and other entities.
  • TypeScript Types: Inferred types from schemas for full-stack type safety.
  • Form Validation: Shared logic used by both the Admin and Driver app for form inputs.

🔌 @majestic-transport/client

A centralized API client package that provides:

  • Unified Interface: A single, type-safe way for all applications to interact with the Hono API.
  • Automatic Token Injection: Handles authentication headers and session management for the client applications.
  • Error Handling: Standardized error management across different frontend platforms.

Architectural Benefits

  • Lean Bundles: Packages are structured to ensure that frontends only pull in necessary code, avoiding unnecessary server-side dependencies.
  • Consistent Communication: Ensures that all applications "speak the same language" when interacting with the API.
  • Easier Refactoring: Changes to core schemas or client logic only need to be made in one place and are automatically propagated throughout the monorepo.