Skip to content

omermask/stroapp-sms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

StroApp SMS β€” Virtual Phone Number Platform

A production-grade SMS verification platform that aggregates multiple SMS provider APIs, providing virtual phone numbers for receiving SMS verification codes β€” with a full-featured admin dashboard and a polished user mobile application.


πŸ“‹ Overview

StroApp SMS is a SMS-PaaS (SMS Platform as a Service) that solves the problem of needing a real phone number to receive SMS verification codes. Users purchase virtual numbers to receive OTP/activation codes for services like WhatsApp, Telegram, Google, Facebook, TikTok, and hundreds more β€” without exposing their personal phone number.

The platform aggregates supply from multiple SMS provider APIs, applies a configurable markup engine for profitability, and delivers a unified experience through:

  • πŸ“± User Mobile App (Flutter) β€” Browse services, purchase numbers, receive SMS, manage account
  • πŸ› οΈ Admin Dashboard (Flutter) β€” Manage users, orders, finances, security, and platform configuration
  • βš™οΈ Backend API (Python/FastAPI) β€” RESTful API powering both frontends with enterprise-grade security

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   User App      β”‚     β”‚   Admin App     β”‚     β”‚  3rd-Party      β”‚
β”‚  (Flutter)      β”‚     β”‚  (Flutter)      β”‚     β”‚  Integrations   β”‚
β”‚  port 3000      β”‚     β”‚  port 3001      β”‚     β”‚  (OAuth, IAP,   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  Payments...)   β”‚
         β”‚                       β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
                     β”‚ HTTP/JSON                         β”‚
                     β–Ό                                   β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            β”‚
            β”‚   FastAPI App  β”‚β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚   Port 9527    β”‚
            β”‚  + Gunicorn    β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό          β–Ό          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚PostgreSQLβ”‚ β”‚  Redis  β”‚ β”‚ SMS     β”‚
   β”‚ Database β”‚ β”‚  Cache  β”‚ β”‚Providersβ”‚
   β”‚ :5433    β”‚ β”‚ :6379   β”‚ β”‚(4 APIs) β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. User opens the mobile app, browses available services and countries
  2. Backend queries provider APIs for real-time pricing and stock
  3. Price Engine applies markup rules, user-specific pricing, and coins conversion
  4. User purchases a number β†’ coins deducted β†’ provider API called β†’ number allocated
  5. Polling Service monitors the number for incoming SMS messages
  6. Delivery β€” SMS code is delivered to the user via app UI, webhook, email forwarding, or Telegram bot
  7. Optional β€” Order auto-cancels after timeout with refund

✨ Features

πŸ”Ή Backend API (FastAPI)

User Features

  • Email/password authentication with JWT (access + refresh tokens)
  • Google Sign-In and Apple Sign-In OAuth integration
  • Multi-factor authentication (TOTP)
  • Virtual number purchase for SMS verification (temporary & rental)
  • Real-time SMS message polling with auto-refresh
  • Number cancellation with partial refund
  • Wallet system with coin-based transactions
  • In-app purchase payments (Google Play, Apple App Store, Stripe)
  • Webhook management for SMS delivery callbacks
  • Email forwarding and Telegram bot integration
  • Multi-tier subscription plans (Freemium, PAYG, Pro, Custom)
  • Temporary email inbox service
  • Voice call verification (call & speak code)
  • Referral and affiliate programs
  • Reseller and white-label support
  • KYC verification and compliance
  • GDPR data export and account deletion

Admin Features

  • Admin authentication and session management
  • User management (CRUD, ban, coin adjustment, tier change)
  • Order and transaction monitoring
  • Provider management (enable/disable, balance check)
  • Service management (activate/deactivate)
  • Dynamic pricing engine with markup rules
  • Pricing templates and user-specific pricing
  • Support ticket system
  • Dispute resolution
  • KYC document verification
  • Revenue and P&L reporting
  • Financial reconciliation
  • Provider settlement tracking
  • Affiliate commission management
  • Reseller account management
  • Broadcast push notifications
  • Security scanning and compliance reporting
  • Automated database backup and disaster recovery
  • Audit logging (enterprise-grade)
  • Feature flag management
  • Email template customization
  • Data export (users, transactions, payments, audit logs)
  • Security scans, secrets check, compliance reports
  • Multi-language support (7 languages)

