ZenginLite

Gem Version update

A lightweight implementation of zengin-code/zengin-rb.

The name "zengin-lite" comes from the fact that it uses SQLite to store and query bank and branch data.

Rebuilt from scratch with focus on:

  • ⚡️ Fast startup time (5-10ms)
  • 💾 Low memory footprint (1MB)
  • 🔍 Flexible query capabilities

Performance & Trade-offs

This gem (zengin-lite) is designed as a lightweight alternative to zengin-rb.

When to use zengin-lite

  • Web Applications / API Servers: When you need to validate bank codes or look up branch names occasionally in user requests.
  • Memory Constrained Environments: Running on FaaS (AWS Lambda, etc.) or small containers where memory usage matters. zengin-lite keeps memory usage very low (~1MB) by querying SQLite on demand.

When to use zengin-rb

  • Batch Processing / Heavy Loops: If you need to iterate over thousands of banks/branches or perform bulk data processing.
  • Maximum Performance: zengin-rb loads all data into memory (Hash), offering microsecond-level access speed at the cost of higher memory usage (20MB+).

Installation

Add this line to your application's Gemfile:

gem 'zengin_lite'

Or install it yourself as:

$ gem install zengin_lite

Usage

require 'zengin_lite'

# Find bank and branch
bank = ZenginLite.bank("0001") # => #<ZenginLite::Bank code="0001" name="みずほ銀行" ...>
branch = bank.branch("001")    # => #<ZenginLite::Branch code="001" name="東京営業部" ...>

# Search banks
banks = ZenginLite.search_banks(name: "三井")

# Check existence (returns nil if not found)
ZenginLite.bank("9999") # => nil

For more detailed API documentation, please refer to the YARD documentation.

Data Source

This gem uses data from zengin-code/source-data, which is automatically updated daily.

Development

# Clone with submodule
$ git clone --recursive https://github.com/kromiii/zengin-lite.git
$ cd zengin-lite
$ bundle install

# Update source data and build database
$ git submodule update --remote
$ bundle exec rake db:build

# Run tests
$ bundle exec rake test

# Verify database integrity
$ bundle exec rake db:verify

# Build and install locally (database will be built automatically)
$ bundle exec rake install

# Generate documentation
$ bundle exec yard doc
$ open doc/index.html

License

The gem is available as open source under the terms of the MIT License.