# Packages Directory **Last Updated**: 2025-01-27 **Purpose**: Shared libraries and packages overview ## Overview This directory contains shared libraries and packages used across services and applications in The Order monorepo. ## Package Categories ### Core Packages #### `shared/` - **Purpose**: Common utilities, middleware, error handling - **Used By**: All services - **Key Features**: Logging, validation, authentication, rate limiting #### `database/` - **Purpose**: Database layer, migrations, queries - **Used By**: All services - **Key Features**: PostgreSQL client, migrations, query builders #### `schemas/` - **Purpose**: Zod/JSON schemas for validation - **Used By**: All services and apps - **Key Features**: Request/response validation, type safety ### Authentication & Security #### `auth/` - **Purpose**: Authentication and authorization - **Used By**: All services - **Key Features**: JWT, OIDC, DID authentication #### `crypto/` - **Purpose**: Cryptography, KMS integration - **Used By**: Identity, Legal Documents services - **Key Features**: Key management, signing, encryption ### Infrastructure #### `storage/` - **Purpose**: Storage abstraction (S3/GCS/Azure) - **Used By**: Intake, Dataroom, Legal Documents services - **Key Features**: WORM storage, object lifecycle #### `monitoring/` - **Purpose**: Observability and metrics - **Used By**: All services - **Key Features**: Prometheus metrics, OpenTelemetry #### `cache/` - **Purpose**: Caching utilities - **Used By**: All services - **Key Features**: Redis caching, cache strategies ### Specialized Packages #### `verifier-sdk/` - **Purpose**: Verifiable credential verification - **Used By**: Identity service - **Key Features**: VC verification, DID resolution #### `ocr/` - **Purpose**: OCR processing - **Used By**: Intake service - **Key Features**: Document OCR, text extraction #### `payment-gateway/` - **Purpose**: Payment gateway abstraction - **Used By**: Finance service - **Key Features**: Stripe integration, payment processing ## Package Structure All packages follow a consistent structure: ``` package/ ├── src/ │ ├── index.ts # Main exports │ └── [module files] ├── tests/ # Test files ├── package.json # Package definition └── README.md # Package documentation ``` ## Using Packages ### In Services ```typescript import { createLogger, errorHandler } from '@the-order/shared'; import { getPool, createDocument } from '@the-order/database'; import { IssueVCSchema } from '@the-order/schemas'; ``` ### In Applications ```typescript import { Button } from '@the-order/ui'; import { validateSchema } from '@the-order/schemas'; ``` ## Development ### Building Packages ```bash # Build all packages pnpm build # Build specific package pnpm --filter @the-order/shared build ``` ### Testing Packages ```bash # Test all packages pnpm test # Test specific package pnpm --filter @the-order/shared test ``` ## Package Dependencies Packages can depend on other packages: - `shared` → No dependencies - `database` → `shared` - `auth` → `shared`, `database` - Services → Multiple packages ## Related Documentation - [Project Structure](../PROJECT_STRUCTURE.md) - [Service Documentation](../services/) - [Architecture Documentation](../docs/architecture/) --- **Last Updated**: 2025-01-27