Skip to content

A high-performance stream monitoring engine built on the Boyer-Moore Voting Algorithm. Detects dominant signals (bad actors, network floods, or majority votes) in real-time with O(1) space and O(N) time efficiency.

Notifications You must be signed in to change notification settings

aliallouf/Election-Guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Election Guardian: Real-Time Stream Monitoring

Python 3.8+ License: MIT

Election Guardian is a high-performance monitoring tool designed to identify "bad actors" or dominant signals in high-frequency data streams. By implementing the Boyer-Moore Voting Algorithm, it provides a mathematically guaranteed method to detect majority elements with absolute minimal memory overhead.


πŸ’‘ The Problem

In high-velocity systems (like voting servers or network firewalls), tracking the frequency of every incoming ID is memory-intensive. If you have millions of unique IPs, a standard hash map will crash your system.

Election Guardian solves this by finding the most frequent element without storing a counter for every item.

πŸ›  Technical Highlights

  • Optimal Performance: Identifies a majority candidate in a single pass $O(N)$ and verifies it in a second pass.
  • Space Efficiency: Operates with $O(1)$ auxiliary space, maintaining constant memory usage regardless of stream size.
  • Strict Verification: Distinguishes between a "true majority" ($> N/2$) and a simple plurality.

🧠 How It Works (The Intuition)

The algorithm works like a series of "duels."

  1. If we see a new candidate and our vote count is 0, they take the lead.
  2. If we see the same candidate again, their vote increases.
  3. If we see a different signal, they "fight" and one vote is removed.
  4. Because a true majority occupies more than half the stream, they will mathematically always be the last one standing.

πŸ“‚ Project Structure

  • src/: Core logic for the StreamMonitor engine.
  • simulations/: Real-time traffic simulation mimicking a network flood.
  • tests/: Robust test suite covering edge cases (empty streams, no majority, etc.).

πŸš€ Getting Started

Installation

  1. Clone the repository:
    git clone [https://github.com/your-username/election-guardian.git](https://github.com/your-username/election-guardian.git)
    cd election-guardian

About

A high-performance stream monitoring engine built on the Boyer-Moore Voting Algorithm. Detects dominant signals (bad actors, network floods, or majority votes) in real-time with O(1) space and O(N) time efficiency.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages