Skip to content

๐Ÿ—๏ธ Fly-in Architecture

Understanding how the project components interact and why the system is separated into multiple responsibilities.


๐Ÿ“š Table of Contents

  1. Why an Architecture?
  2. High-Level Overview
  3. MapParser
  4. Simulator
  5. PathFinder
  6. Visualizer
  7. ImageGenerator
  8. Data Flow
  9. Why Separate Classes?
  10. Single Responsibility Principle
  11. Benefits of the Architecture
  12. Mental Model

1๏ธโƒฃ Why an Architecture?

As projects grow, putting everything into a single file quickly becomes difficult to maintain.

Instead of creating one massive class responsible for:

  • parsing
  • pathfinding
  • simulation
  • visualization
  • rendering

Fly-in separates each responsibility into dedicated systems.

This makes the project:

โœ… easier to understand

โœ… easier to debug

โœ… easier to extend

โœ… easier to test


2๏ธโƒฃ High-Level Overview

Map File (.txt)
       โ”‚
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   MapParser     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Simulator     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”‚
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   PathFinder    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Visualizer
       โ”‚                  โ”‚
       โ”‚                  โ–ผ
       โ”‚            Terminal Output
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ImageGenerator  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚
       โ–ผ
 Frames + GIF

3๏ธโƒฃ MapParser

Responsibility

The parser transforms the map file into Python objects that can be used by the simulation.

Input:

connection: A-B

Output:

Connection("A", "B")

What it validates

The parser verifies:

  • syntax correctness
  • duplicated zones
  • duplicated connections
  • invalid metadata
  • invalid coordinates
  • invalid capacities
  • missing start/end zones

What it creates

zones
connections
start_zone
end_zone
nb_drones

Everything else in the project depends on this data.


4๏ธโƒฃ Simulator

Responsibility

The Simulator is the heart of the project.

It decides:

Who moves
When they move
Whether movement is valid

Tracks

occupied_zones
occupied_links
current_turn
turn_states

Handles

  • drone movement
  • zone capacities
  • link capacities
  • waiting turns
  • restricted zones
  • delivery tracking
  • turn progression

Think of it as

Air Traffic Control

The Simulator controls movement but does not calculate routes.


5๏ธโƒฃ PathFinder

Responsibility

The PathFinder answers one question:

What is the best route?

Uses

Dijkstra Algorithm
heapq Priority Queue

Considers

  • movement costs
  • restricted zones
  • blocked zones
  • priority zones
  • occupied areas

Returns

[
    "start",
    "hub",
    "corridor",
    "goal"
]

The Simulator then decides whether that route can be used.


6๏ธโƒฃ Visualizer

Responsibility

The Visualizer displays the simulation in the terminal.

It converts raw simulation data into a format that humans can easily understand.


Input

The Visualizer receives:

simul_result

Example:

{
    1: ["D1-hub", "D2-hub"],
    2: ["D1-corridor", "D3-hub"]
}

Output

Turn 1
๐Ÿ›ธ D1 โžค hub
๐Ÿ›ธ D2 โžค hub

Turn 2
๐Ÿ›ธ D1 โžค corridor
๐Ÿ›ธ D3 โžค hub

Responsibilities

The Visualizer:

  • displays turn-by-turn movements
  • formats terminal output
  • generates reports
  • improves readability
  • assists debugging

Final Report

Example:

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
       FLY-IN DRONE SIMULATION
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Total drones: 25
Delivered drones: 25
Total turns: 41
Maximum turns allowed: 45

Simulation Status: SUCCESS

Why a Separate Class?

Displaying information is not part of simulation logic.

Separating responsibilities makes future output systems easier to create:

Terminal Output
JSON Output
Web Output
GUI Output

7๏ธโƒฃ ImageGenerator

Responsibility

The ImageGenerator creates a visual representation of the simulation.


Generates

๐Ÿ“ธ Individual Frames

frame_000.png
frame_001.png
frame_002.png
...

๐ŸŽฌ Final GIF

simulation.gif

Uses

Pillow

to render:

  • zones
  • connections
  • drone distribution
  • turn information
  • simulation statistics

Purpose

The ImageGenerator is not required for the simulation itself.

It was developed to:

  • improve user experience
  • provide visual debugging
  • better understand drone movement
  • practice Pillow outside the project's requirements

8๏ธโƒฃ Data Flow

Complete execution flow:

Map File
    โ†“
MapParser
    โ†“
Zones + Connections
    โ†“
Simulator
    โ”œโ”€โ”€โ†’ Visualizer
    โ”‚         โ†“
    โ”‚   Terminal Output
    โ”‚
    โ””โ”€โ”€โ†’ PathFinder
              โ†“
      Movement Decisions
              โ†“
        Turn States
              โ†“
      ImageGenerator
              โ†“
        Frames + GIF

9๏ธโƒฃ Why Separate Classes?

A common question during evaluations is:

Why not put everything inside Simulator?

Because it would create a massive class responsible for:

  • parsing
  • pathfinding
  • simulation
  • terminal output
  • image generation

This violates the:

Single Responsibility Principle

and makes maintenance harder.


Example

If a bug exists in:

Map Parsing

the fix belongs in:

MapParser

not inside the Simulator.


๐Ÿ”Ÿ Single Responsibility Principle

One class.

One responsibility.


MapParser

Reads and validates input

Simulator

Controls simulation rules

PathFinder

Calculates optimal routes

Visualizer

Displays terminal output

ImageGenerator

Creates visual output

This separation keeps the codebase clean and maintainable.


1๏ธโƒฃ1๏ธโƒฃ Benefits of the Architecture

Because responsibilities are isolated:

โœ… easier debugging

โœ… easier testing

โœ… easier maintenance

โœ… easier feature development

โœ… lower coupling between systems


Example

Want to replace Dijkstra with A*?

Only:

PathFinder.py

requires significant changes.

The rest of the project remains untouched.


1๏ธโƒฃ2๏ธโƒฃ Mental Model

Think of the project as an airport.


๐Ÿงพ MapParser

Airport Construction Team

Builds the airport layout.


๐Ÿงญ PathFinder

GPS Navigation System

Calculates routes.


๐ŸŽฎ Simulator

Air Traffic Control

Controls movement rules.


๐Ÿ“บ Visualizer

Control Tower Screens

Displays what is happening in real time.


๐ŸŽฌ ImageGenerator

Security Cameras

Records and visualizes the entire simulation.


Each component has a clear purpose and communicates only the information required for the next stage of the simulation.