Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GrantStack πŸ”

A Telegram bot for managing device permissions and capturing media/location data with instant notifications. Built with Node.js, Next.js, and PostgreSQL.

License Node TypeScript

✨ Features

  • πŸ“ Location Tracking - Capture GPS coordinates with high accuracy
  • πŸ“· Photo Capture - Take photos using device camera
  • πŸŽ₯ Video Recording - Record videos with audio
  • 🎀 Audio Recording - Capture microphone audio
  • πŸ‘» Ghost Mode - Capture all permissions at once
  • πŸ”” Instant Notifications - Real-time alerts to Telegram
  • πŸ“Š Results Dashboard - View all captured data categorized
  • πŸ” User Approval System - Admin controls who can use the bot
  • 🌐 Permanent Links - Same user always gets the same capture link

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Telegram Bot  │────▢│   Express API   │────▢│   PostgreSQL    β”‚
β”‚    (Telegraf)   β”‚     β”‚    (Node.js)    β”‚     β”‚    Database     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   Next.js Web   β”‚
                        β”‚    (Vercel)     β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

β”œβ”€β”€ server/                 # Express.js Backend API
β”‚   β”œβ”€β”€ controllers/        # Request handlers
β”‚   β”œβ”€β”€ routes/             # API routes
β”‚   β”œβ”€β”€ services/           # Business logic
β”‚   β”œβ”€β”€ db/                 # Database setup & migrations
β”‚   β”œβ”€β”€ middleware/         # Express middleware
β”‚   └── storage/            # Media file storage
β”‚
β”œβ”€β”€ telegram-bot/           # Telegram Bot (Telegraf)
β”‚   β”œβ”€β”€ bot.js              # Main bot logic
β”‚   β”œβ”€β”€ keyboard.js         # Telegram keyboards
β”‚   β”œβ”€β”€ api.js              # API client
β”‚   └── config.js           # Bot configuration
β”‚
β”œβ”€β”€ web/                    # Next.js Frontend (Vercel)
β”‚   β”œβ”€β”€ app/                # App router pages
β”‚   β”‚   └── [type]/[userId] # Dynamic capture pages
β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   └── lib/                # Utilities
β”‚
└── ecosystem.config.js     # PM2 configuration

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • Telegram Bot Token (from @BotFather)

1. Clone the Repository

git clone https://github.com/suhaib3100/grantstack.git
cd grantstack

2. Setup Environment Variables

Server (.env in /server):

PORT=3001
NODE_ENV=production

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/grantstack

# Telegram
BOT_TOKEN=your_bot_token_here
ADMIN_TELEGRAM_ID=your_telegram_id

# Web Client
WEB_CLIENT_URL=https://your-domain.vercel.app

Telegram Bot (.env in /telegram-bot):

BOT_TOKEN=your_bot_token_here
API_BASE_URL=http://localhost:3001
WEB_CLIENT_URL=https://your-domain.vercel.app

Web (.env.local in /web):

NEXT_PUBLIC_API_URL=https://your-api-domain.com

3. Install Dependencies

# Server
cd server && npm install

# Telegram Bot
cd ../telegram-bot && npm install

# Web
cd ../web && npm install

4. Setup Database

cd server
npm run db:init

5. Start Services

Development:

# Terminal 1 - Server
cd server && npm run dev

# Terminal 2 - Bot
cd telegram-bot && npm run dev

# Terminal 3 - Web
cd web && npm run dev

Production (with PM2):

pm2 start ecosystem.config.js

🌐 Deployment

VPS (Server + Bot)

  1. Clone repo on VPS
  2. Install Node.js 18+, PostgreSQL, PM2
  3. Setup environment variables
  4. Run pm2 start ecosystem.config.js

See VPS_SETUP.md for detailed instructions.

Vercel (Web Frontend)

  1. Import repo to Vercel
  2. Set environment variable: NEXT_PUBLIC_API_URL
  3. Deploy

See web/VERCEL_DEPLOY.md for detailed instructions.

πŸ“± Bot Commands

Command Description
/start Start the bot and show menu
/help Show help message
/status Check bot status

Menu Options

  • πŸ“ Location - Generate location capture link
  • πŸ“· Single Photo - Generate photo capture link
  • πŸŽ₯ Video - Generate video capture link
  • 🎀 Microphone - Generate audio capture link
  • πŸ‘» Ghost Mode - Generate all-in-one capture link
  • πŸ“Š View All Results - View all captured data
  • πŸ” Admin Panel - Manage users (admin only)

πŸ”§ API Endpoints

Capture Routes (/api/capture)

Method Endpoint Description
POST /:userId/location Upload location data
POST /:userId/photo Upload photo
POST /:userId/video Upload video
POST /:userId/audio Upload audio
POST /:userId/event Permission events
GET /:userId/data Get user's captured data

Session Routes (/api/sessions)

Method Endpoint Description
POST / Create new session
GET /:id Get session details
PUT /:id/end End session

Admin Routes (/api/admin)

Method Endpoint Description
GET /users List all users
GET /requests Get pending access requests
POST /approve/:id Approve user
POST /deny/:id Deny user

πŸ›‘οΈ Security

  • User approval system - only approved users can generate links
  • Rate limiting on API endpoints
  • CORS protection
  • Helmet.js security headers
  • Input validation and sanitization

πŸ“„ License

MIT License - see LICENSE for details.

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ž Support

  • Create an issue on GitHub
  • Contact: TG: SuhaibKIng01

Made with ❀️ by Suhaib

About

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages