How munal777/nprxchange-cli works
Project type and purpose
• nprxchange is a standalone, open-source CLI application written in Python.
• Its purpose is to convert Nepali Rupees (NPR) to other currencies using official NRB exchange rates, supporting both online fetches and offline cache.
Main architectural components
a. CLI Layer
• nprxchange/cli.py – parses command-line arguments (argparse) and/or launches interactive prompts (InquirerPy).
• Rich-based renderer for styled terminal output.
b. Core Conversion Logic
• nprxchange/converter.py – orchestrates the conversion calculation, takes NPR amount + target code, returns converted value.
c. API Layer
• nprxchange/api.py – HTTP client that fetches live rates from Nepal Rastra Bank API.
d. Storage (Cache) Layer
• nprxchange/storage.py – reads/writes a local cache (e.g., JSON or pickle file) for offline use.
e. External Dependencies & Services
• Python runtime, pip installation (setup.py)
• External libraries: requests (or httpx), Rich, InquirerPy
• Nepal Rastra Bank external API
Relationships and data flow
• User invokes nprxchange CLI → CLI Layer
→ If interactive: InquirerPy prompts → user selects amount & currency
→ CLI Layer calls Converter
→ Converter checks Storage:
– If cache is fresh/available → read from storage → return rate
– Otherwise → API Layer fetches rates → Storage updates cache → return rate
→ Converter applies exchange formula → returns result
→ CLI Layer passes result to Rich renderer → terminal output
Highlighted design principles & patterns
• Single Responsibility: each module (cli, converter, api, storage) has one job
• Layered architecture: CLI → Converter → (Storage ↔ API)
• Extensibility: clear module boundaries ease adding new features (e.g., new output formats)
• Offline-first strategy: transparent cache fallback
• [ ] Clear component names matching file names/modules
• [ ] Callouts for key technologies (Rich, InquirerPy, requests)
• [ ] Note of offline vs. online flow