Backend Packages Monorepo
RightCapital’s backend packages monorepo contains 43+ shared PHP libraries that provide foundational infrastructure for all backend services.
Overview
Section titled “Overview”| Attribute | Value |
|---|---|
| Location | /backend/packages/ |
| PHP Version | 8.4+ (strict types required) |
| Package Manager | Composer 2.9+ |
| Monorepo Tool | Symplify MonorepoBuilder |
| Laravel Version | 12.10+ |
Architecture
Section titled “Architecture”packages/├── libs/ # 43 individual packages│ ├── array-helpers/│ ├── core-models/│ ├── laravel-restful/│ └── ...├── bin/ # Build/CI scripts├── composer.json # Root manifest├── monorepo-builder.php # Monorepo configuration└── .gitlab-ci.yml # CI/CD pipelinePackage Categories
Section titled “Package Categories”Low-level utility packages with no internal dependencies:
array-helpers- Array manipulation and arithmeticstring-helpers- String formatting and localizationnumeric-helpers- Precision arithmetic and comparisonsfile-helpers- File/stream operationshtml-helper- HTML sanitizationbilling-helpers- Billing domain utilitiesmethod-delegate- AOP method interception
Central domain models and business logic:
core-models- 225+ Eloquent models, 105+ enumscore-seeds- YAML database seederscore-test-fixtures- Test fixture datasetsbusiness-validation-rules- 40+ validation rulesfinancial-networks- Advisor network abstractions
Enhanced Laravel framework features:
illuminate-database- Submodels, IAM auth, validationilluminate-encryption- ID encryption, static IVilluminate-filesystem- Flysystem decorator chainsilluminate-http-problem-response- RFC 7807 responsesilluminate-routing- Resource routing customizationilluminate-validation- 12+ custom validation ruleslaravel-restful- RESTful controller traitslaravel-form-requests- Multi-source validation
External service integrations:
integrations-core- Base integration abstractionsintegrations-file-based- File-based vendor importslaravel-stripe- Stripe payment processinglaravel-salesforce- Salesforce CRMlaravel-azure-ad- Azure AD authenticationsaml- SAML 2.0 SSO
Monitoring and performance tracking:
laravel-apm- OpenTelemetry distributed tracinglaravel-sentry- Error tracking with contextlaravel-cronitor- Job health monitoringlaravel-query-detector-outputs- N+1 detectionfile-log- Structured file logging
Performance optimization packages:
laravel-file-storage-cache- Cloud storage cachelaravel-command-cache- Cache management CLIlaravel-http-cache-control- HTTP cache headersflysystem-compress-adapter- Transparent compression
Development and CI/CD tools:
phpstan-rules- Static analysis rulesrector-rules- Automated refactoringphp-cs-fixer-rules- Code style configurationphp-cs-fixer-custom-fixers- Custom style fixerscomposer-normalize- composer.json normalizationcomposer-event-dispatcher- Composer-Laravel bridgeide-helper-files-generator- IDE autocompleteenv-sync- Environment variable sync
Other utility packages:
xml-parser- XML to array conversionlaravel-database-tools- Schema manipulationlaravel-aop- Aspect-oriented programming
Dependency Tiers
Section titled “Dependency Tiers”Packages are organized in dependency tiers to prevent circular dependencies:
| Tier | Description | Examples |
|---|---|---|
| 0 | No internal dependencies | string-helpers, file-helpers, numeric-helpers |
| 1 | Depends on Tier 0 | array-helpers, financial-networks |
| 2 | Core domain + Illuminate extensions | core-models, illuminate-validation |
| 3 | Laravel integrations | laravel-restful, integrations-core |
| 4 | High-level business packages | integrations-file-based |
| 5 | Tooling (meta) | phpstan-rules, ide-helper-files-generator |
Consumers
Section titled “Consumers”These packages are consumed by three main backend services:
| Service | Description |
|---|---|
| retail-api | Customer-facing API |
| admin-api | Internal administration API |
| calculation-api | Financial calculation service |
All services pin the same package version (e.g., 100.885.0) for consistency.
Commands
Section titled “Commands”# Static analysiscomposer phpstan [packages...]
# Code style fixingcomposer phpcs
# Automated refactoringcomposer rector
# Validate monorepo structurecomposer monorepo-validate
# Normalize composer.json filescomposer normalizeCI/CD Integration
Section titled “CI/CD Integration”The packages monorepo uses GitLab CI with:
- PHPStan static analysis
- PHP-CS-Fixer style checking
- Rector dry-run validation
- Composer normalize validation
- Package splitting for independent publishing