Security & Compliance

  • Rate limiting (Redis token bucket)
  • CSRF protection
  • XSS prevention
  • SQL injection prevention (ORM-based)
  • Proxy/VPN detection middleware
  • Device fingerprinting
  • IP blacklisting
  • PII masking in logs
  • Structured JSON logging
  • Sentry error tracking
  • Prometheus metrics
  • Security headers (HSTS, CSP, X-Frame-Options, etc.)

πŸ”Ή User Mobile App (Flutter)

  • Browse 100+ services organized by category
  • View prices across 200+ countries
  • Purchase numbers with one tap (from presets)
  • Real-time SMS waiting screen with countdown timer
  • Order history with full details
  • Wallet with top-up via Google Pay / Apple Pay
  • Number rental with duration and auto-extend
  • Temporary email inbox
  • Voice verification purchase
  • Saved presets for quick re-purchase
  • Webhook and forwarding configuration
  • MFA setup and management
  • API key management
  • Active sessions management
  • Affiliate dashboard with commissions and payouts
  • KYC document submission and status tracking
  • Support ticket system
  • Multi-language (Arabic/English) with RTL support
  • Dark/Light theme
  • Biometric authentication (fingerprint, face ID)
  • Deep linking (referral codes)
  • Push notifications via Firebase Cloud Messaging
  • Onboarding wizard for new users

πŸ”Ή Admin Dashboard (Flutter)

  • Dashboard with KPI cards and charts (new users, orders, revenue)
  • User management with search, filters, and bulk actions
  • Order and transaction browsing with detail views
  • Support ticket management with reply thread
  • System settings (coins per USD, markup, email limits)
  • Provider and service management
  • Pricing engine with templates, promotions, and markup rules
  • Affiliate applications, commissions, and payouts
  • Reseller accounts and credit allocation
  • Financial reports (revenue, costs, settlements, tax)
  • P&L reports
  • Analytics dashboard with verification stats and carrier analytics
  • Ledger and reconciliation tools
  • Security screen: vulnerability scans, secrets check, compliance
  • Backup management: create, list, restore
  • Disaster recovery: run tests, monitor status
  • Webhook queue and retry monitoring
  • Broadcast push notifications
  • Blacklist management (IP, tokens)
  • Whitelabel domain management
  • Data sync orchestrator with markup rules
  • Data export (CSV) for users, transactions, payments, audit logs
  • Telegram bot connection management
  • Feature flag toggling
  • Session management with force logout
  • Email template editing
  • Waitlist management
  • Multi-language support (7 languages)

πŸ› οΈ Tech Stack

Backend

Technology Purpose
Python 3.12+ Runtime
FastAPI Web framework (async)
Uvicorn + Gunicorn ASGI server (dev + prod)
SQLAlchemy 2.0 ORM with async support
PostgreSQL 16 Primary database
Redis 7 Caching, rate limiting, queues
Alembic Database migrations
Pydantic v2 Data validation & settings
PyJWT JWT authentication
Passlib (bcrypt) Password hashing
Sentry Error monitoring
Prometheus Metrics & observability
Docker Containerization
NGINX Reverse proxy + WAF

SMS Providers (Integrated)

Provider Region Specialty
SMS-Man (smsman) Russia/CIS Wide country coverage
5sim (fivesim) International Large inventory
SMS-Activate (smsactivate) Russia/CIS Competitive pricing
SMSPool (smspool) USA/Global US numbers focus

Mobile Apps

Technology Purpose
Flutter Cross-platform UI framework
Riverpod State management
GoRouter Declarative routing
Dio HTTP client with interceptors
Freezed Immutable data models
Google Sign-In OAuth authentication
Apple Sign-In OAuth authentication
Firebase Messaging Push notifications
fl_chart Charts (admin app)

πŸ“ Project Structure

