← Back to architecture

Business Logic Layer — Request Handling & Workflow Orchestration

Core application logic: request validation → domain rules → workflow execution → state management → response composition · NestJS microservices architecture

Entry points
REST API controllers
GraphQL resolvers
WebSocket handlers
Event consumers
Scheduled jobs (cron)
Input validation
DTO validation (class-validator)
Schema enforcement
Type coercion
Sanitization (XSS/SQL)
Size limits
Auth context
JWT decode → user
Role extraction
Tenant resolution
Permission check
Session hydration
Request enrichment
Correlation ID inject
Geo-IP resolution
Device fingerprint
Feature flags load
Rate limit check
Guards & interceptors
AuthGuard
RolesGuard
ThrottlerGuard
LoggingInterceptor
TransformInterceptor
Credit services
Score calculation
Credit report parse
Factor analysis
Recommendation engine
Dispute workflow
Payment services
Transaction process
Balance management
Fee calculation
Settlement logic
Refund handling
User services
Profile management
KYC orchestration
Subscription logic
Notification prefs
Account lifecycle
FX services
Rate aggregation
Spread calculation
Corridor routing
Limit enforcement
Hedging logic
Rule engine
Business rules (JSON)
Condition evaluation
Decision trees
Dynamic thresholds
A/B rule variants
Saga orchestrator
Temporal workflows
Step sequencing
Compensating actions
Retry policies
Timeout handling
Event choreography
Event sourcing
CQRS separation
Domain events emit
Event handlers
Eventual consistency
State machine
Transaction states
KYC states
Dispute states
Subscription states
Guard transitions
Distributed transactions
Two-phase commit
Idempotency keys
Outbox pattern
Dead letter queue
Manual reconciliation
Async processing
BullMQ job queues
Priority scheduling
Delayed execution
Batch processing
Worker scaling
Data access
TypeORM repositories
Redis cache layer
MongoDB documents
S3 file storage
Elasticsearch index
AI/ML calls
Credit LLM queries
Prael agent invoke
Fraud model score
NLP extraction
Embedding lookup
Payment providers
Stripe SDK
Flutterwave API
Stablecoin contracts
Bank partners
MoMo integration
Bureau & identity
TransUnion
Equifax
Experian
KYC providers
Identity verification
Resilience patterns
Circuit breaker
Retry (exp. backoff)
Timeout management
Bulkhead isolation
Fallback responses
Response handling
DTO serialization
Pagination (Pagination<T>)
Error formatting
Status code mapping
Cache headers
Logging
Structured JSON logs
Correlation trace
Request/response log
PII redaction
Log levels (dynamic)
Metrics
Latency histograms
Error rate counters
Business KPIs
Queue depths
DB query time
Tracing
OpenTelemetry spans
Cross-service traces
DB query spans
External call spans
Jaeger visualization
Health & SLA
p50
45ms
p95
220ms
p99
890ms
Error
0.1%
SLA target: 99.95% uptime