Skip to content

JoseJulianMosqueraFuli/apolo-11

Repository files navigation

Softserve

πŸš€ NASA Apollo 11 - Simulation and Monitoring System

Python Poetry CI Tests Coverage FastAPI Kubernetes License

A professional simulation and monitoring system for NASA space missions

English β€’ EspaΓ±ol


πŸ“‹ Table of Contents

🎯 About

Apollo 11 is a comprehensive simulation and monitoring system designed for NASA space missions. Built with modern Python practices, it provides real-time telemetry data generation, analysis, and reporting capabilities with a beautiful terminal user interface.

Developed as part of the Softserve Python Bootcamp Challenge, this project demonstrates advanced Python concepts including:

  • πŸ—οΈ Object-oriented programming with classes and inheritance
  • πŸ“ File I/O operations and directory management
  • βš™οΈ Configuration management with YAML
  • πŸ§ͺ Comprehensive testing (unit tests + property-based testing)
  • πŸ–₯️ CLI interface with argument parsing
  • πŸ“Š Real-time dashboard with Rich library
  • 🌐 Web dashboard with FastAPI and auto-refresh
  • ☸️ Kubernetes deployment with Ingress and RabbitMQ

The system simulates real-world scenarios where multiple devices across different space missions generate telemetry data that needs to be collected, analyzed, and reported in real-time.

✨ Features

Apollo 11 provides a complete suite of tools for space mission monitoring:

πŸ”§ Core Components

  • πŸ“Š Data Generator: Creates realistic simulated log files for different missions and devices
  • πŸ“ˆ Report Analyzer: Processes logs and generates comprehensive device status statistics
  • πŸ’Ύ Backup Management: Automatically archives processed data with intelligent folder handling
  • πŸ–₯️ TUI Dashboard: Beautiful terminal interface for real-time monitoring using Rich library
  • 🌐 Web Dashboard: FastAPI web dashboard with JSON API, HTML interface, and Swagger docs

πŸš€ Advanced Capabilities

  • Real-time Monitoring: Live updates of system status and mission statistics
  • Web Dashboard: Auto-refreshing web UI with REST API and Swagger documentation
  • Property-based Testing: Robust validation using Hypothesis framework
  • Centralized Logging: Configurable logging system across all modules
  • High Test Coverage: 96% test coverage with 88 comprehensive tests
  • Professional CLI: Full argument parsing with validation and help system
  • Kubernetes Support: Ready-to-deploy manifests for Docker Desktop

πŸ› οΈ Installation

Prerequisites

Quick Start

Local

# 1. Clone the repository
git clone git@github.com:JoseJulianMosqueraFuli/apolo-11.git
cd apolo-11

# 2. Install dependencies
poetry install

# 3. Run with dashboard (recommended)
poetry run apolo --dashboard

Docker

# Build and run with RabbitMQ
docker compose up --build

Verify Installation

# Run tests to verify everything works
poetry run pytest --cov=apolo_11 -v

πŸš€ Usage

Basic Execution

# Default configuration
poetry run apolo

# Custom parameters
poetry run apolo --num_files_min 1 --num_files_max 100 --generator_interval 5 --reporter_interval 15

# Enable dashboard for real-time monitoring (recommended)
poetry run apolo --dashboard

Command Line Parameters

Parameter Default Description
--num_files_min 1 Minimum number of log files to generate per cycle
--num_files_max 100 Maximum number of log files to generate per cycle
--generator_interval 20 Time in seconds between each file generation cycle
--reporter_interval 60 Time in seconds between each report generation cycle
--dashboard False Enable TUI dashboard for real-time monitoring
--api False Enable web API dashboard (FastAPI)
--api-port 8000 Port for the web API dashboard

⚠️ Important: The reporter interval must be greater than the generator interval to prevent data accumulation.

πŸ“Š Dashboard TUI

The system features a beautiful Terminal User Interface (TUI) dashboard built with the Rich library for real-time monitoring:

Dashboard

Real-time monitoring dashboard with live statistics