stroapp-sms/                          # Monorepo root
β”œβ”€β”€ app/                              # Python backend package
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ v1/                       # Version 1 API (60+ route files)
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py               # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ purchase.py           # SMS purchase & orders
β”‚   β”‚   β”‚   β”œβ”€β”€ services.py           # Service listing
β”‚   β”‚   β”‚   β”œβ”€β”€ user.py               # User profile & balance
β”‚   β”‚   β”‚   β”œβ”€β”€ payments.py           # Payment processing
β”‚   β”‚   β”‚   β”œβ”€β”€ webhooks.py           # Webhook management
β”‚   β”‚   β”‚   β”œβ”€β”€ admin_*.py            # 14 admin sub-modules
β”‚   β”‚   β”‚   └── ...                   # 40+ more endpoint files
β”‚   β”‚   └── v4/                       # Version 4 API (clean admin)
β”‚   β”‚       └── admin.py              # Unified admin API
β”‚   β”œβ”€β”€ core/                         # Framework & shared utilities
β”‚   β”‚   β”œβ”€β”€ config.py                 # Pydantic Settings
β”‚   β”‚   β”œβ”€β”€ database.py               # SQLAlchemy setup
β”‚   β”‚   β”œβ”€β”€ security.py               # JWT, hashing
β”‚   β”‚   β”œβ”€β”€ dependencies.py           # FastAPI dependencies
β”‚   β”‚   └── middleware.py             # Custom ASGI middleware
β”‚   β”œβ”€β”€ domain/
β”‚   β”‚   β”œβ”€β”€ models.py                 # 60+ SQLAlchemy models
β”‚   β”‚   └── coins.py                  # Coin conversion logic
β”‚   β”œβ”€β”€ infrastructure/
β”‚   β”‚   β”œβ”€β”€ providers/                # SMS provider adapters
β”‚   β”‚   β”‚   β”œβ”€β”€ base.py               # Abstract provider
β”‚   β”‚   β”‚   β”œβ”€β”€ router.py             # Provider router (fallback)
β”‚   β”‚   β”‚   β”œβ”€β”€ smsman.py             # SMS-Man integration
β”‚   β”‚   β”‚   β”œβ”€β”€ fivesim.py            # 5sim integration
β”‚   β”‚   β”‚   β”œβ”€β”€ smsactivate.py        # SMS-Activate integration
β”‚   β”‚   β”‚   β”œβ”€β”€ smspool.py            # SMSPool integration
β”‚   β”‚   β”‚   └── circuit_breaker.py    # Fault tolerance
β”‚   β”‚   β”œβ”€β”€ payments/                 # Payment integrations
β”‚   β”‚   β”œβ”€β”€ cache/                    # Redis caching
β”‚   β”‚   β”œβ”€β”€ queue/                    # Webhook queue (Redis streams)
β”‚   β”‚   β”œβ”€β”€ push/                     # OneSignal push
β”‚   β”‚   β”œβ”€β”€ bot/                      # Telegram bot
β”‚   β”‚   └── security/                 # Secrets & compliance
β”‚   β”œβ”€β”€ middleware/                    # HTTP middleware
β”‚   β”œβ”€β”€ schemas/                      # Pydantic schemas
β”‚   β”œβ”€β”€ services/                     # Business logic (40+ files)
β”‚   β”‚   β”œβ”€β”€ purchase_service.py       # SMS purchase flow
β”‚   β”‚   β”œβ”€β”€ price_calculator.py       # Pricing engine
β”‚   β”‚   β”œβ”€β”€ pricing_engine_service.py # User-specific pricing
β”‚   β”‚   β”œβ”€β”€ payment_service.py        # Payment processing
β”‚   β”‚   β”œβ”€β”€ audit_service.py          # Enterprise audit
β”‚   β”‚   β”œβ”€β”€ backup_service.py         # DB backup/restore
β”‚   β”‚   β”œβ”€β”€ security_scanner.py       # Security scanning
β”‚   β”‚   β”œβ”€β”€ background.py             # Background workers
β”‚   β”‚   └── ...                       # 30+ more services
β”‚   └── websocket/                    # WebSocket manager
β”œβ”€β”€ infrastructure/
β”‚   └── db/
β”‚       └── migrations/               # Alembic migrations
β”œβ”€β”€ scripts/                          # Utility scripts
β”‚   β”œβ”€β”€ seed_admin.py                 # Create admin user
β”‚   β”œβ”€β”€ backup.sh                     # Database backup
β”‚   └── run_security_audit.sh         # Security audit
β”œβ”€β”€ main.py                           # Application entry point
β”œβ”€β”€ Dockerfile                        # Docker build
β”œβ”€β”€ docker-compose.yml                # Full stack setup
β”œβ”€β”€ nginx.conf                        # Production proxy config
β”œβ”€β”€ requirements.txt                  # Python dependencies
β”œβ”€β”€ .env.example                      # Example environment
β”‚
β”œβ”€β”€ stroapp-sms-user/                 # User Flutter app
β”‚   └── lib/
β”‚       β”œβ”€β”€ main.dart                 # App entry point
β”‚       β”œβ”€β”€ core/                     # API, models, router, theme
β”‚       └── features/                 # Feature modules
β”‚           β”œβ”€β”€ sms_purchase/         # SMS buying flow
β”‚           β”œβ”€β”€ auth/                 # Authentication
β”‚           β”œβ”€β”€ home/                 # Dashboard
β”‚           β”œβ”€β”€ wallet/               # Wallet & payments
β”‚           β”œβ”€β”€ settings/             # Settings hub
β”‚           β”œβ”€β”€ presets/              # Saved presets
β”‚           β”œβ”€β”€ temp_email/           # Temp email inbox
β”‚           β”œβ”€β”€ voice/                # Voice verification
β”‚           β”œβ”€β”€ rentals/              # Number rental
β”‚           └── ...                   # 10+ more features
β”‚
└── stroapp-sms-admin/                # Admin Flutter app
    └── lib/
        β”œβ”€β”€ main.dart                 # App entry point
        β”œβ”€β”€ app/                      # Screens & tabs
        β”‚   β”œβ”€β”€ screens/              # 21 screen files
        β”‚   └── tabs/                 # 5 bottom nav tabs
        └── core/                     # API, models, services, theme
            β”œβ”€β”€ api_constants.dart    # 184 API endpoint definitions
            β”œβ”€β”€ services/             # 5 service classes
            β”œβ”€β”€ models/               # Data models
            └── widgets/              # 12 reusable widgets

