SIKKIM STATE LOTTERY —
A Secure & Auditable Management Ecosystem
A custom high-performance distributed ledger verifying lottery ticket inventories, processing high-volume distributor uploads, and auditing winner payouts in sub-milliseconds.
Digitizing the Draw
Compliance Ledger
State-run lotteries in India are high-frequency, massive-volume distribution ecosystems. Every day, regional distributors allocate millions of ticket sequences to sub-agents, stockists, and retail outlets.
Historically, lottery compliance relied on paper registries. Distributors manually recorded unsold books, leaving state departments highly vulnerable to duplicate claims, ticket counterfeits, and "unsold frauds" where unissued winning tickets were surreptitiously claimed after draw announcements.
By designing a high-density, centralized ledger platform, we consolidated the entire operational lifecycle. Built with a robust Next.js 15 UI and backed by low-latency Express servers, this system parses multi-million row seller allocations and processes strict unsold exclusions at scale.
"We engineered the system to completely eliminate relational query loops, replacing flat row tables with compact, highly-indexed range sequences that handle millisecond checks.
Interactive Management Console
An intuitive and high-visibility portal engineered to verify drawings, manage distributor allocations, and monitor node health across the state network.
Core Management Engine
Scheme Configuration
Allocate alphanumeric serials, boundary digits, and draw frequencies dynamically for state scheme schedules.
Ledger Auditing
Performs instant B-Tree range scan calculations inside database overlaps, auditing unallocated blocks in under 8ms.
Consensus Nodes
Propagates connection allocations and synchronization blocks instantly to outpost stockists across state boundaries.
SHA-256 Audit Chains
Cryptographically links every distributor CSV transaction, database change, and winning payout in an unalterable log.

Ticket Upload Console
Import distributor unsold sheets and allocate seller lists instantly into state data arrays.
PostgreSQL B-Tree Ranges
Ticket series compressed into dynamic bounds cells, preventing duplicate or illegal draw claims.
Scheme Setup Module
Establish alphabet keys, numerical ranges, schedules, and prize allocations dynamically.
Create Scheme Form
Launches the structured CRUD configurator to register new lottery schemas in the ledger.
HMAC Access Logs
Restricts layout edits, distributor registrations, and drawing audits to authenticated users.
The Multi-Million Ticket Bottleneck
Distributor CSV File Timeouts
Daily distributor uploads containing over 1 million entries repeatedly exceeded maximum server timeouts, causing node worker memory overflows. Standard row-by-row imports locked database connections for minutes.
The "Unsold Fraud" Vector
Under strict government regulations, only tickets verified as "Sold" prior to the draw time are eligible for payouts. Querying individual row records to prove a winning serial was unsold exceeded 3.4 seconds under high server loads.
Database Storage Bloat
Storing each ticket as an individual database row inflated index sizes to over 100GB, causing slow-loading queries and locking transaction tables during peak draw times.
PostgreSQL JSONB Range Auditing
Instead of parsing tickets as individual database entities, ticket series are compressed into continuous ranges using advanced PostgreSQL JSONB indexing and customized range checks.
[{"start": 10000, "end": 99999}]JSONBSystem Topology & Ledger Pipeline
A high-performance pipeline mapping data ingestion, indexing compression, and live compliance verification.
Distributor CSV Ingest
Bulk uploads from state outlets containing ticket inventory allocations and unsold logs.
Active ParserExpress.js Validation API
Verifies parameters, parses alpha series sequences, and formats range boundaries.
Buffered PoolPostgreSQL JSONB Indexer
Compresses ticket series arrays into dynamic range cells using compact GIST indexes.
Linear StorageExclusion Validator
GIST indexed range audits perform real-time verification scans in under 8ms.
Audit SecuredEnterprise System Capabilities
Highly specialized modules designed for secure state-level draw operations.
Draw Scheme Configurator
Dynamic setup panel allocating alpha series tokens, numerical boundaries, digit formats, and overall draw ticket calculations for each lottery scheme.
Unsold Inventory Auditor
Direct CSV exclusion tool executing real-time ledger audits on unallocated ticket numbers to prevent claims fraud.
Winner Reporting Ledger
Advanced search interface validating sales status, and exporting multi-tier payout logs.
Regional States Manager
Full CRUD engine managing geographic lottery configurations and distributor quotas across Indian regions.
Official PDF Exporter & Immutable Audit Trails
Automated, government-approved PDF generator distributing verified weekly winning scheme results. Continuous logs tracking user administrative actions, distributor uploads, and database schema updates.
Sikkim Ledger Compliance Simulator
Interact with the live programmatic audit tools, range scanners, and node synchronizers running behind our secure database layer.
Control Board Modules

Algorithmic PostgreSQL Optimizations
How converting individual rows into compressed JSONB arrays reduced indexing footprints by 90% and query latencies by 99%.
SELECT * FROM unsold_tickets
WHERE series = '85A'
AND ticket_no = 73849;SELECT * FROM scheme_exclusions
WHERE series = '85A'
AND numeric_range @> 73849;Performance Benchmark Tests
| Operation / Metric | Traditional SQL | Optimized JSONB | Improvement |
|---|---|---|---|
| Storage Size (1M tickets) | 112.5 MB | 1.1 MB | 99% Compression |
| CSV Import Latency (1M) | 28.40 seconds | 0.14 seconds | 200x Faster |
| Unsold Range Check | 3,420 ms | 4.8 ms | 712x Faster |
| DB Lock During Upload | Full Table Lock | No Locks | Infinite Improvement |
| Connection Pool Overhead | 84% (High Risk) | 2% (Idle) | Safe Status |
Stakeholder Commission & Payout Chain
How lottery prize allocations split automatically from Government Treasury pools down to point-of-sale retailers.
State Treasury Pool
Government lottery funds secure the raw draw prize reserve.
State Distributor
Primary distributor (e.g. Himalayan Agency) processing fee.
Regional Sub-Stockist
Local wholesaler managing agent stocks.
Retail Seller Agent
Point-of-sale retailers receive a direct seller prize bonus.
Lucky Winner
Net prize payout processed directly into verified citizen banking ledger.
Immutable Draw Integrity & Anti-Fraud Protocols
A multi-tiered cryptographic validation stack securing drawing records and verifying distributor identities.
Verification & Check-Digit Calculations
Every ticket allocation is bound by a strict Luhn-based mathematical verification code. If ticket bounds or check-digits do not correlate exactly, distributors are locked from committing sequences.
SHA-256 Ledger Block Chaining
Each distributor upload and draw configuration creates an immutable, cryptographically chained block linked by SHA-256 hashes. Any post-draw manipulation attempts break the hash chain immediately.
HMAC Distributor Key Signatures
Distributor inventory lists are signed at the point of origin using private HMAC-SHA256 tokens. The State Authority verifies these payload keys before parsing the upload.
Audit Ledger Success Metrics
Quantified compliance outcomes achieved through architectural optimizations.
Audit Rigor
Eliminated payout errors and duplicate claims.
Validation Latency
Sub-millisecond inventory cross-checks.
Audited Tickets
Active drawings audited and recorded.
Payout Errors
Zero manual ledger validation slip-ups.