πŸŽ›οΈ Dashboard Features

System Overview Panel

  • πŸ“ Files Generated: Total log files created in current session
  • πŸ”„ Current Cycle: Active generation cycle number
  • ⏰ Last Report: Timestamp of most recent statistical report

Mission Statistics Panel

  • πŸš€ Mission Names: Active space missions (GalaxyTwo, ColonyMoon, VacMars, etc.)
  • πŸ”§ Device Types: Device categories per mission (Rover, Equipment, Sensor, etc.)
  • πŸ“Š Device Counts: Total devices per mission
  • βœ… Status Summary: Device status distribution (operational, excellent, unknown, etc.)

Real-time Updates

  • ⚑ Auto-refresh: Updates every second automatically
  • πŸ“‘ Live Data: Direct feed from generator and reporter components
  • 🎨 Clean Layout: Professional interface using Rich library
  • ⌨️ Easy Exit: Press Ctrl+C to exit gracefully

Enable Dashboard

# Recommended settings for optimal dashboard experience
poetry run apolo --dashboard --generator_interval 3 --reporter_interval 10

# Enable web dashboard (also works alongside TUI)
poetry run apolo --api --api-port 8000

# Both together
poetry run apolo --dashboard --api --generator_interval 3 --reporter_interval 10

🌐 Web Dashboard

The system includes a modern web dashboard built with FastAPI for browser-based monitoring:

πŸŽ›οΈ Endpoints

Endpoint Description
GET / HTML dashboard with auto-refresh (every 3s)
GET /api/stats JSON API with real-time system and mission stats
GET /docs Swagger UI for API exploration

Usage

# Enable the web dashboard
poetry run apolo --api --generator_interval 3 --reporter_interval 10

# Open in browser
open http://localhost:8000

The web dashboard displays the same real-time information as the TUI dashboard:

  • πŸ“ Files Generated: Total log files created in current session
  • πŸ”„ Current Cycle: Active generation cycle number
  • ⏰ Last Report: Timestamp of most recent statistical report
  • πŸš€ Mission Statistics: Per-mission device counts and status breakdowns with color-coded badges
  • ⚑ Auto-refresh: Updates every 3 seconds via JavaScript fetch API
  • πŸ“‘ REST API: Machine-readable JSON at /api/stats for external integrations

πŸ—οΈ Architecture

The system follows a modular architecture with clear separation of concerns:

General Architecture

High-level system architecture

Detailed Architecture

Detailed component interactions

πŸ“ Project Structure

apolo-11/
β”œβ”€β”€ πŸ“ apolo_11/
β”‚   β”œβ”€β”€ πŸ“ config/
β”‚   β”‚   └── πŸ“„ config.yaml      # System configuration
β”‚   β”œβ”€β”€ πŸ“ src/
β”‚   β”‚   β”œβ”€β”€ πŸ“„ classes.py       # Mission and Device classes
β”‚   β”‚   β”œβ”€β”€ πŸ“„ cli.py           # Async CLI entry point
β”‚   β”‚   β”œβ”€β”€ πŸ“„ config.py        # ConfigManager
β”‚   β”‚   β”œβ”€β”€ πŸ“„ dashboard.py     # TUI Dashboard with Rich
β”‚   β”œβ”€β”€ πŸ“„ web_dashboard.py # Web Dashboard with FastAPI
β”‚   β”‚   β”œβ”€β”€ πŸ“„ generator.py     # Log generator
β”‚   β”‚   β”œβ”€β”€ πŸ“„ logging_config.py # Centralized logging
β”‚   β”‚   β”œβ”€β”€ πŸ“„ messaging.py     # RabbitMQ message broker
β”‚   β”‚   └── πŸ“„ reporter.py      # Report processor
β”‚   └── πŸ“ results/             # Generated data (backups, reports)
β”œβ”€β”€ πŸ“ tests/
β”‚   └── πŸ“ tests_src/           # Unit and property tests (65+)
β”œβ”€β”€ πŸ“ docs/
β”‚   └── πŸ“ images/              # Diagrams and visual documentation
β”œβ”€β”€ πŸ“„ main.py                  # Backward-compatible entry point
β”œβ”€β”€ πŸ“ k8s/                     # Kubernetes manifests
β”‚   β”œβ”€β”€ πŸ“„ apolo-configmap.yaml
β”‚   β”œβ”€β”€ πŸ“„ apolo-deployment.yaml
β”‚   β”œβ”€β”€ πŸ“„ apolo-pvc.yaml
β”‚   β”œβ”€β”€ πŸ“„ apolo-service.yaml
β”‚   β”œβ”€β”€ πŸ“„ rabbitmq-ingress.yaml
β”‚   β”œβ”€β”€ πŸ“„ rabbitmq-service.yaml
β”‚   β”œβ”€β”€ πŸ“„ rabbitmq-statefulset.yaml
β”‚   └── πŸ“„ README.md
β”œβ”€β”€ πŸ“„ Dockerfile               # Docker image build
β”œβ”€β”€ πŸ“„ docker-compose.yml       # Multi-service orchestration
└── πŸ“„ pyproject.toml           # Project dependencies

