Skip to content

Automated investment platform with Telegram bot, admin panel, and PagBank integration. Includes full flows for registration, finances, affiliate network, and support.

Notifications You must be signed in to change notification settings

issagomesdev/smart-option

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

68 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Smart Option β€” Telegram finance Bot

Node.js TypeScript Express.js Telegram PagBank JWT Next.js

About β€’ Features β€’ Technologies β€’ Structure β€’ Routes β€’ Getting Started β€’ Related Projects

Automated investment platform with Telegram bot, admin panel, and PagBank integration. Includes full flows for registration, finances, affiliate network, and support.

This repository contains the Telegram Bot and RESTful API developed in Node, responsible for all backend operations.

πŸ’» You can try the live demo at Bot on Telegram

⚠️ Important Notice:
This is a demonstration version intended for testing and preview purposes only.
Do not perform real transactions or payments.
The creator is not responsible for any real financial operations made using this demo.

πŸ“Œ About

SmartOption is a fully automated Telegram-based investment platform. It allows users to register, deposit funds, receive daily profits, manage their affiliate network, and get support β€” all through a conversational interface.

The project also includes an Admin Panel Repository built with Next.js + TypeScript for managing users, balances, withdrawals, and monitoring activity.

✨ Features

πŸ€– Telegram Bot

  • User registration and login system
  • Intuitive navigation menu
  • Integration with PagBank payment API
    • Used for product subscription and deposit transactions
    • Generates personalized payment links
    • Automatically updates transactions: releases product or credit when status becomes "PAID"
  • Automatic product expiration updates
    • Daily check for expired plans
    • Each plan is valid for 30 days after subscription
    • Checks user balance for automatic renewal
    • If the balance is sufficient, renews for another month; otherwise, user is marked as inactive
  • Daily profitability system
    • Only active users (with valid plans) receive daily earnings
    • Values depend on the product acquired and the user's current balance
  • Affiliate network system with 3 levels
    • Level 1: affiliates directly invited by the user
    • Level 2: affiliates invited by level 1 affiliates
    • Level 3: affiliates invited by level 2 affiliates
    • Users earn commissions from product subscriptions and daily earnings based on affiliates' balance
    • Users can have unlimited affiliates but only earn commissions from up to 9 (3 per level)
    • View your affiliate network, levels, and status through the "🚻 NETWORK" menu option
  • Finance menu
    • Deposit system (add funds to earn daily profitability)
    • Withdrawal system (request payouts anytime)
    • Balance transfer between users using the registered email
    • View current balance with your earnings
    • Complete transaction history with type, source, and date
    • Track status of deposit, withdrawal, and subscription requests
  • Automated support with escalation to human assistance

ℹ️ Active users are those with at least one valid plan. Plans expire 30 days after subscription.

🌐 Admin Panel API

  • Admin authentication and access control
  • Dashboard with system metrics and statistics
  • User data query and management
  • Management of requests for:
    • Deposits
    • Product subscriptions
    • Withdrawals
  • Affiliate network overview and management
  • Integration with PagBank API for automated transactions
  • Centralized support ticket management

πŸ› οΈ Technologies

  • Node.js – Backend runtime for the Telegram bot and API
  • TypeScript – Strongly typed JavaScript for safer and more scalable code
  • Express.js – Web framework for building the RESTful API
  • node-telegram-bot-api – Library for interacting with the Telegram Bot API
  • PagBank API – Payment gateway used for product subscriptions, deposits, and transaction tracking
  • Cron Jobs (node-cron) – For daily tasks like plan expiration checks and profitability updates
  • JWT (JSON Web Token) – Secure authentication for the admin panel

πŸ“ Structure

Overview of the main folders and files in the project:

