cp-atm
v2.2.1
Published
Creating a Simple ATM Machine Using Typescript, Node.js, Inquirer and Chalk
Downloads
14
Readme
ATM Machine (CLI)
A simple interactive command-line ATM simulator written in TypeScript and Node.js. It demonstrates a minimal ATM workflow including PIN authentication, deposit, withdrawal, fast cash options, balance check, and exit.
This project is intended as a small demo or learning project using inquirer for prompts and chalk for colored console output.
Features
- PIN authentication (sample user account is hard-coded for demo)
- Deposit funds
- Withdraw funds with balance checks
- Fast cash quick-withdraw options (1000, 2000, 5000, 10000)
- Check account balance
- CLI exit option
Quick start
Prerequisites: Node.js 18+ and npm.
- Install dependencies:
git clone https://github.com/cr33p1ngp4ck3t/ATM-Machine.git
npm install- Build (if using TypeScript source):
npm run build- Run locally (from project root):
node dist/index.jsOr run the TypeScript source directly with ts-node (if installed):
npx cp-atmUsage
When you run the app you'll be prompted to enter a 4-digit PIN. The demo user is configured in src/index.ts as:
- id:
123456 - pin:
1234 - starting balance:
10000
After entering the correct PIN you will be shown an operation menu with choices:
- Deposit — enter an amount to add to the balance
- Withdrawal — enter an amount to withdraw (balance will be checked)
- Fastcash — choose a preset amount to withdraw (1000, 2000, 5000, 10000)
- Check Balance — show current balance
- Exit — quit the app
The app validates numeric inputs and will print error messages for invalid amounts or insufficient funds.
Project layout
package.json— project metadata and dependenciessrc/index.ts— TypeScript source with the ATM logic and CLIindex.js— compiled JavaScript entry (executable)
Bin / CLI
This package sets dist/index.js as a binary (bin field in package.json), so after building and installing globally it can be run as a CLI.
Example (install globally):
npm install -g .
atm-machine # or the package name `cp-atm` depending on package.json 'name'Note: The package name in package.json is cp-atm and the bin points to dist/index.js.
Development notes
- The user account is hard-coded for demonstration. For production-ready behavior you'd replace this with persistent storage and secure PIN handling.
- Input validation is basic; consider adding stricter checks and unit tests.
- To add more users or features, extend the
Usermodel insrc/index.tsand update the authentication flow.
Contributing
Feel free to open issues or PRs to improve the demo. Suggested enhancements:
- Persist user accounts (file or database)
- Add unit tests
- Better CLI UX and localization
License
ISC
