How oprekable/bank-reconcile works
Project Type and Purpose
• This is a standalone Go-based CLI application (using Cobra) that performs:
• “sample” command – generates system and bank CSVs
• “process” command – reads CSVs, reconciles transactions, writes reports
• It employs a layered/hexagonal architecture with DI (Google Wire), unit tests (mockery), and SQLite as an embedded database.
Main Components
A. CLI Layer (Green)
1. Cobra Root & Commands
– cmd/root/root.go
– cmd/sample, cmd/process, cmd/version
2. CLI Handlers
– internal/app/handler/hcli/*
B. Service Layer (Blue)
– internal/app/service/{sample,process}
– business rules for sample generation & reconciliation
C. Repository Layer (Orange)
– internal/app/repository/{sample,process}
– imports data into SQLite, executes queries
D. Database (Gray)
– SQLite (via internal/pkg/driver/sql/sqlite.go)
– schemas & persistence
E. Parser Modules (Purple)
– internal/pkg/reconcile/parser
• banks/* (bca, bni, default)
• systems/default_system
F. Configuration & Utilities (Yellow)
– internal/app/config (app.toml, sqlite.toml, reconciliation.toml)
– internal/pkg/utils (file I/O, logging, shutdown)
G. Dependency Injection (Wire)
– internal/inject/wire_gen.go
Relationships & Data Flows
• User → CLI Layer:
• Enters “bank-reconcile sample” or “process”
• CLI Layer → Handler:
• Parses flags, constructs input DTOs
• Handler → Service:
• Calls SampleService.Generate, ProcessService.GenerateReconciliation
• Service ↔ Repository:
• SampleService writes generated data to CSV (FileSystem)
• ProcessService:
– Reads CSV via Parser Modules → transforms into domain entities
– Calls Repository to import into DB
– Calls Repository to run reconciliation queries
– Retrieves summary & unmatched sets
• Repository ↔ Database:
• Executes SQL via sqlite driver
• Service → Reports:
• Exports matched/unmatched CSV reports via FileSystem
• Throughout all layers, components for logging, error handling, profiling, and shutdown are invoked.
Architectural Patterns & Principles
• Clean/Hexagonal Architecture: clear separation between CLI, Use Cases (Service), Persistence (Repository), and External Systems (FS, DB)
• Dependency Injection via Wire: decouples construction of handlers, services, repositories
• Repository Pattern: abstracts database operations
• Single-Responsibility: each package/folder has distinct concern (handler, service, repository, parser, config)
• Mockability: interfaces in each layer (under _mock) enable high test coverage