# GetMeACoffee CLI

> A terminal-based creator tipping tool that integrates Khalti payments, allowing users to send virtual coffees, attach messages, and track contributions directly from the command line.

Case study: https://sushandahal.com.np/work/get-me-a-coffee-cli

Author: Sushan Dahal

Role: Solo Developer

Status: Learning Project

Technologies: Node.js, JavaScript, Express.js, SQLite, Khalti ePayment API, Node.js Readline

## Problem

Most creator-support platforms rely on graphical web interfaces. This project explores whether developers can support creators directly from their terminals while still using a conventional payment gateway. The main technical challenge is bridging CLI interactions with external payment flows and maintaining trustworthy transaction records.

## Contribution

Independently developed a command-line tipping application with a Node.js CLI, Express backend, and SQLite database. Integrated Khalti's ePayment API for payment initiation and verification, implemented username-based creator registration, contribution tracking, and backend rate limiting.

## Approach

- Built an interactive command-line interface using Node.js and readline/promises.
- Implemented username-based creator registration and lookup.
- Developed Express API endpoints for registration, contributions, payment verification, and contribution history.
- Integrated Khalti ePayment API v2 to initiate payments and generate payment links.
- Used Khalti's payment lookup API to verify transaction status before marking contributions as completed.
- Stored creator information and contribution records in SQLite without an ORM.
- Supported anonymous contributions with optional sender names and messages.
- Added rate limiting to sensitive endpoints and documented a sandbox testing workflow.

## Decision

Separated the terminal interface from payment processing by using an Express backend. Chose SQLite for lightweight persistence and Khalti's hosted payment flow to avoid collecting sensitive payment credentials directly in the CLI.

## Tradeoff

Using a hosted payment gateway means users must leave the terminal to complete payment in a browser. The architecture also requires a running backend service, rather than operating as a completely standalone CLI. These compromises kept payment processing outside the terminal and made the integration easier to reason about.

## Outcome

Built a functional CLI prototype supporting creator registration, username-based tipping, payment initiation, transaction verification, and contribution history. Published the source code with a demonstration GIF and Khalti sandbox setup instructions.

## Lessons

Learned how to design interactive command-line applications and connect them to external services. Gained practical experience with payment initiation, server-side transaction verification, API design, lightweight persistence, and protecting financial workflows from untrusted client responses.

Interface illustrations on the case-study page explain the concept; they are not project screenshots.

Source: https://github.com/Sushan2589/GetMeACoffee-CLI
