EasyBook
EasyBook is a user-friendly digital library designed for seamless access to a wide range of books. With EasyBook, users can effortlessly borrow books, request new titles, manage their profiles, upgrade to a premium account, and pay fines using cashless transactions.
2024
Website
Node.js, Express, MySQL, Midtrans, JWT, Cron
Problem
Traditional library circulation operations are frequently hindered by slow physical return queues, manual tracking of overdue loans, and error-prone cash fine collections that often cause bookkeeping discrepancies. Furthermore, members lack a structured platform to submit procurement requests for desired book titles, and institutions miss opportunities to monetize premium tier perks (e.g., expanded borrowing quotas). EasyBook was engineered as a digital library REST API engine that automates overdue fine invoicing and facilitates instant cashless settlements directly from the borrower’s device.
My role
I developed this platform as the Sole Backend Engineer (authoring 180+ commits in the perpus-service repository), handling server architecture, MySQL relational schema, third-party integrations, and scheduled automation jobs:
- Relational Database Design (MySQL): Designed comprehensive circulation models (
user,buku,kategori,kategori_buku,peminjaman,pembayaran,koleksi_pribadi,ulasan,request_buku). - Scheduled Automated Fining Engine: Created a background cron routine (
node-cron) executing daily at 09:00 WIB to flag overdue loans asterlambatand idempotently insert standard fine invoices (IDR 5,000) without duplicates. - Midtrans Cashless Integration: Implemented Midtrans Snap payment token generation and webhook handlers to support cashless fine settlement and instant membership tier upgrades.
- Stateless Authentication & Role Guards: Secured endpoints using JSON Web Tokens (JWT) enforcing role-based permissions across Borrowers/Members, Library Staff, and System Administrators.
- Automated Reporting & Notifications: Integrated
pdfkit-tableto compile monthly circulation audit summaries into downloadable PDF reports, and wirednodemailerto dispatch email return reminders to borrowers approaching their due dates.
System architecture
The backend operates as an isolated REST service ready for web and mobile frontends:
- Node.js Express Engine: Features modular routers (
/buku,/peminjaman,/pembayaran,/user,/request,/ulasan) handling JSON payloads and multipart book cover uploads (multer). - Midtrans Payment Gateway: Integrates digital wallets (GoPay, QRIS) and Virtual Account bank transfers. Upon payment confirmation, Midtrans webhooks trigger instant ledger updates and clear borrowing blocks.
- Background Cron Engine (
node-cron): Manages recurring lifecycle jobs independently from user HTTP requests. - MySQL Connection Pool: Utilizes
mysql2connection pooling to maintain low overhead during peak request spikes.
Key endpoints
| Method | Path | Function & Role |
|---|---|---|
POST |
/user/login & /user/register |
User authentication & JWT Bearer token issuance |
GET |
/buku & POST /buku |
Public book discovery / Staff catalog insertion |
POST |
/peminjaman |
Checkout physical book (atomic inventory decrement) |
PUT |
/peminjaman/kembali/:id |
Confirm return and calculate overdue penalties |
POST |
/pembayaran/bayar |
Request Midtrans Snap Token for fine or upgrade fees |
POST |
/pembayaran/notifikasi |
Webhook callback listener for Midtrans settlements |
POST |
/pembayaran/upgrade |
Submit request for Premium Membership tier |
POST |
/request |
Submit procurement requests for new book acquisitions |
GET |
/peminjaman/laporan-pdf |
Generate and export tabular circulation reports in PDF |
POST |
/ulasan |
Post star ratings and reviews on returned titles |
Technical challenges
1. Idempotent fine generation without duplicates. Daily automated cron scripts risk generating multiple duplicate invoices for the same overdue record if not strictly constrained. We enforced idempotency at the database query level using a subquery guard.
2. Physical inventory synchronization under concurrent requests. To avoid negative inventory counts, the borrowing endpoint checks book stock atomically before insertion. If available stock $>0$, the stock is decremented immediately; upon returned check-in, the quantity increments back into the pool.
3. Webhook signature validation & verification.
Because payment callbacks originate externally, raw parameters cannot be trusted blindly. The webhook handler cross-references order_id, gross_amount, and verified transaction statuses against internal database invoices before upgrading user privileges or clearing outstanding fines.
4. Dual payment settlement channels (Cash vs Cashless).
While digital transactions are handled via Midtrans, library members occasionally prefer settling fines physically at the circulation desk. A dedicated pembayaranTunai endpoint accessible exclusively to authorized staff enables manual verification with complete audit logging.
Future improvements
- Migrate raw SQL queries to a type-safe query builder or ORM (such as Prisma or Kysely) to improve code maintainability.
- Add physical Barcode / QR Code scanning integrations to streamline check-in and check-out workflows at physical counters.
- Move cron routines and heavy PDF report rendering into dedicated worker threads or background job queues.
Simulate Midtrans payment webhook lifecycle and idempotency defense against replay attacks or network retries.
POST /midtrans/webhook
Payload & SHA-512 Hash
Verify Signature
Midtrans API Double-Check
State Transition Guard
getOriginal('status')
DB::transaction
Assign Room & Invoice PDF
// System ready. Click one of the action buttons above to simulate.
Benchmark impact of compound index on 50,000 monthly bill records for midnight billing cron.
ref (Index Seek)
idx_user_bulan_tahun
1 row
0.002% of table
1.2 ms
99.2% faster
O(log N)
B+ Tree Traversal
View More Projects

Gamified educational community platform: Phaser mini-games (Kitty Attack), real-time score pipeline, and Top-10 leaderboards.
- Next.js
- Node.js
- Express
- +3

Flutter app for learning sign language with offline on-device AI detection and gamification.
- Flutter
- TensorFlow Lite
- MediaPipe
- +2

E-learning platform backend with Student and Collaborator profiles on Mejakita accounts.
- Node.js (Express)
- MySQL
- Git