πŸ“ src/                             # Main source directory
 ┣ πŸ“„ index.ts                      # Entry point

 ┣ πŸ“ bot/                          
 ┃ ┣ πŸ“„ index.ts                    
 ┃ ┣ πŸ“ components/                 
 ┃ ┃ ┣ πŸ“„ auth.ts                   # User login/register logic
 ┃ ┃ ┣ πŸ“„ mainMenu.ts               # Navigation menu
 ┃ ┃ β”— πŸ“„ index.ts                  # Entry for all components
 ┃ β”— πŸ“ sections/                   
 ┃   ┣ πŸ“„ affiliateLink.ts          # Affiliate link generator
 ┃   ┣ πŸ“„ balance.ts                # Financial menu flow
 ┃   ┣ πŸ“„ login.ts                  # Login flow
 ┃   ┣ πŸ“„ network.ts                # Affiliate network flow
 ┃   ┣ πŸ“„ products.ts               # Product subscription
 ┃   ┣ πŸ“„ register.ts               # Registration flow
 ┃   ┣ πŸ“„ rules.ts                  # Platform rules flow
 ┃   β”— πŸ“„ suport.ts                 # Support flow
 ┣ πŸ“ config/                       
 ┃ β”— πŸ“„ env.ts                      # Loads and exports .env variables

 ┣ πŸ“ db/                          
 ┃ ┣ πŸ“„ base.sql                    # Database file
 ┃ β”— πŸ“„ index.ts                   

 ┣ πŸ“ exceptions/                   # Global exception handling
 ┃ β”— πŸ“„ http.exception.ts           # Custom HTTP error classes

 ┣ πŸ“ server/                       # Backend API for admin panel
 ┃ ┣ πŸ“„ cron.ts                    
 ┃ ┣ πŸ“„ genKeys.ts                  
 ┃ ┣ πŸ“„ index.ts                   
 ┃ ┣ πŸ“ middlewares/                
 ┃ ┃ ┣ πŸ“„ auth.interceptor.ts       # JWT authentication middleware
 ┃ ┃ β”— πŸ“„ error.handler.ts         
 ┃ β”— πŸ“ routes/                     
 ┃   ┣ πŸ“„ auth.routes.ts            # Auth routes for admin
 ┃   ┣ πŸ“„ dash.routes.ts            # Dashboard statistics and summaries
 ┃   ┣ πŸ“„ index.ts                  # Router initialization
 ┃   ┣ πŸ“„ network.routes.ts         # Affiliate data and tree
 ┃   ┣ πŸ“„ requests.routes.ts        # Deposit, withdrawal, product requests
 ┃   ┣ πŸ“„ transactions.routes.ts    # Transaction monitoring
 ┃   ┣ πŸ“„ users.routes.ts           # Users management
 ┃   β”— πŸ“„ validateEmail.routes.ts   # Email verification logic

 β”— πŸ“ services/                     
   ┣ πŸ“„ authentication.service.ts   # Auth and session management
   ┣ πŸ“„ dash.service.ts             # Dashboard metrics
   ┣ πŸ“„ network.service.ts          # Affiliate network engine
   ┣ πŸ“„ requests.service.ts         # Deposit/product/withdrawal flow
   ┣ πŸ“„ users.service.ts            # User data manipulation
   β”— πŸ“ bot/                        # Services exclusive to the bot
     ┣ πŸ“„ auth.service.ts           # Bot-side auth services 
     ┣ πŸ“„ network.service.ts        # Affiliates network services 
     ┣ πŸ“„ products.service.ts       # Bot products services 
     ┣ πŸ“„ register.service.ts       # Bot-side registration services 
     ┣ πŸ“„ requests.service.ts       # Deposit, withdrawal, and subscription requests services 
     β”— πŸ“„ transactions.service.ts   # Financial transactions services 

πŸ“„ .env                             # Environment variable definitions
πŸ“„ .env.copy                        # Sample .env file
πŸ“„ confirm.html                     # Email confirmation template

πŸ“ Application Routes

πŸ” Auth Routes (/api/auth)

Method URI Description
POST / Login to the front panel
POST /token Token validation in the panel

πŸ‘€ Users Routes (/api/users)

Method URI Description
GET / List users (panel)
PATCH /update-user Update user data (panel)
PATCH /update-pass Update user password (panel)
GET /users-bot/:search Search users (bot) with a term
POST /users-bot Search users (bot) with filters
GET /user-bot/:id Get user data (bot)
POST /user-bot Register user (bot)
PATCH /user-bot Update user (bot)
DELETE /user-bot/:id Delete user (bot)
PUT /user-bot/:id/:status Activate/deactivate user (bot)
POST /transf-user-admin Transfer funds (admin β†’ bot user)

πŸ“Š Dashboard Routes (/api/dashboard)

Method URI Description
GET /users List users (bot)
GET /balance/:user_id/:product_id/:period Get balance filtered by user/product/period
GET /plans List plans/products

🌐 Network Routes (/api/network)

Method URI Description
POST /:id Get user's network

πŸ“‹ Requests Routes (/api/requests)

Method URI Description
GET /extract/:id Get user statement
POST /extract/:id Get filtered statement
POST /withdrawal/:id Withdrawal requests
POST /deposit/:id Deposit requests
POST /support/:id Support requests
POST /subscription/:id Product subscription requests
POST /res-withdrawal Approve or reject withdrawal requests
PATCH /was-read/:id/:status Mark support requests as read
GET /pendencies Get pending requests for response

πŸ’° Transactions Routes (/transactions)

Method URI Description
POST /checkouts/:reference_id Update pagbank checkouts route
POST /transfers/:reference_id Update pagbank pix transfers route

πŸ“§ Email Validation Route (/email/verify)

Method URI Description
GET /:token Email validation page

▢️ Getting Started

Follow these steps to run the project locally:

Prerequisites

  • Node.js (version 16 or higher recommended)
  • MySQL database
  • Telegram Bot Token (from BotFather)
  • PagBank API credentials

Installation

# Clone the repository
git clone https://github.com/issagomesdev/smart-option.git

cd smart-option

# Install dependencies
npm install
# or
yarn install

# Go to the "db" folder and import the "base.sql" file into your database.

# Copy the environment variables file and edit it
cp .env.copy .env
# Edit the .env file with your Telegram, database, and PagBank credentials

# Start the project
node src/index.ts

πŸ‘‘ Fontend (Admin Panel) repository here

About

Automated investment platform with Telegram bot, admin panel, and PagBank integration. Includes full flows for registration, finances, affiliate network, and support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published