πŸš€ Getting Started

Prerequisites

  • Python 3.12+
  • PostgreSQL 16
  • Redis 7
  • Flutter 3.x (for mobile apps)
  • Docker (optional, for containerized deployment)

1. Clone & Setup Backend

git clone <repo-url> stroapp-sms
cd stroapp-sms

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # Linux/Mac
# or .venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your settings (database URL, API keys, secrets)

2. Database Setup

# Using Docker (recommended for development)
docker run -d \
  --name stroapp-db \
  -e POSTGRES_USER=stroapp \
  -e POSTGRES_PASSWORD=stroapp_pass \
  -e POSTGRES_DB=stroapp \
  -p 5433:5432 \
  postgres:16

# Run migrations
alembic upgrade head

# Seed admin user
python scripts/seed_admin.py admin@example.com your-password

3. Run Backend

# Development
python main.py

# Production (with Gunicorn)
gunicorn main:app -c gunicorn.conf.py

The API will be available at http://localhost:9527/stroapp/docs (Swagger UI).

4. Run User App

cd stroapp-sms-user
cp .env.example .env  # edit API_BASE_URL
flutter pub get
flutter run -d chrome  # or -d android, -d ios

5. Run Admin App

cd stroapp-sms-admin
flutter pub get
flutter run -d chrome  # or -d android, -d ios

Docker Compose (Full Stack)

docker compose up -d

This starts PostgreSQL, Redis, and the FastAPI application together.


πŸ”§ Configuration

Backend Environment Variables

Variable Description Default
DATABASE_URL PostgreSQL connection string postgresql://stroapp:stroapp_pass@localhost:5433/stroapp
REDIS_URL Redis connection string redis://localhost:6379/0
SECRET_KEY App encryption key (min 32 chars) β€”
JWT_SECRET_KEY JWT signing key (min 32 chars) β€”
COINS_PER_USD Coin-to-USD conversion rate 100
DEFAULT_MARKUP Default price markup multiplier 1.15
SMSMAN_API_KEY SMS-Man provider API key β€”
FIVESIM_API_KEY 5sim provider API key β€”
SMSACTIVATE_API_KEY SMS-Activate provider API key β€”
SMSPOOL_API_KEY SMSPool provider API key β€”
SENTRY_DSN Sentry error tracking DSN β€”
TURNSTILE_SECRET_KEY Cloudflare Turnstile secret β€”
TELEGRAM_BOT_TOKEN Telegram bot token β€”

