Packages
Shared packages and utilities in the Affluent monorepo
Packages
The Affluent monorepo includes several shared packages that provide reusable functionality across applications and services. These packages are designed to promote code reuse, maintain consistency, and enable independent development workflows.
Package overview
Architecture
Shared typeScript packages
The main application uses several TypeScript packages that provide:
- UI Components (
@affluent/ui): Radix UI primitives with TailwindCSS design system - Financial Calculators (
@affluent/calculators): Reusable financial calculation tools shared between app and website - Utility Library (
@affluent/lib): Common utilities for date, currency, and number formatting
Independent packages
Some packages are designed to operate independently from the main application:
- Financial Data Service: FastAPI service for fetching financial market data via REST API
Package management
All packages are managed through the Turborepo monorepo structure:
# Install dependencies for all packages
pnpm install
# Build all packages
turbo build
# Build specific package
turbo build --filter=@affluent/uiDevelopment workflow
TypeScript packages
TypeScript packages follow the standard monorepo workflow:
- Develop packages in isolation
- Use workspace dependencies (
workspace:*) for internal packages - Build and test through Turborepo pipeline
- Import packages using
@affluent/package-name
Independent packages
Independent packages like the Financial Data Service have their own development workflow:
- Separate dependency management (Python virtual environments)
- REST API integration with HTTP endpoints
- Integration through npm scripts in the root package.json
- Independent versioning and deployment
Integration
Monorepo integration
Packages are integrated into the monorepo through:
- Turborepo Configuration: Defined in
turbo.jsonfor TypeScript packages - Package Scripts: Convenient npm scripts in root
package.jsonfor all packages - Shared Configuration: ESLint, TypeScript, and Biome configurations
Cross-package Dependencies
- TypeScript packages can depend on each other using workspace references
- Independent packages interact through database and external APIs
- Shared environment variables and configuration through the monorepo structure
Best Practices
Package development
- Single Responsibility: Each package should have a clear, focused purpose
- Minimal Dependencies: Keep external dependencies to a minimum
- TypeScript First: Use strict TypeScript for type safety (TypeScript packages)
- Documentation: Comprehensive documentation for all public APIs
- Testing: Unit tests and integration tests where appropriate
Monorepo considerations
- Build Order: Ensure packages build in the correct dependency order
- Version Management: Coordinate versions between dependent packages
- Breaking Changes: Consider impact on consuming packages and applications
- Performance: Optimize build times through efficient dependency graphs
Contributing
When adding new packages:
- Follow the established directory structure
- Add appropriate build and test scripts
- Update Turborepo configuration if needed
- Document the package purpose and API
- Consider integration points with existing packages
For package-specific contribution guidelines, see the individual package documentation.