Skip to content

lavendarsolution/atm-insights-simulator

Repository files navigation

ATM Insights Simulator

A high-performance ATM telemetry simulator designed to generate realistic data for the ATM Insights monitoring system. This simulator produces telemetry data for a fleet of 612 ATMs with sophisticated cash management, error generation, and alert calibration capabilities.

🚀 Features

  • Realistic ATM Fleet Simulation: Generates telemetry for 612 ATMs across different regions (Airport, Supermarket, Mall, Hospital, University)
  • Smart Cash Management: Advanced cash depletion and refill algorithms calibrated to generate exactly ~50 cash alerts per day
  • Error Generation: Sophisticated error simulation with daily limits and realistic frequency patterns
  • Alert Calibration: Dual-tier alert system with warnings (<20% cash) and critical alerts (<10% cash)
  • Notification Integration: Supports Telegram and Email notifications through the backend API
  • Performance Optimized: Batched API calls and efficient data structures for high-throughput simulation
  • Docker Ready: Containerized deployment with Docker support

📊 Alert System

Cash Level Alerts

  • Warning Alerts (10-20% cash): Telegram notifications, 12-hour cooldown
  • Critical Alerts (<10% cash): Telegram + Email notifications, 8-hour cooldown
  • Target: Calibrated to generate ~50 total cash alerts per day across all ATMs

Error Alerts

  • Daily Limits: Maximum 300 total errors, 100 critical errors per day
  • Frequency: Each ATM generates errors every 40-58 hours on average
  • Types: Hardware failures, network issues, cash dispenser problems, etc.

🛠️ Installation

Prerequisites

  • Python 3.10 or higher
  • Poetry
  • Docker (optional, for containerized deployment)

Local Development Setup

  1. Clone the repository (if not already done):

    git clone <repository-url>
    cd atm-insights-simulator
  2. Install dependencies:

    poetry install
  3. Configure environment:

    cp .env.example .env
    # Edit .env with your configuration
  4. Run the simulator:

    poetry run python run_simulator.py

Docker Deployment

  1. Build the Docker image:

    make build
  2. Run the container:

    make run
  3. Run database migrations (if needed):

    make migration

⚙️ Configuration

The simulator is configured through environment variables. Copy .env.example to .env and modify as needed:

Required Configuration

# Backend API URL - Point to your ATM Insights backend
BACKEND_URL=http://localhost:8000

Optional Configuration

# Fleet Configuration
NUM_ATMS=612                    # Number of ATMs to simulate
SEND_INTERVAL_SECONDS=30        # Telemetry transmission interval
BATCH_SIZE=10                   # API batch size for performance

# Cash Management (Calibrated for 50 alerts/day)
TARGET_DAILY_CASH_ALERTS=50     # Target daily cash alerts
CASH_WARNING_THRESHOLD=20.0     # Warning threshold percentage
CASH_CRITICAL_THRESHOLD=10.0    # Critical threshold percentage

# Error Control
MAX_DAILY_ERRORS=300            # Maximum total errors per day
MAX_DAILY_CRITICAL_ERRORS=100   # Maximum critical errors per day
MIN_HOURS_BETWEEN_ERRORS=40.0   # Minimum hours between errors per ATM
MAX_HOURS_BETWEEN_ERRORS=58.0   # Maximum hours between errors per ATM

🏗️ Architecture

Core Components

  • simulator.py: Main simulation engine with cash management and error generation
  • config.py: Configuration management and ATM fleet generation
  • run_simulator.py: Entry point script for running the simulator

ATM Fleet Structure

Each simulated ATM includes:

  • Identification: Unique ATM ID, location, region
  • Hardware: Manufacturer, model, firmware version
  • Health Metrics: Health factor influencing error probability
  • Cash Management: Dynamic cash levels with realistic depletion patterns
  • Error States: Tracking for error frequency and cooldown periods

Cash Management Algorithm

The simulator implements a sophisticated cash management system:

  1. Dynamic Depletion: Cash levels decrease based on location multipliers and time-of-day patterns
  2. Smart Refills: Three-tier refill strategy (100%, 80%, 40%) based on cash levels
  3. Alert Generation: Calibrated to maintain exactly 50 alerts per day across all ATMs
  4. Real-time Adjustment: Daily monitoring and adjustment to meet alert targets

🔧 Development

Adding New Features

  1. New Alert Types: Add to config.py error codes and modify alert logic in simulator.py
  2. Custom ATM Models: Extend the ATM generation logic in config.py
  3. Advanced Cash Patterns: Modify the cash management algorithms in simulator.py
  4. Additional Metrics: Add new telemetry fields to the data generation methods

🚨 Alert Calibration

The simulator is precisely calibrated to meet specific alert frequency requirements:

Target: 50 Cash Alerts/Day

  • Total ATMs: 612
  • Alert Rate: ~0.082 alerts per ATM per day
  • Warning Threshold: 20% cash level
  • Critical Threshold: 10% cash level

Calibration Parameters

  • Depletion Rate: 0.08-0.15% per 30-second cycle
  • Location Multipliers: Airport (1.5x), Mall (1.3x), Supermarket (1.2x), etc.
  • Time Patterns: Higher consumption during business hours
  • Refill Strategy: Prevents excessive alerts while maintaining realistic patterns

🐛 Troubleshooting

Common Issues

  1. High Alert Frequency: Adjust TARGET_DAILY_CASH_ALERTS in configuration
  2. Backend Connection Failed: Verify BACKEND_URL and ensure backend is running
  3. Performance Issues: Increase BATCH_SIZE or SEND_INTERVAL_SECONDS
  4. Docker Build Failed: Ensure Docker is running and has sufficient resources

Logs and Debugging

The simulator provides detailed logging:

  • Info level: Normal operation, alert generation, daily summaries
  • Warning level: API failures, configuration issues
  • Error level: Critical failures, connection problems

Enable debug logging by modifying the logging level in simulator.py.

📝 License

This project is part of the ATM Insights trial task developed by Lavendar Solution.

🤝 Contributing

For issues, improvements, or questions, please contact:

📚 Related Projects

  • ATM Insights Backend: REST API and data processing engine
  • ATM Insights Frontend: Web dashboard for monitoring and analytics

Note: This simulator is designed to work in conjunction with the ATM Insights backend system. Ensure the backend is properly configured with Telegram and email notification services for complete functionality.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published