How mamangrust/payment-gateway-axum works
Main Components
A. API Layer (Axum Web Server)
• Entry point through main.rs
• Handler layer (/src/handler/*)
• Middleware layer (/src/middleware/*)
B. Business Logic Layer
• Services layer (/src/services/*)
• Abstract traits (/src/abstract_trait/*)
• Domain models
• Request models (/src/domain/request/*)
• Response models (/src/domain/response/*)
C. Data Access Layer
• Repository layer (/src/repository/*)
• Entities (/src/entities/*)
• Database migrations (/migration/*)
D. Cross-Cutting Concerns
• Configuration (/src/config/*)
• Utils (/src/utils/*)
• State management (/src/state.rs)
• [Client/External Systems]
• ↓
• [API Layer (Axum)]
• ↓
• [Business Logic Layer]
• ↓
• [Data Access Layer]
• ↓
• [Database]
Component Relationships
• HTTP requests flow through middleware (JWT authentication) to handlers
• Handlers communicate with services
• Services implement abstract traits
• Services use repositories for data access
• Repositories work with entities
• All components can access utils and config
Specific Features to Highlight
Financial Operations:
• Top-up flow
• Transfer flow
• Withdrawal flow
• Balance (Saldo) management
• User management
• Authentication/Authorization
Technical Details
Framework & Libraries:
• Axum (Web Framework)
• Sea-ORM (Database ORM)
• JWT Authentication
• Database Migrations
Additional Elements
Supporting components:
• Error handling system (/src/utils/errors.rs)
• Dependency injection system (/src/utils/di.rs)
• Logging system (/src/utils/log_tracing.rs)
• Payment validation (/src/utils/payment_method_validator.rs)
Testing Architecture
A separate section for:
• Integration tests
• Unit tests
• Repository tests
• Service tests
Clear boundaries between components
Remember to:
• Notes for critical components
• Both synchronous and asynchronous flows
• Security boundaries
• Error handling paths
This architecture follows a typical clean architecture pattern with clear separation of concerns, making it important to show the independence of business logic from external concerns while maintaining clear dependency rules flowing inward from controllers through use cases to entities.