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.
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.
- 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 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
- 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
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
Method | URI | Description |
---|---|---|
POST | / |
Login to the front panel |
POST | /token |
Token validation in the panel |
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) |
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 |
Method | URI | Description |
---|---|---|
POST | /:id |
Get user's network |
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 |
Method | URI | Description |
---|---|---|
POST | /checkouts/:reference_id |
Update pagbank checkouts route |
POST | /transfers/:reference_id |
Update pagbank pix transfers route |
Method | URI | Description |
---|---|---|
GET | /:token |
Email validation page |
Follow these steps to run the project locally:
- Node.js (version 16 or higher recommended)
- MySQL database
- Telegram Bot Token (from BotFather)
- PagBank API credentials
# 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