Resurrecting Japan's Paper Jikokuhyo & Midori-no-Madoguchi Desk as a 100% Offline PWA with Kiro
This post was written as part of my submission to the **Kiroween 2026 hackathon* (Resurrection category).* Why Resurrect a Paper Railway Timetable in 2026? Before smartphone transit apps, rail travel in Japa
This post was written as part of my submission to the **Kiroween 2026 hackathon* (Resurrection category).*
Why Resurrect a Paper Railway Timetable in 2026?
Before smartphone transit apps, rail travel in Japan revolved around two artifacts: the thick printed railway timetable (Jikokuhyo / ๆๅป่กจ) and the staffed Midori-no-Madoguchi (ใฟใฉใใฎ็ชๅฃ) ticket counter, where station clerks flipped pages, circled boarding and alighting times in red grease pencil, warned travelers about tight platform transfers, and caught rail-pass pitfalls before issuing a perforated magnetic ticket (Kippu / ๅ็ฌฆ).
Today, live cloud apps have replaced bothโuntil your Shinkansen enters a mountain tunnel, you arrive at Narita Airport without a local SIM, or you cross a rural Hokuriku corridor with zero signal.
Inspired by my earlier Japan rail map project (trainjapan.me), I built TrainJapan Planner from scratch for Kiroween 2026 as a standalone, 100% offline-first PWA that brings back the tactile Jikokuhyo sheet, the classic Japanese Train Diagram (ๅ่ปใใคใค), and the station-master planning deskโwith zero backend and zero runtime API calls.
- Live Offline PWA: https://jia881.github.io/trainjapan-planner/
- Open-Source Repo (MIT): https://github.com/jia881/trainjapan-planner
What It Does
-
Deterministic Offline Routing Engine (
src/engine/):- Pure TypeScript earliest-arrival timetable search over a curated representative dataset (8 major Japanese rail corridors, 37 bilingual EN/JA stations, 104 daily services across 06:00โ22:30).
- Evaluates JR Pass coverage & surcharges (catching the classic Nozomi / Mizuho supplement trap and offering a covered-only Hikari / Sakura alternative).
- Scales realistic station transfer minimums across three instant Transfer Pace buttons (
0.8ร Brisk,1.0ร Standard,1.5ร Relaxed)โswitching Demo 2 (Tokyo โ Hakata) to1.5รimmediately reroutes around a tight 10-minute Shin-Osaka transfer.
-
Interactive Paper Jikokuhyo & Pure-SVG Train Diagram (ๅ่ปใใคใค):
- Authentic printed timetable grid with
ใฌ(pass-through),โฅ(bypassed),ๆ(all-reserved),JR, and+ยฅsymbols. Clicking any itinerary leg circles its boarding and alighting cells in red grease pencil (โ); clicking any stop cell lets you plan directly from that train (Plan from here). - Toggle to Train Diagram (ๅ่ปใใคใค) to view a zero-dependency Marey time-distance SVG chart where steeper Nozomi stringlines visibly overtake Hikari trains, with the selected leg highlighted in crimson.
- Authentic printed timetable grid with
-
Retro Kippu Slip, Inspection Stamp, & Zero-Backend Sharing:
- Printable
@media printticket slip, pure-CSS ๆนๆญๅ ฅ้ (ticket-gate inspection stamp) animation,localStorageoffline Saved Trips Pocket, and URL Hash sharing (#plan=STA_SHIN_OSAKA~STA_KANAZAWA~400~1~0) so travelers can share offline itineraries without any server.
- Printable
-
Verified True Offline Mode:
- A cache-first Service Worker (
public/sw.js) parsesindex.htmlduringinstallto precache hashed./assets/chunks immediately, plus a Tunnel Test (ใใณใใซๆจกๆฌ) toggle andnavigator.onLinelive indicator.
- A cache-first Service Worker (
How I Built It with Kiro (Specs + Steering + Hooks + Property Tests)
Because I built this solo as a university junior under a tight 36-hour sprint window alongside another competition deadline and upcoming finals, unstructured vibe-coding would have caused scope creep and broken edge cases. Kiro's Spec-Driven Development workflow kept the entire build disciplined across two iterations:
1. Steering Files Locked the Architecture Early (.kiro/steering/)
I defined three workspace steering documents up front:
-
product.mdโ enforced the Resurrection framing, single-feature depth, and honest framing of the bundled schedule as a curated representative reference timetable. -
tech.mdโ mandated Vite + React 19 + TypeScript (strict: true), integer minutes since00:00(preventingDate/timezone bugs), zero React/DOM imports insrc/engine/, and zero external network requests. -
structure.mdโ defined exact folder boundaries and three mandatory verification gates (validate:timetables,typecheck,test,build).
2. Iterative Spec-Driven Development (Two Complete Specs in .kiro/specs/)
-
Phase 1 Spec (
.kiro/specs/jikokuhyo-offline-planner/): Kiro generatedrequirements.mdin strict EARS syntax (WHEN ... THE SYSTEM SHALL ...),design.md(including Mermaid architecture and 14 formal correctness properties), and a wave-orderedtasks.md. -
Phase 2 Spec (
.kiro/specs/resurrection-polish/): Once the core PWA deployed cleanly, I added a second feature spec to plan and execute the SVG Train Diagram, Tunnel Test toggle, Kippu gate stamp, URL hash sharing, bidirectional grid clicking, andfast-checkproperty tests cleanly without breaking existing contracts.
3. Dual Kiro Agent Hooks Guarded Data & Engine (.kiro/hooks/)
Instead of relying on manual discipline, I wired two v1 PostFileSave Kiro hooks:
-
timetable-integrity.jsonโ watchessrc/data/.*\.json$and runsnpm run validate:timetables(checking monotonic timestamps, valid station references, direction ordering, and JR Pass rules). -
engine-test-guard.jsonโ watchessrc/engine/.*\.ts$and runsnpm testautomatically.
4. Model-Based Property Testing with fast-check
Using Kiro, I paired src/engine/router.ts against an independent brute-force earliest-arrival reference oracle in src/engine/__tests__/generators.ts and properties.test.ts (100 random iterations per property across generated multi-line interchange graphs), verifying:
- Earliest-arrival optimality vs. the independent oracle
- Strict determinism and transfer-pace monotonicity (
arrival(0.8ร) <= arrival(1.0ร) <= arrival(1.5ร)) - JR Pass coverage/surcharge summation consistency
- Round-trip integrity for both
SavedTrip(localStorage) andshareHashURL encoding
All 57 automated tests (34 unit/UI + 19 fast-check property tests + 4 Phase-2 integration tests) pass in ~2.5s locally and in GitHub Actions CI.
Verifying Offline Mode Yourself
- Open https://jia881.github.io/trainjapan-planner/ (or click Tunnel Test in the top bar for an instant preview).
- Open Chrome DevTools โ Network โ switch throttling to Offline.
- Reload the page: the Service Worker serves the entire app and timetable dataset locally (
OFFLINE MODE ACTIVE โ LOCAL TIMETABLE,0 API Calls / SW Active, zero console errors). - Switch between Jikokuhyo ๆๅป่กจ and Train Diagram ๅ่ปใใคใค, toggle 1.5ร Relaxed pace, stamp your Kippu, and test printing.
Takeaways
Using Kiro's Steering + two sequential Specs + Agent Hooks turned a 36-hour solo student sprint into a reproducible engineering pipeline: zero external dependencies, 57 passing tests including oracle-backed property tests, and an offline Japanese railway desk that resurrects the craft of paper timetables for modern travelers.
Check out the live app at jia881.github.io/trainjapan-planner and the full .kiro/ workflow at github.com/jia881/trainjapan-planner!
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.