πŸ§ͺ Testing

The project maintains high code quality with comprehensive testing:

Test Coverage

  • βœ… 88 Tests Passing: All tests pass consistently
  • πŸ“Š 96% Coverage: Excellent test coverage across all modules
  • πŸ”¬ Property-Based Testing: Using Hypothesis for robust validation
  • πŸ§ͺ Unit Testing: Comprehensive unit tests for all components

Run Tests

# Run all tests with coverage report
poetry run pytest --cov=apolo_11 --cov-report=term-missing --cov-report=html

# Run tests in verbose mode
poetry run pytest -v

# Run specific test file
poetry run pytest tests/tests_src/test_dashboard.py -v

# Generate HTML coverage report
poetry run pytest --cov=apolo_11 --cov-report=html
# Open htmlcov/index.html in browser

Test Types

  • Unit Tests: Test individual components and functions
  • Property-Based Tests: Test universal properties using Hypothesis
  • Integration Tests: Test component interactions
  • Edge Case Tests: Test error conditions and boundary cases

βš™οΈ Configuration

The system is highly configurable through the apolo_11/config/config.yaml file:

Configuration Options

# Mission definitions
missions:
  codes:
    OrbitOne: ORBONE
    GalaxyTwo: GALXTWO
  names:
    - OrbitOne
    - GalaxyTwo

# Device specifications
devices:
  types:
    - Satellite
    - Rover
  status:
    - excellent
    - good
    - warning

# System settings
general:
  num_files_initial: 1
  num_files_final: 100
  time_cycle: 20

# Logging configuration
logging:
  level: INFO
  format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"

# Directory paths
routes:
  results: ./apolo_11/results
  devices: ./apolo_11/results/devices
  backups: ./apolo_11/results/backups/
  reports: ./apolo_11/results/reports/

Customization

  • Missions: Add new space missions and their codes
  • Devices: Define device types and status options
  • Logging: Configure log levels and formats
  • Paths: Customize directory structure
  • Intervals: Set generation and reporting frequencies

⚠️ Known Limitations

  • Timing Constraints: Reporter interval must exceed generator interval to prevent data accumulation
  • Concurrency: No support for multiple simultaneous instances accessing the same log files
  • Error Handling: Basic error handling for malformed log files may need enhancement
  • Resource Usage: Large datasets may require additional memory optimization

☸️ Kubernetes

Deploy to any Kubernetes cluster (tested on Docker Desktop & Kind):

# Deploy everything
kubectl apply -f k8s/

# Watch pods
kubectl get pods -w

Cluster Architecture

Resource Description
rabbitmq StatefulSet + Service (AMQP 5672, Mgmt 15672)
apolo-11 Deployment with TUI + Web dashboard (port 8000)
apolo-config ConfigMap mounted at /app/apolo_11/config/
apolo-results PVC for persistent mission data
apolo-ingress Ingress for apolo.local and rabbitmq.local

