Skip to content

Wali-dev/SMS-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

API Documentation

BACKEND & FRONTEND

Table of Contents

Setup

Backend Setup

Backend Prerequisites

Before setting up the project, ensure you have the following installed:

  • Python 3.8 or higher
  • MySQL
  • MongoDB
  • Git

Backend Installation

  1. Clone the repository
git clone https://github.com/Wali-dev/SMS-management.git
cd SMS-management
cd backend
  1. 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
  1. Install dependencies
pip install -r requirements.txt

Backend Configuration

  1. 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
  1. 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

Running the Backend

  1. Initialize the database tables
pyhton init_db.py
  1. Start the Flask application
python main.py

The backend will start running on http://localhost:5000

Frontend Setup

Frontend Prerequisites

  • Node.js 14.x or higher
  • npm 6.x or higher

Frontend Installation

  1. Navigate to the frontend directory from the project root
cd frontend
  1. Install dependencies
npm install

Running the Frontend

  1. Start the development server
npm run dev

The frontend will start running on http://localhost:3000

Introduction

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.

Authentication

The API uses JWT-based authentication. Include the Authorization header with a valid JWT token.

Program Management

Create Program

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": { ... }
}

Update Program

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": { ... }
}

Delete Program

Endpoint: DELETE /program/delete/<pair_id> Response:

{
  "message": "Pair deleted successfully",
  "pair_id": "612a4b1c3b0b1c0b1c0b1c0b"
}

Start/Stop/Restart Program

Endpoint: POST /program/<operation> Request:

{
  "pair_name": "My Program"
}

Response:

{
  "message": "Started processing pair",
  "success": true
}

Get All Programs

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"
  },
  { ... }
]

Statistics

Get SMS Stats for a Program

Endpoint: GET /stats/<pair_name> Response:

{
  "message": "Stats retrieved successfully",
  "stats": { ... }
}

Get Aggregate Stats

Endpoint: GET /stats/aggregate Response:

{
  "message": "Aggregate stats retrieved successfully",
  "stats": { ... }
}

Create Dummy Stats

Endpoint: POST /stats/dummy Request:

{
  "pair_name": "My Program",
  "total_sms_sent": 1000,
  "total_sms_failed": 100
}

Response:

{
  "message": "Stats created successfully",
  "stats": { ... }
}

User Management

Get User

Endpoint: GET /user/<user_id> Response:

{
  "username": "johndoe",
  "password": "hashed_password",
  "email": "[email protected]"
}

Create User

Endpoint: POST /user Request:

{
  "username": "johndoe",
  "password": "password123",
  "email": "[email protected]"
}

Response:

{
  "message": "User created",
  "userId": "612a4b1c3b0b1c0b1c0b1c0b"
}

Sign In

Endpoint: POST /signin Request:

{
  "identifier": "johndoe",
  "password": "password123"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjEyYTRiMWMzYjBiMWMwYjFjMGIxYzBiIiwiZXhwIjoxNjYyOTQ4NDAwfQ.BpOJ-SqJcPZmDlr6Nx5Lbr8uQe_AH8BxIbA3HWwD_XM"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published