├── requirements.txt ├── vercel.json ├── api └── app.py ├── README.md └── index.php /requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | pymongo 3 | python-dateutil -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { 5 | "src": "api/app.py", 6 | "use": "@vercel/python" 7 | } 8 | ], 9 | "routes": [ 10 | { 11 | "src": "/(.*)", 12 | "dest": "api/app.py" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /api/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, jsonify 2 | from pymongo import MongoClient 3 | from datetime import datetime, timedelta 4 | 5 | app = Flask(__name__) 6 | 7 | # MongoDB Client Setup 8 | MONGO_URL = "YOUR_MONGO_URL" 9 | MONGO_CLIENT = MongoClient(MONGO_URL) 10 | 11 | # Access the database and collections 12 | db = MONGO_CLIENT["user_activity_db"] 13 | user_activity_collection = db["user_activity"] 14 | 15 | @app.route('/') 16 | def index(): 17 | return "SmartDevStats Hosted On Vercel!!!" 18 | 19 | @app.route('/api/stats') 20 | def get_stats(): 21 | now = datetime.utcnow() 22 | 23 | daily_users = user_activity_collection.count_documents({ 24 | "is_group": False, 25 | "last_activity": {"$gt": now - timedelta(days=1)} 26 | }) 27 | weekly_users = user_activity_collection.count_documents({ 28 | "is_group": False, 29 | "last_activity": {"$gt": now - timedelta(weeks=1)} 30 | }) 31 | monthly_users = user_activity_collection.count_documents({ 32 | "is_group": False, 33 | "last_activity": {"$gt": now - timedelta(days=30)} 34 | }) 35 | yearly_users = user_activity_collection.count_documents({ 36 | "is_group": False, 37 | "last_activity": {"$gt": now - timedelta(days=365)} 38 | }) 39 | 40 | total_users = user_activity_collection.count_documents({"is_group": False}) 41 | total_groups = user_activity_collection.count_documents({"is_group": True}) 42 | 43 | stats = { 44 | "daily_users": daily_users, 45 | "weekly_users": weekly_users, 46 | "monthly_users": monthly_users, 47 | "yearly_users": yearly_users, 48 | "total_users": total_users, 49 | "total_groups": total_groups 50 | } 51 | 52 | return jsonify(stats) 53 | 54 | if __name__ == '__main__': 55 | app.run(debug=True) 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TheSmartDev Bot Stats 🌟 2 | 3 | A full-stack application for real-time Telegram bot statistics, featuring a Flask API on Vercel and a PHP frontend on a custom domain. Built with MongoDB for data storage and a responsive, auto-refreshing UI. 🚀 4 | 5 | **Demo**: [smartdevstats.unaux.com](https://smartdevstats.unaux.com) 🌐 6 | 7 | ## ✨ Features 8 | - 📊 **Real-time Stats**: Tracks daily, weekly, monthly, yearly users, total users, and groups. 9 | - ⚙️ **Service Status**: Displays bot and API status in a clean table. 10 | - 📱 **Responsive UI**: Mobile-friendly with Animate.css animations. 11 | - 🔄 **Auto-Refresh**: Updates every 60 seconds. 12 | - 🌍 **Social Links**: Connects to Telegram, Facebook, YouTube, GitHub, Twitter (X). 13 | - 🗄️ **MongoDB Backend**: Secure, scalable data storage. 14 | - ☁️ **Vercel Hosting**: Reliable API deployment. 15 | 16 | ## 🛠️ Tech Stack 17 | - **Backend**: Flask, MongoDB, Vercel 18 | - **Frontend**: PHP, HTML, CSS, JavaScript, Chart.js, Font Awesome, Animate.css 19 | - **Database**: MongoDB Atlas 20 | - **Deployment**: Vercel (API), Custom Domain (Frontend) 21 | 22 | ## 📋 Prerequisites 23 | - MongoDB Atlas account 🗄️ 24 | - Vercel account ☁️ 25 | - PHP-supported hosting (e.g., Unaux, Hostinger) 🌐 26 | - Git, Python 3.8+, pip, code editor 🛠️ 27 | 28 | ## 🚀 Setup Guide 29 | 30 | ### 1. Clone Repository 31 | ```bash 32 | git clone https://github.com/abirxdhack/SmartDevStats.git 33 | cd SmartDevStats 34 | ``` 35 | 36 | ### 2. Backend (Flask API) 🐍 37 | 38 | #### a. Configure MongoDB Atlas 39 | 1. Sign up at [mongodb.com](https://www.mongodb.com/cloud/atlas). 40 | 2. Create a cluster, database (`user_activity_db`), and collection (`user_activity`). 41 | 3. Update `api/app.py` with your MongoDB connection string: 42 | ```python 43 | MONGO_URL = "mongodb+srv://:@cluster0.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" 44 | ``` 45 | 46 | #### b. Install Dependencies 47 | ```bash 48 | python -m venv venv 49 | source venv/bin/activate # Windows: venv\Scripts\activate 50 | pip install -r requirements.txt 51 | ``` 52 | 53 | #### c. Test Locally 54 | ```bash 55 | python api/app.py 56 | ``` 57 | Visit `http://localhost:5000/api/stats` to confirm JSON output. 58 | 59 | #### d. Deploy to Vercel 60 | 1. Install Vercel CLI: 61 | ```bash 62 | npm install -g vercel 63 | ``` 64 | 2. Log in: 65 | ```bash 66 | vercel login 67 | ``` 68 | 3. Ensure `vercel.json` is configured: 69 | ```json 70 | { 71 | "version": 2, 72 | "builds": [{ "src": "api/app.py", "use": "@vercel/python" }], 73 | "routes": [{ "src": "/(.*)", "dest": "api/app.py" }] 74 | } 75 | ``` 76 | 4. Deploy: 77 | ```bash 78 | vercel 79 | ``` 80 | 5. Update `index.php` with your Vercel API URL: 81 | ```php 82 | $apiUrl = "https://your-app.vercel.app/api/stats"; 83 | ``` 84 | 85 | ### 3. Frontend (PHP) 🌐 86 | 87 | #### a. Customize `index.php` 88 | 1. Confirm `$apiUrl` matches your Vercel API. 89 | 2. Edit social media links and footer text as needed. 90 | 3. Modify CSS in ` 620 | 621 | 622 | 623 |
624 |

Loading TheSmartDev's Full Statistics

625 |
626 |
627 | 628 | 629 |
630 | 631 |
632 |
633 |

TheSmartDev

634 |
635 |
636 |
637 |
"Trying To make The World Smarter With SmartDev"
638 |
639 |
640 | 641 |
642 |

⚙️ TheSmartDev ❄️

643 |
644 |

📊 SmartBot's User's Database

645 |
646 | 647 |
648 |
649 | 💥 Last Database Updated At: 🌐 650 |
651 |
652 | 653 |
654 |
655 |
656 |
657 |

⚙️ Bots And API Statistics

658 | All Services Are Online🌟 659 |
660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 |
⚙️ Service❄️ Server Status
TelegramTheSmartDev APIAlive
TelegramSmartTools 404 BotAlive
TelegramSmart Tools BotAlive
TelegramSmart AIAlive
686 |
687 |
688 |
689 |
690 |
691 | 🔄 Refreshing Database In 56 Seconds 692 |
693 |
694 |
695 | 712 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 854 | 855 | 856 | --------------------------------------------------------------------------------