Access

# Web dashboard
kubectl port-forward svc/apolo-11 8000:8000
# Open http://localhost:8000

# RabbitMQ management
kubectl port-forward svc/rabbitmq 15672:15672
# Open http://localhost:15672 (guest/guest)

# View logs
kubectl logs -l app=apolo-11 -f

See k8s/README.md for full instructions.

🐳 Docker

Standalone container

docker build -t apolo-11 .
docker run --rm apolo-11 --dashboard --api --generator_interval 3 --reporter_interval 10

Mount a volume to persist results:

docker run --rm -v $(pwd)/results:/app/apolo_11/results -p 8000:8000 apolo-11 --api --generator_interval 3 --reporter_interval 10

Docker Compose (with RabbitMQ)

docker compose up --build

Starts two services:

Service Image Ports
rabbitmq rabbitmq:3-management 5672 (AMQP)
15672 (Management)
apolo-11 (built from Dockerfile) β€”

The management UI is available at http://localhost:15672 (guest/guest).

Environment Variables

Variable Default Description
RABBITMQ_HOST β€” RabbitMQ host. Unset = no messaging

πŸ“¨ Message Broker (RabbitMQ)

When RABBITMQ_HOST is set, the generator publishes events to the apolo.generated topic exchange after each cycle:

{
  "cycle": 5,
  "files_count": 50,
  "num_files_min": 1,
  "num_files_max": 10,
  "timestamp": "2026-05-14 20:00:00"
}

External consumers can subscribe to apolo.generated for real-time monitoring, dashboards, or archiving. The system works with full functionality when RabbitMQ is not available β€” messaging is optional and zero-overhead when disabled.

🚧 Recent Improvements

  • βœ… Web Dashboard: FastAPI with auto-refresh HTML, JSON API, and Swagger docs
  • βœ… Kubernetes: Service + Ingress for web dashboard and RabbitMQ
  • βœ… CI Manifest Validation: Kubeconform validates all k8s manifests in CI
  • βœ… Architecture: Eliminated side-effect imports β€” no IO at module load time
  • βœ… Dependency Injection: All components accept optional config, testable without mocks
  • βœ… Config Stability: Routes changed from fragile list indices to dict keys
  • βœ… Package Safety: State file moved out of package source to results directory
  • βœ… CLI Entry Point: apolo command works after pip install (no more python main.py)
  • βœ… CI/CD: GitHub Actions with matrix testing across Python 3.10–3.12
  • βœ… Security: Patched pytest (CVE-2024-11305) and Pygments (CVE-2024-43791)
  • βœ… Logging: No longer stomps on root logger β€” safe as a library
  • βœ… SIGTERM Handling: Graceful shutdown on kill signal
  • πŸ”„ Future: Web dashboard with WebSocket real-time updates

πŸ”’ Security

See SECURITY.md for the planned security hardening roadmap, including:

  • πŸ›‘οΈ Running containers as non-root
  • πŸ”‘ RabbitMQ credentials in Kubernetes Secrets
  • πŸ“Š Resource limits and probes
  • πŸ” Container image vulnerability scanning
  • 🚧 Network policies and PodDisruptionBudget

Contributions to improve security are welcome!

🀝 Contributing

We welcome contributions! Please see our contributing guidelines:

  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 Setup

# Clone your fork
git clone git@github.com:yourusername/apolo-11.git
cd apolo-11

# Install development dependencies
poetry install

# Run tests before committing
poetry run pytest --cov=apolo_11 --cov-fail-under=95

# Run linting
poetry run flake8 apolo_11/

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Authors

Built with ❀️ by:

πŸš€ Alejandra Quiroz GΓ³mez β€’ Sara Palacio β€’ Jose Julian Mosquera Fuli

Softserve Python Bootcamp Challenge


⭐ Star this repository if you found it helpful!

πŸ› Report Bug β€’ ✨ Request Feature β€’ πŸ“– Documentation

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors