A Flask-based backend using MongoDB, session authentication, and live currency conversion with persistence of conversion history.
POST /signup)POST /login)Collections created automatically:
userssessionsrecordsCloudProject/
βββ app.py
βββ fx_api.py
βββ db.properties
βββ README.md
βββ requirements.txt
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
/Applications/Python\ 3.12/Install\ Certificates.command
db.properties)Example db.properties:
[DB]
prefix = mongodb+srv://
user = myUser
pwd = MyPassword123
dbUrl = cluster0.abcd1.mongodb.net
dbName = cloudProjectDB
params = ?retryWrites=true&w=majority&appName=CloudProject
python3 app.py
Server runs at:
http://127.0.0.1:5001
POST /signup
{
"username": "john",
"password": "123456"
}
{
"message": "User created",
"user_id": "uuid"
}
POST /login
{
"username": "john",
"password": "123456"
}
{
"message": "Login successful",
"session_id": "xxxxxxxx-xxxx"
}
POST /convert
session_id: your-session-id
{
"base_country": "United States",
"target_country": "Japan",
"amount": 100
}
{
"record_id": "uuid",
"base": "USD",
"target": "JPY",
"rate": 150.45,
"converted_amount": 15045,
"date": "2025-11-18"
}
GET /records
session_id: your-session-id
[
{
"record_id": "uuid",
"base": "USD",
"target": "JPY",
"amount": 100,
"converted_amount": 15045,
"rate": 150.45,
"date": "2025-11-18"
}
]
Missing session:
{"error": "Session expired or invalid"}
Missing fields:
{"error": "Missing base_country or target_country"}
Frankfurter API down:
{"error": "Currency API unavailable"}
POST β http://127.0.0.1:5001/signup
POST β http://127.0.0.1:5001/login
Copy the session_id
POST β http://127.0.0.1:5001/convert
Header:
session_id: {YOUR_SESSION}
GET β http://127.0.0.1:5001/records
Header:
session_id: {YOUR_SESSION}