How kianis4/saftey-net works
Project Type and Purpose
• This is a desktop Java application that maps NYPD crime data to New York City regions. It targets tourists and real estate investors by allowing them to explore crime frequency comparisons, time period analyses, location-specific queries, and identifying the safest path between areas using Dijkstra’s algorithm.
• The project leverages Java SE 10 and employs external libraries like OpenCSV (for CSV parsing), Gson (for JSON parsing), and Commons Lang3.
Analyzing the File Structure
• Top-Level Organization:
• The primary project folder (2XB3_GR02_FinalProject) contains directories for source code (src/src) and libraries (lib). There’s also a Specification folder that includes project documentation (including a PDF and LaTeX files), and unit test files are present in the src folder.
• Key Files:
• Configuration files like .gitignore, Eclipse-related settings ensure consistency and environment setup.
• Architectural Implications:
• The file structure follows a modular design where different classes reside in a single “src” package. The test classes are conveniently paired with the domain classes.
• Use of libraries suggests that data parsing/integration with external web services (e.g., LocationIQ for geocoding) is a central aspect of the design.
Main Components
a. User Interface Component:
• Represented by the Interface class.
• This serves as the entry point and interacts directly with end-users. It collects user input, displays options, and triggers underlying processes.
b. Business Logic / Model Component:
• The Map class, which handles the majority of the querying, data processing, and interaction logic (retrieving safe/neighborhood data, crime statistics, etc.).
c. Graph Processing Component:
• ShortestPath module: Implements Dijkstra’s algorithm to determine the safest path based on crime statistics.
• EdgeWeightedDiGraph and DirectedEdge classes: Together they represent the graph structure where each vertex (neighborhood) and its directed edges (connections weighted by crime data) are modeled.
d. Data Model / Domain Entities:
• ChunkT: Represents a neighborhood (a “chunk”) and encapsulates crime data.
• CrimeT: Represents individual crimes with attributes such as date, description, and location.
• CoordinateT: Represents geographical coordinates (latitude, longitude) and includes distance calculations.
e. External Dependencies and Libraries:
• A layer or side-note indicating the involvement of libraries such as opencsv, gson, and commons-lang3.
Relationships and Data Flow
• The Interface (entry point) communicates directly with the Map and ShortestPath modules.
• The Map component aggregates data and interacts with the Domain Entities (ChunkT, CrimeT, CoordinateT).
• The ShortestPath component depends on the EdgeWeightedDiGraph and DirectedEdge classes to perform route calculations.
• External libraries and services (such as CSV/JSON parsing and geocoding APIs) provide support across these components.
• That user input flows from the Interface to the Map and ShortestPath, and in turn, processed data (crime info and path details) flows back to the Interface for output.
Architectural Patterns and Design Principles
• Modular design: Components are well-separated (UI, business logic, data models) which is critical to maintainability.
• Model-Controller-like behavior: While not strictly MVC, the Interface acts as a controller coordinating between user interactions and the underlying models (Map and Domain classes).
• Abstraction of graph-based algorithms: The ShortestPath and graph representation classes clearly isolate algorithm logic from user interaction.