Full list available in .env.example.

Flutter App Configuration

Each Flutter app uses a .env file for configuration:

User App (.env):

API_BASE_URL=http://localhost:9527/stroapp/v1
CONNECT_TIMEOUT=10000
RECEIVE_TIMEOUT=15000

Admin App: Base URL is configured in lib/core/constants/api_constants.dart and can be changed at runtime via the login screen UI.


πŸ“– API Documentation

Base URLs

  • User API: /stroapp/v1/...
  • Admin API: /stroapp/v4/admin/api/...
  • Swagger UI: /stroapp/docs
  • ReDoc: /stroapp/redoc
  • Health: /health
  • Metrics: /stroapp/metrics

Authentication

  • User: JWT Bearer tokens (access + refresh tokens)
  • Admin: JWT Bearer tokens (separate admin login endpoint)
  • MFA: Optional TOTP with x-mfa-token header
  • API Keys: nsk_ prefixed keys for programmatic access

Response Format

All API responses follow a consistent structure:

{
  "success": true,
  "data": { ... },
  "error": null,
  "request_id": "uuid"
}

Paginated responses:

{
  "success": true,
  "data": { "items": [...], "total": 100, "page": 1, "per_page": 20 },
  "error": null
}

πŸ”’ Security

The platform implements multiple layers of security:

  • Rate Limiting: Redis token bucket algorithm (configurable limits)
  • CSRF Protection: Token-based per-session
  • XSS Prevention: Input sanitization and output encoding
  • SQL Injection: ORM-based queries + statement-level protection
  • Proxy/VPN Detection: Middleware to flag anonymous traffic
  • Device Fingerprinting: Risk scoring per device
  • IP Blacklisting: Manual and automated blacklist management
  • Session Management: Active session tracking with revocation
  • MFA: Optional TOTP two-factor authentication
  • Audit Logging: Every admin action is logged with user, IP, timestamp
  • Security Scanning: Automated vulnerability scanning
  • Secrets Management: Encrypted storage of sensitive configuration
  • GDPR Compliance: Data export, deletion, and consent management
  • KYC/AML: Identity verification for high-value accounts
  • WAF: NGINX-based web application firewall in production
  • HTTPS: SSL/TLS enforcement via NGINX

πŸ§ͺ Testing

# Backend tests
pytest tests/ -v

# Run specific test
pytest tests/test_comprehensive.py -v

# Flutter tests (user app)
cd stroapp-sms-user
flutter test

# Flutter tests (admin app)
cd stroapp-sms-admin
flutter test

πŸ“¦ Deployment

Production Architecture

Internet β†’ NGINX (Reverse Proxy + WAF) β†’ Gunicorn (4 workers) β†’ FastAPI
                                                                    β”‚
                                    PostgreSQL ←─────────────────────
                                    Redis ←─────────────────────────
                                    SMS Providers β†β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Docker Deployment

# Build and run
docker compose up -d --build

# Check logs
docker compose logs -f api

# Run migrations
docker compose exec api alembic upgrade head

# Create admin user
docker compose exec api python scripts/seed_admin.py admin@example.com password

Manual Production Setup

  1. Set up PostgreSQL and Redis
  2. Configure .env with production values
  3. Run with Gunicorn:
    gunicorn main:app -c gunicorn.conf.py
  4. Set up NGINX reverse proxy using nginx.conf
  5. Configure SSL certificates (Let's Encrypt)
  6. Set up monitoring (Sentry, Prometheus)
  7. Configure automated backups via the admin panel

🀝 Contributing

  1. Fork the repository
  2. Create a 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

Development Guidelines

  • Follow existing code style and conventions
  • Write tests for new features
  • Update API documentation for endpoint changes
  • Run pytest before submitting PRs
  • Use conventional commit messages

πŸ“„ License

All rights reserved. This project is proprietary software.


πŸ“ž Support