Streamlit app for South African home-loan Q&A with offline affordability calculator
# 🏠AI Home Loan Assistant (South Africa)
Live Link:
ai-home-loan-assistant-irnx…
A simple Streamlit app where you can ask home-loan questions and get clear answers. It supports:
- Online mode (OpenAI GPT-4o-mini)
- Offline mode (no API required): affordability calculator + quick FAQs
## Demo Screenshots
Place screenshots in the `screenshots/` folder and they will appear below automatically.
- Home screen:
- Offline affordability result:
> Tip: You can take screenshots with Shift+Cmd+4 (macOS) and save them into the `screenshots/` folder as `home.png` and `offline-affordability.png`.
---
## 1) Requirements
- Python 3.9+ (Python 3.13 works too)
- pip (or use `python3 -m pip` on macOS)
Install dependencies:
```bash
python3 -m pip install -r requirements.txt
```
---
## 2) Configure your OpenAI API key (optional)
If you plan to use online AI answers:
1. Get a key at
platform.openai.com
2. Add it to `.env`:
```
OPENAI_API_KEY=sk-...your_key_here...
```
Security:
- Never commit real keys to GitHub (this repo’s `.gitignore` already ignores `.env`).
- You may need to add billing to use the API:
platform.openai.com
> If you don’t have an API key or billing, just use the app in Offline mode (see below).
---
## 3) Run the app
From the project folder:
```bash
streamlit run app.py
```
If `pip` is not found or Streamlit doesn’t start, use:
```bash
python3 -m streamlit run app.py
```
Open the URL shown in the terminal (usually
localhost). If it doesn’t open, try:
-
127.0.0.1
- Or run on a different port:
```bash
python3 -m streamlit run app.py --server.port 8502
```
---
## 4) Using the app
- In the left sidebar, toggle **Offline mode (no API)** ON to avoid OpenAI usage.
- Ask an affordability question including your monthly income, e.g.:
- “I earn R20,000 per month — how much can I borrow?”
- Adjust assumptions in the sidebar:
- Interest rate …