This commit introduces new transaction routes for handling various transaction-related operations. It also includes updates to the `config.py` file to support these new features.
The following files were modified:
- `README.md`: Updated documentation to clarify .env variables and their purposes
- `To-Do.md`: Updated task meaningless
- `config.py`: Added COLLECT_COOLDOWN and TAX_ACCOUNT_BID configurations.
Main Thing:
- `interbend/routes/transaction_routes.py`:
Added boilerplate transaction to handle all transfers and separated business transfers with tax application.
/transfer for personal transfers
/transfer-business for business transfers with tax deduction
TODO: add route to change tax rate and add non hardcoded tax rate.
Type 6 and 7 are reserved for future use. currently implemented are 0 and 1.
|
||
|---|---|---|
| interbend | ||
| .gitignore | ||
| config.py | ||
| README.md | ||
| run.py | ||
| To-Do.md | ||
Interbend API
Interbend is a Flask-based web application that provides a backend API for managing user balances and transactions. It features a robust authentication system using JWT and includes a separate set of administrative endpoints for system management. The application is designed to be extensible and can be used as a foundation for a variety of financial applications.
Installation
-
Clone the repository:
git clone https://github.com/your-username/interbend.git cd interbend -
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate -
Install the dependencies:
pip install Flask python-dotenv mysql-connector-python PyJWT -
Set up the environment variables: Create a
.envfile in the root directory of the project and add the following variables:JWT_KEY=your_secret_jwt_key JWT_EXPIRATION=30 // jwt experation duration in days DB_HOST=your_database_host DB_USER=your_database_user DB_PASSWORD=your_database_password DB_NAME=your_database_name ADMIN_KEY=your_secret_admin_key COLLECT_COOLDOWN=24 // collect cooldown in hours TAX_ACCOUNT_BID=BUSINESS_BID_HERE // tax account bid here
Usage
To start the application, run the following command in the root directory of the project:
python run.py
The application will start in debug mode on http://127.0.0.1:5000.
API Endpoints
Authentication
-
POST /register: Creates a new user account.- Request Body:
{ "username": "testuser", "email": "test@example.com", "password": "password123" } - Response: Sets a JWT token in an HTTP-only cookie and returns a success message.
- Request Body:
-
POST /login: Logs in a user.- Request Body:
{ "bid": "your_user_bid", "password": "password123" } - Response: Sets a JWT token in an HTTP-only cookie and returns a success message.
- Request Body:
Transactions
-
GET /balance?bid=<user_bid>: Retrieves the balance of a user.- Response:
{ "balance": 100.00 }
- Response:
-
POST /collect: Collects the salary for the authenticated user.- Authentication: JWT token required.
- Response: A success message and the new balance.
-
POST /transfer: Transfers a specified amount from the authenticated user to another user.- Authentication: JWT token required.
- Request Body:
{ "to": "recipient_bid", "amount": 50.00, "note": "Payment for services" } - Response: A success message.
Admin
All admin endpoints require an admin key in the request body.
-
POST /admin/set-job: Sets the job for a user.- Request Body:
{ "bid": "user_bid", "job": 1, "key": "your_admin_key" } - Response: A success message.
- Request Body:
-
POST /admin/add-money: Adds money to a user's account.- Request Body:
{ "bid": "user_bid", "amount": 100.00, "key": "your_admin_key" } - Response: A success message.
- Request Body:
-
POST /admin/change-password: Changes the password for a user.- Request Body:
{ "bid": "user_bid", "password": "new_password", "key": "your_admin_key" } - Response: A success message.
- Request Body: