Data Management - pratchaya-maneechot/service-exchange GitHub Wiki
Each microservice owns its data and exposes it only through its API.
Service | Database Type | Justification |
---|---|---|
User & Identity | PostgreSQL | ACID compliance, relational data |
Task Management | PostgreSQL | Complex queries, transactions |
Bidding & Negotiation | PostgreSQL | Transactional integrity |
Payment | PostgreSQL | Financial data, ACID critical |
Review & Rating | MongoDB | Flexible schema, read-heavy |
Notification | MongoDB | Varied message structures |
Location & Mapping | PostGIS | Geospatial queries |
Support & Dispute | MongoDB | Flexible ticket structures |
Multi-level Caching:
- CDN Level: Static assets, API responses
- API Gateway Level: Response caching
- Service Level: Redis for frequently accessed data
- Database Level: Query result caching
Cache Patterns:
- Cache-Aside: Application manages cache
- Write-Through: Cache updated on write
- Write-Behind: Asynchronous cache updates
- Payment transactions
- User authentication
- Critical business operations
- Notification delivery
- Search index updates
- Analytics data
- Cross-service data synchronization
Task Assignment Saga:
1. Create Escrow (Payment Service)
2. Assign Task (Task Service)
3. Notify Parties (Notification Service)
Compensation Actions:
- Release Escrow if assignment fails
- Revert task status if notification fails