How bhooyas/enigma works
Project Type and Purpose
• This is a Python-based implementation of the historic Enigma cipher machine.
• It provides:
• A core Enigma engine (rotors, reflector, plugboard) in enigma.py, rotor.py, reflector.py, plugboard.py.
• A command-line interface (main.py) for offline encryption/decryption.
• A Flask-powered HTTP API (app.py) with minimal frontend (templates/ + static/).
• Containerization via Dockerfile for easy deployment.
File Structure Analysis
Top-level:
• Configuration: .gitignore, .dockerignore, GitHub Actions, Dockerfile.
• Core logic modules: enigma.py, rotor.py, reflector.py, plugboard.py.
• Entry points:
– main.py (CLI, uses argparse).
– app.py (Flask app exposing REST endpoints).
• Web UI:
– templates/ (index.html, cipher.html).
– static/ (CSS/JS assets if any).
There is no database or external persistence—everything is in-memory.
a. Main components:
1. Client Layer:
– Web Browser (User UI)
– CLI (Terminal)
2. Server Layer:
– Flask App (app.py)
3. Core Engine:
– Enigma class (enigma.py)
– Rotor module (rotor.py)
– Reflector module (reflector.py)
– Plugboard module (plugboard.py)
4. Infrastructure:
– Docker Container
– CI/CD (GitHub Actions) (optional, for deploy pipeline)
b. Relationships / Data Flow:
• Web Browser → HTTP request → Flask App → Enigma Engine → HTTP response → Browser
• Terminal → CLI (main.py) → Enigma Engine → Console output
• Flask App & CLI both depend on the same core engine modules.
• Docker container wraps the Flask App (and its dependencies) for deployment.
c. Architectural Patterns & Principles:
– Single-responsibility: each module handles one aspect of the cipher (rotor, plugboard, reflector).
– Layered separation: UI ↔ API ↔ Core Logic.
– Stateless design: no persistence layer; each request is independent.
– Containerized deployment: infrastructure as code.
d. Key Technologies:
– Python 3
– Flask (HTTP API + templating)
– Argparse (CLI)
– Docker
– GitHub Actions (CI for image build & tests)