Before setting up the project, ensure you have the following installed:
- Python 3.8 or higher
- MySQL
- MongoDB
- Git
- Clone the repository
git clone https://github.com/Wali-dev/SMS-management.git
cd SMS-management
cd backend
- Create and activate a virtual environment
# On Windows
python -m venv venv
venv\Scripts\activate
# On macOS/Linux
python3 -m venv venv
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
- Create a
.env
file in the root directory with the following variables:
SQL_DATABASE_URL=mysql://username:password@localhost/database_name
MONGODB_DATABASE_URL=mongodb://localhost:27017/database_name
JWT_SECRET_KEY=your_secret_key
- Set up the databases
- Create a MySQL database with the name specified in your
.env
file - Ensure MongoDB is running and accessible at the URL specified in your
.env
file
- Initialize the database tables
pyhton init_db.py
- Start the Flask application
python main.py
The backend will start running on http://localhost:5000
- Node.js 14.x or higher
- npm 6.x or higher
- Navigate to the frontend directory from the project root
cd frontend
- Install dependencies
npm install
- Start the development server
npm run dev
The frontend will start running on http://localhost:3000
This API allows you to manage SMS programs, track their performance metrics, and manage user accounts. The API is built using Flask, Flask-SQLAlchemy, and Flask-MongoEngine.
The API uses JWT-based authentication. Include the Authorization
header with a valid JWT token.
Endpoint: POST /program/create
Request:
{
"pair_name": "My Program",
"proxy": "proxy.example.com:8080",
"active_status": true,
"priority": 1,
"number_list": (file)
}
Response:
{
"message": "Pair created successfully",
"pair_id": "612a4b1c3b0b1c0b1c0b1c0b",
"pair": { ... }
}
Endpoint: PATCH /program/update/<pair_id>
Request:
{
"pair_name": "Updated Program",
"active_status": false,
"priority": 2,
"proxy": "new.proxy.example.com:8080"
}
Response:
{
"message": "Pair updated successfully",
"pair": { ... }
}
Endpoint: DELETE /program/delete/<pair_id>
Response:
{
"message": "Pair deleted successfully",
"pair_id": "612a4b1c3b0b1c0b1c0b1c0b"
}
Endpoint: POST /program/<operation>
Request:
{
"pair_name": "My Program"
}
Response:
{
"message": "Started processing pair",
"success": true
}
Endpoint: GET /program/pairs
Response:
[
{
"pairName": "My Program",
"activeStatus": true,
"priority": 1,
"proxy": "proxy.example.com:8080",
"sessionDetails": {},
"createdAt": "2023-08-15T12:34:56.789Z",
"numberListFile": { ... },
"pair_id": "612a4b1c3b0b1c0b1c0b1c0b"
},
{ ... }
]
Endpoint: GET /stats/<pair_name>
Response:
{
"message": "Stats retrieved successfully",
"stats": { ... }
}
Endpoint: GET /stats/aggregate
Response:
{
"message": "Aggregate stats retrieved successfully",
"stats": { ... }
}
Endpoint: POST /stats/dummy
Request:
{
"pair_name": "My Program",
"total_sms_sent": 1000,
"total_sms_failed": 100
}
Response:
{
"message": "Stats created successfully",
"stats": { ... }
}
Endpoint: GET /user/<user_id>
Response:
{
"username": "johndoe",
"password": "hashed_password",
"email": "[email protected]"
}
Endpoint: POST /user
Request:
{
"username": "johndoe",
"password": "password123",
"email": "[email protected]"
}
Response:
{
"message": "User created",
"userId": "612a4b1c3b0b1c0b1c0b1c0b"
}
Endpoint: POST /signin
Request:
{
"identifier": "johndoe",
"password": "password123"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjEyYTRiMWMzYjBiMWMwYjFjMGIxYzBiIiwiZXhwIjoxNjYyOTQ4NDAwfQ.BpOJ-SqJcPZmDlr6Nx5Lbr8uQe_AH8BxIbA3HWwD_XM"
}