fintech

module
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT

README ΒΆ

Fintech Platform

Fintech Platform Banner

A modern, event-driven fintech platform for learning, prototyping, and experimentation

Build Status Go Report Card Code Coverage Go Reference Go Version License

A modern, event-driven fintech platform for learning, prototyping, and experimentation.

This project demonstrates best practices in Go for building scalable, secure, and modular financial systems. It's designed for educational useβ€”explore event-driven architecture, clean code, and real-world fintech patterns in a safe, open-source environment.


  • Event-Driven: Built around events and asynchronous workflows.
  • Educational: Perfect for students, engineers, and fintech enthusiasts.
  • Modular: Explore accounts, currencies, transactions, and more.
  • Open Source: Use, modify, and contribute freely.

For Educational Purpose Only ⚠️


🏁 Features

  • 🌐 Multi-currency support
  • πŸ”„ Real-time exchange rates
  • πŸ’³ Stripe integration
  • πŸ”’ JWT authentication
  • 🧰 Unit of Work & Repository patterns
  • πŸ—οΈ Clean architecture & DDD

🧩 Event-Driven Architecture & Handler Design

This project uses a clean, DRY, and SRP-compliant event-driven architecture for all core flows (deposit, withdraw, transfer):

  • Event Bus Pattern: Handlers are registered for specific event types. The bus dispatches events to the correct handler, avoiding central switch/if logic.
  • SRP & DRY: Each handler is responsible for a single event type and business concern. Shared logic is factored into helpers or interfaces.
  • Flow-Agnostic Payment Initiation: Payment initiation is triggered by both deposit and withdraw validated events, without caring about the flow type. This is achieved by accepting both event types in the handler, with no flow-specific logic.
  • Cycle Detection: A static analysis tool (scripts/event_cycle_check.go) detects event cycles and is integrated into pre-commit hooks to prevent infinite event loops.
  • Consistent Logging: All handlers use structured, emoji-rich logging for clarity and traceability.
  • Legacy Cleanup: All legacy event types and handlers have been removed for clarity and maintainability.
  • Extensibility: New flows can be added by defining new event types and handlers, or by extending interfaces if logic is shared.

Design Lessons:

  • Prefer explicit handler registration over central switch/if statements for extensibility and SRP.
  • Use interfaces for shared event contracts when multiple event types trigger the same logic.
  • Only refactor to interfaces when you have multiple stable use cases (YAGNI principle).
  • Document handler design decisions to avoid "refactor ping-pong" between switch/if and abstraction.

See docs/service-domain-communication.md for more on service/domain boundaries.


🌊 Event Flow Overview

This project uses a robust event-driven architecture for all account flows (deposit, withdraw, transfer). Each business flow is modeled as a chain of domain events, with each handler responsible for a single step and emitting the next event in the chain.

Current Event Flows
  • Deposit:

    1. Deposit.Requested - Initial deposit request
    2. Deposit.CurrencyConverted - Deposit record created in database
    3. Deposit.Validated - Input validation completed
    4. Payment.Initiated - Payment processing started with provider
  • Withdraw:

    1. Withdraw.Requested - Initial withdraw request
    2. Withdraw.CurrencyConverted - Withdraw record created in database
    3. Withdraw.Validated - Input validation completed
    4. Payment.Initiated - Payment processing started with provider
  • Transfer:

    1. Transfer.Requested - Initial transfer request
    2. Transfer.CurrencyConverted - Conversion completed
    3. Transfer.Validated - Input validation completed
    4. Transfer.Completed - Transfer completed
Mermaid Diagram
flowchart TD
    subgraph Deposit
        DR[Deposit.Requested] --> DC[Deposit.CurrencyConverted]
        DC --> DV[Deposit.Validated]
        DV --> PI[Payment.Initiated]
    end
    subgraph Withdraw
        WR[Withdraw.Requested] --> WC[Withdraw.CurrencyConverted]
        WC --> WV[Withdraw.Validated]
        WV --> PI2[Payment.Initiated]
    end
    subgraph Transfer
        TR[Transfer.Requested] --> TV[Transfer.Validated]
        TV --> TC[Transfer.CurrencyConverted]
        TC --> TC[Transfer.Completed]
    end
Handler Responsibilities
  • Each handler is responsible for a single event type and emits the next event in the flow.
  • Handlers use structured, emoji-rich logging for traceability.
  • All event structs embed a common FlowEvent for shared fields (UserID, AccountID, CorrelationID, FlowType).
  • All IDs and correlation IDs use uuid.UUID.
Testing & Static Analysis
  • E2E event flow tests verify the full event chain for each flow.
  • Static analysis detects event cycles and is integrated into pre-commit hooks.
  • All handlers and event flows are covered by unit and integration tests.

πŸš€ Getting Started

See the full guide: docs/getting-started.md


πŸ’³ Stripe Connect Onboarding

The platform supports Stripe Connect for payment processing. To onboard a user as a Stripe Connect account:

  1. Initiate Onboarding

    POST /stripe/onboard
    Authorization: Bearer <your_jwt_token>
    

    This will return a URL to redirect the user to complete the Stripe Connect onboarding process.

  2. Check Onboarding Status

    GET /stripe/onboard/status
    Authorization: Bearer <your_jwt_token>
    

    Returns the onboarding status for the authenticated user.

Environment Variables

Configure the following in your .env file:

# Stripe Configuration
STRIPE_API_KEY=your_stripe_api_key
STRIPE_SIGNING_SECRET=your_stripe_webhook_secret
STRIPE_ENV=test  # or "development" or "production"
STRIPE_SUCCESS_PATH=http://localhost:3000/payment/stripe/success/
STRIPE_CANCEL_PATH=http://localhost:3000/payment/stripe/cancel/
STRIPE_ONBOARDING_RETURN_URL=http://localhost:3000/onboarding/return
STRIPE_ONBOARDING_REFRESH_URL=http://localhost:3000/onboarding/refresh

🧭 Documentation


πŸ… Contributing

See our guide: CONTRIBUTING.md


πŸ“„ License

This project is licensed under the MIT License.

Directories ΒΆ

Path Synopsis
cmd
cli command
server command
server/swagger
Package swagger Code generated by swaggo/swag.
Package swagger Code generated by swaggo/swag.
internal
pkg
app
Package app provides functionality for setting up and configuring the event Bus with all necessary event handlers for the application.
Package app provides functionality for setting up and configuring the event Bus with all necessary event handlers for the application.
commands
Package commands contains command DTOs for service and handler orchestration.
Package commands contains command DTOs for service and handler orchestration.
currency
Package currency provides functionality for working with currency codes and metadata.
Package currency provides functionality for working with currency codes and metadata.
dto
handler/conversion
Package conversion handles currency conversion events and persistence logic.
Package conversion handles currency conversion events and persistence logic.
money
Package money provides functionality for handling monetary values.
Package money provides functionality for handling monetary values.
money/v2
Package money provides functionality for handling monetary values.
Package money provides functionality for handling monetary values.
service
Package service provides business logic for the fintech application.
Package service provides business logic for the fintech application.
service/account
Package account provides business logic for interacting with domain entities such as accounts and transactions.
Package account provides business logic for interacting with domain entities such as accounts and transactions.
service/user
Package user provides business logic for user management operations.
Package user provides business logic for user management operations.
Package webapi provides HTTP handlers and API endpoints for the fintech application.
Package webapi provides HTTP handlers and API endpoints for the fintech application.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL