How snmcodes99/disaster-management works
Project type and purpose
• This is a modular, C-based, terminal “Disaster Relief Resource Management System.”
• Purpose: manage cities as nodes in a weighted graph, accept disaster requests (with urgency and resource needs), compute nearest support city via Dijkstra, allocate resources (priority queue + hashmap), update statuses, and log allocations.
File structure
• Top-level C source/Header pairs:
• graph.c/h → graph representation (adjacency lists)
• dijkstra.c/h → shortest-path algorithm (min-heap)
• resources.c/h → request processing (max-heap + hashmap)
• utils.c/h → I/O, menu, logging support
• main.c → CLI/menu orchestrator
• Other files: Makefile (build), allocation_logs.txt (persistence), markfile/disaster_relief.exe (artifacts), .vscode (IDE settings).
README insights
• Describes each module’s responsibilities, data structures, complexity.
• Workflow: user + main menu → resources module (queues) → graph + dijkstra → update structures → log file.
• Emphasizes modular code, menu interface, file logging, cross-platform cleanup.
a. Main components
• CLI/Menu Layer (main.c + utils)
• Graph Module (graph.c/h)
• Dijkstra Module (dijkstra.c/h)
• Resources Module (resources.c/h)
• Persistence Layer (allocation_logs.txt)
• Data Structures: Priority Queues (min-heap/max-heap), Hashmap
b. Relationships & interactions
1. User invokes CLI → main.c (Menu system via utils)
2. “Add city/road” commands call Graph Module to update adjacency lists
3. “Raise Request” adds an entry to the max-heap in Resources Module + hashmap
4. “Allocate Resources” in Resources Module:
– Extracts highest-urgency request
– Calls Dijkstra Module, passing graph data structures
– Receives shortest path + distance
– Updates request status in hashmap
– Writes entry to allocation_logs.txt via Utils
5. “Display Status/Logs” commands read from in-memory hashmap or file
c. Architectural patterns/design principles
• Layered modular design (separation of concerns)
• Data abstraction (graph, queues, hashmap behind APIs)
• Single responsibility per module
• File-based persistence for logs (append-only)
d. Technologies & libraries
• Standard C (C99)
• Custom min/max heaps, hashmap chaining
• stdio, stdlib, string
• Makefile for build orchestration
Key elements to capture
• Module boundaries and APIs
• Data structures behind each module (adjacency list, heaps, hashmap)
• The request lifecycle: queuing → path calculation → allocation → logging
• Build artifact (Makefile) and persistence (allocation_logs.txt)