Skip to content

AmmarSalmi/minha-app

Repository files navigation

Minha App - ANEM Automation & Monitoring

A powerful, resilient web application and Telegram bot designed to automate interactions with the ANEM (Agence Nationale de l'Emploi) platform. It helps job seekers monitor appointments, renew demands, and manage their files efficiently.

⚠️ Important: The ANEM API restricts access to Algerian IP addresses. This app includes built-in proxy support for deployment on external servers (VPS).

✨ Key Features

🤖 Smart Automation

  • Appointment Monitoring: Automatically checks for available "Rendez-vous" slots at scheduled times.
  • Auto-Renewal: Automatically renews job demands before they expire, ensuring you never lose your status.
  • Smart Retries: Resilient API client with exponential backoff handles network glitches and proxy instability.
  • Push Notifications: Instant alerts when appointments become available.

🌍 Multilingual Support

  • Three Languages: Full support for Arabic (العربية), French (Français), and English.
  • Seamless Switching: Change language anytime via the bot settings - all UI elements update instantly.
  • RTL Support: Proper right-to-left rendering for Arabic content.

📄 PDF Document Management

  • One-Click Download: Download RDV confirmation and Honour Declaration PDFs directly from Telegram.
  • Cached Downloads: Previously downloaded PDFs are cached using Telegram File IDs for instant re-access.
  • Interview Documents Checklist: Users with pending appointments see required documents for their visit.
  • Auto-Sync: Keeps your profile up-to-date by syncing data from the official documents.

👥 Multi-Account Support

  • Tiered Access:
    • Free: 1 account, 5 PDF downloads/month, 1 Force Sync/month
    • Pro: 5 accounts, 20 PDF downloads/month, 5 Force Syncs/month, Priority notifications
    • Plus: 20 accounts, 60 PDF downloads/month, 20 Force Syncs/month, Usage dashboard, Priority support
  • Dynamic Limits: All tier limits configurable via admin commands without code changes.
  • Usage Tracking: Monthly PDF download and Force Sync quotas with automatic reset.
  • Unified Dashboard: View status and stats for all linked accounts in a single Telegram message.

� Crypto Payments (NOWPayments)

  • Seamless Integration: Users can upgrade to Pro tier via cryptocurrency payments.
  • Multiple Cryptocurrencies: Accept BTC, ETH, USDT, and 100+ other cryptocurrencies.
  • Automatic Activation: Pro subscription activates automatically upon payment confirmation.
  • Webhook Verification: Secure HMAC-SHA512 signature verification for all payment callbacks.
  • Configurable Pricing: Set custom prices and subscription durations via environment variables.

�📬 Contact Admin System

  • Topic Categories: Report bugs, request features, payment issues, or other inquiries.
  • Reference Codes: Each message gets a unique code for tracking and replies.
  • Priority Sorting: Payment issues prioritized in admin reports.
  • Admin Replies: Admins can reply directly to users via message codes.

🛠️ Admin Dashboard

  • Admin Toolkit: Centralized access to all admin functions:
    • Inbox: View user messages and system errors with counts.
    • Broadcast: Send announcements to Free, Pro, or all users with scheduling options.
    • User Management: Search users, change roles (Free/Pro/Plus), view details.
    • Tier Management: View/edit pricing, limits, and features with full audit logging.
    • Cache Stats: Monitor global cache performance and hit rates.
    • Manual Fetch: Trigger immediate appointment checks.
    • API Stats/Test: Monitor API usage and run health checks.
  • System Settings: Hot-swap configuration (retry attempts, backoff, schedules, cooldowns) without restarts.
  • Dynamic Pricing: Update tier prices and limits via Telegram commands (/setprice, /setlimit, /togglefeature).
  • Audit Trail: All pricing changes logged with admin ID, timestamp, and reason.
  • Error Tracking: Unique error codes with detailed logs and resolution buttons.

🚀 Quick Start

Prerequisites

  • Docker & Docker Compose
  • PostgreSQL database
  • Telegram Bot Token (from @BotFather)
  • (Optional) Proxy URL(s) if hosting outside Algeria
  • (Optional) NOWPayments account for crypto payments (nowpayments.io)

Installation

  1. Clone & Configure:

    git clone https://github.com/AmmarSalmi/minha-app.git
    cd minha-app
    cp .env.example .env
    # Edit .env with your credentials
  2. Run with Docker:

    docker-compose up -d --build
  3. Access:

    • Frontend (Web): http://localhost:9091 (Register & Link Accounts)
    • Bot: Open your bot in Telegram to manage accounts.

📖 How to Use

  1. Register: Go to the web interface, enter your Wassit Number and National ID.
  2. Link: You'll receive a unique code. Send this code to the Telegram bot.
  3. Manage: Use the bot menu:
    • 📊 Profile: View account status, expiration dates, and download PDFs.
    • ⚙️ Settings: Toggle preferences (daily reports, push alerts, language).
    • ❓ Help: Access comprehensive documentation.

🏗️ Architecture

graph TD
    User[User] -->|Web UI| Frontend[React Frontend]
    User -->|Commands| Bot[Telegram Bot]
    
    subgraph Backend
        API[Gin API]
        BotEngine[Bot Engine]
        Scheduler[Task Scheduler]
        RenewalWorker[Renewal Service]
    end
    
    Frontend --> API
    API --> DB[(PostgreSQL)]
    Bot --> BotEngine
    BotEngine --> DB
    
    Scheduler -->|Trigger| BotEngine
    Scheduler -->|Trigger| RenewalWorker
    Scheduler -->|Broadcasts| BotEngine
    
    RenewalWorker -->|HTTPS + Proxy| ANEM[ANEM API]
    BotEngine -->|HTTPS + Proxy| ANEM
Loading

🛠️ Tech Stack

  • Backend: Go 1.23 (Gin, GORM, Go-Telegram-Bot-API)
  • Frontend: React 18, Vite
  • Database: PostgreSQL
  • Infrastructure: Docker, Nginx, GitHub Actions
  • Localization: JSON-based i18n with embedded locales

🛡️ Security & Privacy

  • Input Validation: Wassit numbers and National IDs validated before processing.
  • Log Sanitization: PII (personal identifiers) masked in all log outputs.
  • Ownership: Users can only access documents for accounts they have legally verified.
  • Rate Limiting: Cooldowns on PDF downloads, manual checks, and contact messages.
  • Cooldown Bypass Protection: Soft-deleted account records with active cooldowns are preserved, preventing users from evading rate limits by removing/re-adding accounts.
  • Encryption: HTTPS communication throughout.

📅 Scheduled Tasks

Task Schedule Description
Appointment Check Hourly (configurable) Probes for available slots
Daily Reports 7:30 AM CET Sends user statistics
Contact Messages 6:00 AM CET Compiles user messages for admin
Error Digest Every 6 hours Summarizes pending errors
Auto-Renewal 9:00 AM CET Renews expiring accounts
Account Warnings 10:00 AM CET Alerts users about expiring accounts
Scheduled Broadcasts Every 5 minutes Sends due broadcast messages

⚙️ Environment Variables

Variable Required Default Description
TELEGRAM_BOT_TOKEN Yes - Telegram Bot API token from @BotFather
ADMIN_TELEGRAM_IDS Yes - Comma-separated list of admin Telegram IDs
POSTGRES_PASSWORD Yes - PostgreSQL database password
PROXY_URL No - Proxy URL template with XXXXX placeholder for rotating sessions
ALLOWED_ORIGINS No localhost CORS allowed origins for frontend
BUILD_VERSION No - Version string displayed in bot
NOWPayments
NOWPAYMENTS_API_KEY No - API key from NOWPayments dashboard
NOWPAYMENTS_IPN_SECRET No - IPN secret for webhook signature verification
NOWPAYMENTS_WEBHOOK_URL No - Public URL for payment webhooks (e.g., https://yourdomain.com/webhook/nowpayments)
NOWPAYMENTS_SUCCESS_URL No - Redirect URL after successful payment
NOWPAYMENTS_CANCEL_URL No - Redirect URL if payment cancelled
Subscription & Tiers
PRO_PRICE_USD No 4.00 Pro subscription price in USD (legacy)
PRO_DURATION_DAYS No 365 Pro subscription duration in days
TIER_PRO_MONTHLY_PRICE No - Override Pro monthly price from DB
TIER_PRO_YEARLY_PRICE No - Override Pro yearly price from DB
TIER_PLUS_MONTHLY_PRICE No - Override Plus monthly price from DB
TIER_PLUS_YEARLY_PRICE No - Override Plus yearly price from DB
MANUAL_FETCH_CACHE_TTL No 3600 Global cache TTL in seconds (stealth cache)
GLOBAL_CACHE_ENABLED No true Enable/disable global appointment cache

📄 License

MIT

About

ANEM appointment notification system with React frontend, Go backend, and Telegram bot integration

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors