Architecture & Core Parsing Engine
High-throughput, zero-allocation financial transaction ledger parser using Go Standard Library Only.
Section 0: The "Why" & Core Vocabulary
บททดสอบใหญ่ส่งท้าย Phase 1: การสร้าง CLI Financial Ledger & Event Journal Parser สำหรับอ่านและตรวจสอบความถูกต้องของไฟล์ประวัติธุรกรรม (Transaction Log) ขนาดใหญ่ในระบบ Core Banking โดยมีข้อบังคับระดับวิศวกรรมคือ Zero Third-Party Dependencies (ใช้เฉพาะ Go Standard Library ล้วน)
The Spring Batch & Jackson Trap We Are Overcoming
ในระบบ JVM แบบดั้งเดิม การประมวลผล Batch Ledger มักใช้ Spring Batch ร่วมกับ Jackson CSV/JSON ItemReader ซึ่งอาศัย Reflection, สตรีม Object ขนาดใหญ่ข้าม Thread, และแปลงตัวเลขเป็น BigDecimal ส่งผลให้สูญเสีย RAM ไปกับ Object Metadata และเกิด Latency จาก Garbage Collection เมื่อต้อง Audit ไฟล์ขนาด 5GB–20GB
ใน Deliverable นี้ เราจะรวบรวมทักษะจาก Day 2 (Alignment), Day 7 (Errors), Day 10 (Interfaces), Day 11 (Layout), Day 12 (bufio), และ Day 13 (Zero-Alloc Ingestion) มาสร้าง Parser ที่รันเสร็จในหน่วยเสี้ยววินาทีด้วยหน่วยความจำคงที่ O(1)!
Architecture Vocabulary Reference
int64 แทน float64 เพื่อป้องกัน IEEE-754 Rounding Error
[]byte ดั้งเดิมด้วย bytes.IndexByte โดยไม่มีการสร้าง String ชั่วคราวบน Heap
Performance Comparison: Go vs Legacy JVM Frameworks
Section 1: Project Blueprint & Layout
โครงสร้างโปรเจกต์ของ Deliverable นี้จัดเรียงตาม Standard Go Project Layout ที่ได้เรียนรู้ใน Day 11 อย่างเคร่งครัด:
ledger-parser/
├── go.mod
├── cmd/
│ └── ledger-cli/
│ └── main.go # Composition Root รับ Input File
└── internal/
└── ledger/
├── model.go # Structs ที่ผ่าน Memory Aligned
├── parser.go # Core Streaming Engine
├── validator.go # Bitmask Validation Rules
└── parser_test.go # Unit Test ครอบคลุมการทำงาน
TXID,TIMESTAMP,ACC_SRC,ACC_DST,AMOUNT_CENTS,CURRENCY
TX-10001,1711920000,ACC-8801,ACC-9902,500000,THB
TX-10002,1711920001,ACC-3301,ACC-4402,125050,THB
TX-10003,1711920002,ACC-5501,ACC-6602,-9900,USD