This document compares the application size and dependencies between the initial implementation (main branch) and the refactored clean architecture (task-session-2 branch).
Binary Size:
$ du -sh kasir-api
7.9M kasir-apiDependencies:
module kasir-api
go 1.25.6Characteristics:
- Zero external dependencies
- Pure standard library implementation
- Monolithic structure (single file)
- Smaller binary size
Binary Size:
$ du -sh bin/kasir-api
15M bin/kasir-apiDependencies:
module kasir-api
go 1.25.6
require (
github.com/jackc/pgx/v5 v5.8.0
github.com/knadh/koanf/parsers/dotenv v1.1.1
github.com/knadh/koanf/providers/env/v2 v2.0.0
github.com/knadh/koanf/providers/file v1.2.1
github.com/knadh/koanf/v2 v2.3.2
github.com/pressly/goose/v3 v3.26.0
)
require (
// ... 17 indirect dependencies
)Dependency Stats:
go.mod: 32 linesgo.sum: 77 lines- Total: 109 lines
Characteristics:
- 6 direct dependencies
- 17 indirect dependencies
- Layered architecture (domain, repository, service, handler)
- PostgreSQL support with connection pooling
- Configuration management (.env support)
- Database migrations with goose
- Larger binary size due to additional features
| Metric | Main | Task-Session-2 | Increase |
|---|---|---|---|
| Binary Size | 7.9M | 15M | +7.1M (90%) |
| Direct Dependencies | 0 | 6 | +6 |
| Total Dependencies | 0 | 23 | +23 |
-
pgx/v5 (PostgreSQL driver) - ~4-5M
- Full-featured PostgreSQL driver
- Connection pooling
- Prepared statements support
-
koanf (Configuration) - ~1-2M
- Environment variable parsing
- .env file support
- Multiple providers
-
goose (Migrations) - ~1-2M
- Migration management
- Up/Down migration support
- Version tracking
✅ Smaller binary (7.9M) ✅ Zero dependencies ✅ Faster compilation ✅ Simpler deployment
✅ Clean architecture (maintainable) ✅ SOLID principles ✅ PostgreSQL support ✅ Database migrations ✅ Configuration management ✅ Testable design ✅ Production-ready features
If binary size is critical, you can:
-
Build with compression:
go build -ldflags="-s -w" -o bin/kasir-api ./cmd/api/ upx --best --lzma bin/kasir-apiExpected size: ~5-6M (60% reduction)
-
Remove unused features:
- Use in-memory only (remove pgx)
- Use environment variables only (remove koanf)
- Manual migrations (remove goose)
-
Use standard library alternatives:
database/sqlwithlib/pq(smaller than pgx)os.Getenv()instead of koanf- Custom migration runner
The 90% size increase (7.9M → 15M) is justified by:
- Production-ready database support
- Professional configuration management
- Automated migration system
- Clean, maintainable architecture
- Comprehensive test coverage
For production applications, the additional 7.1M is a worthwhile trade-off for maintainability, testability, and feature completeness.