A simple, well-documented currency converter built with Python and Streamlit. It fetches live exchange rates from ExchangeRate-API, caches responses for efficiency, and provides an interactive web UI plus a minimal CLI-style script for quick testing.
Key highlights:
- Real-time exchange rates via ExchangeRate-API
- In-memory caching of rates (3-hour TTL) using
cachetools - Clean Streamlit interface (
src/run.py) for quick demos
Open src/run.py with Streamlit to see the UI locally. Add screenshots or a short GIF to this section later for a repository showcase.
Create and activate a virtual environment (recommended):
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activateInstall dependencies:
pip install requests cachetools streamlitSet your ExchangeRate-API key (example):
PowerShell (Windows):
$Env:API_KEY = "your_api_key_here"macOS / Linux:
export API_KEY="your_api_key_here"Run the Streamlit app:
cd src
streamlit run run.pyThe app opens in your browser where you can choose base/target currencies and convert amounts.
src/constant.py— List of supported currency codes (CURRENCIES).src/currency_convertor.py— Core functions:get_exchange_rate()andconvert_currency().src/run.py— Streamlit app UI and orchestration.src/main.ipynb— Notebook used for development or demonstration.
- API endpoint used:
https://v6.exchangerate-api.com/v6/{API_KEY}/latest/{base_currency} - Caching: in-memory TTLCache (
ttl=3*60*60) reduces duplicate API calls. - Make sure
API_KEYis set in the environment before running.
- If the app shows an error fetching exchange rates, confirm the
API_KEYvalue and network connectivity. - If unexpected currency results appear, validate the currency code against
src/constant.py.
- Add a
requirements.txt(runpip freeze > requirements.txt) to make installs reproducible. - Include a short demo GIF or screenshots in the repository root and reference them under Demo.
- Add a
LICENSEfile (e.g., MIT) and a briefCONTRIBUTING.mdif you welcome contributions.
Contributions are welcome. For small fixes or docs improvements, open a PR. For larger changes, please open an issue first to discuss the approach.
This project is available under the MIT License — see the LICENSE file.
requirements.txt— pinned dependency list for quick installsLICENSE— MIT licenseCONTRIBUTING.md— contribution guidelinesDockerfile— container image to run the Streamlit appassets/— place demo screenshots or GIFs here (seeassets/README.md)
Install from requirements.txt:
pip install -r requirements.txtRun locally (Streamlit):
cd src
streamlit run run.pyBuild and run with Docker:
docker build -t currency-converter:latest .
docker run -p 8501:8501 currency-converter:latest