How pampam000/testtasksecunda works
Payment Service accepts authenticated, idempotent payment requests, atomically stores each payment with an outbox event, and returns a response. A relay publishes pending events to RabbitMQ; a consumer processes pending payments through an emulated gateway, persists the outcome, and attempts a customer webhook. Broker retry queues and a dead-letter queue handle failed processing. The graph also preserves API lookup, authentication, configuration, and the documented circuit-breaker behavior. Relationships for unsampled details rely on README descriptions; source excerpts do not show every persistence or broker interaction.
Main entry points: payments.py Payment routes · handler.py Payment consumer · topology.py Broker topology · main.py Application startup
Components 19
Payment API
- Payment routes
app/api/payments.py - API key auth
app/api/deps.py - Payment schemas
app/schemas/payment.py - Application startup
app/main.py - Service settings
app/core/config.py
Persistence and outbox
- Payment repository
app/repositories/payments.py - Payment model
app/models/payment.py - Outbox model
app/models/outbox.py - Outbox relay
app/outbox/relay.py
Messaging
- Broker topology
app/messaging/topology.py
Payment processing
- Payment consumer
app/consumer/handler.py - Payment processor
app/consumer/processor.py - Emulated gateway
app/consumer/gateway.py - Retry publisher
app/consumer/retry.py - Webhook delivery
app/consumer/webhook.py
Other components
- API client
- PostgreSQL
- RabbitMQ
- Customer webhook
Connections 25
- API client → Payment routes: submits or queries
README.md - Payment routes → API key auth: requires key
app/api/payments.py - Payment routes → Payment schemas: validates and formats
app/api/payments.py - Payment routes → Payment repository: calls
app/api/payments.py - Payment repository → Payment model: creates and fetches
app/repositories/payments.py - Payment repository → Outbox model: creates event
app/repositories/payments.py - Payment repository → PostgreSQL: reads and writes
README.md - Payment routes → PostgreSQL: commits transaction
app/api/payments.py - Application startup → Payment routes: registers routes
app/main.py - Application startup → Service settings: loads settings
app/main.py - Application startup → Broker topology: connects and declares
app/main.py - Application startup → Outbox relay: starts relay
app/main.py - Outbox relay → Outbox model: claims and marks published
app/outbox/relay.py - Outbox relay → Broker topology: uses event publisher
app/main.py - Broker topology → RabbitMQ: declares and publishes
app/messaging/topology.py - RabbitMQ → Payment consumer: delivers payment events
app/consumer/handler.py - Payment consumer → Broker topology: subscribes to queue
app/consumer/handler.py - Payment consumer → Payment processor: invokes processing
app/consumer/handler.py - Payment processor → Payment model: checks and updates status
app/consumer/processor.py - Payment processor → Emulated gateway: runs charge simulation
app/consumer/processor.py - Payment processor → Webhook delivery: requests delivery
app/consumer/processor.py - Payment consumer → Retry publisher: publishes on failure
app/consumer/handler.py - Retry publisher → RabbitMQ: dispatches retry
app/consumer/retry.py - Payment consumer → Broker topology: configures retry queues
app/consumer/handler.py - Webhook delivery → Customer webhook: posts with backoff
app/consumer/webhook.py