This project simulates a reward system where users receive gift cards for paying their last 3 credit card bills on time.
- Create Users, Bills, and Rewards
- Record bill payments with payment date
- Track each billβs due date and payment date
- Reward users with a mock gift card if their last 3 bills are paid on or before the due date
- Homepage endpoint displaying a welcome message
- RESTful API built with FastAPI + SQLite or PostgreSQL
- Python 3.10+
- FastAPI (API framework)
- SQLAlchemy (ORM)
- SQLite (for local dev) / PostgreSQL (for persistent cloud deployment)
- Uvicorn (server)
git clone https://github.com/codedtt/Rewarding-System.git
cd bon-rewardspython -m venv venv
Activate it:
Windows (PowerShell):
.\venv\Scripts\activate
Linux / Mac:
source venv/bin/activatepip install -r requirements.txtAPI (Hosted on Render): π (https://rewarding-system.onrender.com/)
Running Locally:
uvicorn app:app --reload
API will be available at π (http://127.0.0.1:8000)
Docs: (http://127.0.0.1:8000/docs)π Homepage
The root endpoint displays a welcome message:
{
"message": "π Welcome to the BON Rewards App! Pay your bills on time and earn rewards!"
}
π API Endpoints π€ Users
-
POST /users/ β Create a user
-
GET /users/ β List all users
π§Ύ Bills
-
POST /bills/ β Create a bill (define due_date)
-
GET /bills/ β List all bills
π³ Payments
-
POST /payments/ β Pay a bill
-
Requires bill_id, user_id, payment_date
π Rewards
- GET /rewards/ β List all rewards
Reward automatically generated when last 3 bills are paid on/before due date.
π§ͺ Example Test Flow
-
Create User
-
Create 3+ Bills
-
Pay Bills on time
-
Check Rewards endpoint
π Notes
-
Rewards are mocked ($10 Amazon Gift Card).
-
Bills are evaluated based on due_date, not bill IDs.
-
Only the last 3 consecutive bills determine reward eligibility.
-
Use PostgreSQL for persistent cloud deployment; SQLite is suitable for local development only.