# sarec-lab/softwareengineering2018 architecture

> Architecture diagram of the GitHub repository sarec-lab/softwareengineering2018, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sarec-lab/softwareengineering2018
- Repository: https://github.com/sarec-lab/softwareengineering2018

## Overview

1. This repository is a Java teaching monorepo, not one cohesive product. It contains many mostly independent sample applications, homework solutions, and design-pattern exercises under separate package roots. For an architecture diagram, treat each top-level package tree as its own subsystem unless a shared resource is explicitly referenced.

2. The most complete “application” area is the chat system under `src/chatclient` and `src/chatserver`. It is split into a client, a server, and a small shared constants package. Both ends use JavaFX UI files (`FXMLDocument.fxml`) with controllers, so the UI boundary is clearly separated from network/application logic.

3. The chat server side centers on `ChatServer` and `Transcript`, suggesting a message relay plus transcript/logging responsibility. The client side centers on `ChatClient` and `ChatGateway`, which likely mediate between the UI controller and the server connection. A diagram should show: UI/controller -> gateway -> server -> transcript/persistence/logging.

4. The railway-crossing simulation is another major subsystem, duplicated in two versions: `edu.nd.sarec.railwaycrossing` and `edu.nd.sarec.railwaycrossingnew`. These appear to be an older and newer iteration of the same domain model, view layer, and simulation entry point. The “new” version also includes a test package, indicating a more testable refactor.

5. Both railway-crossing versions are organized as a classic model-view-simulation structure. The model contains infrastructure (`Road`, `RailwayTracks`, `MapBuilder`, `Direction`) and vehicles (`Car`, `Train`, `CarFactory`, `IVehicle`). The view layer contains display abstractions (`IDisplay`, `MapDisplay`, `RoadDisplay`, `TracksDisplay`, `CarImageSelector`), implying the simulation renders multiple layers of the map and moving entities.

6. The crossing gate logic is isolated in its own state-machine package under `model/infrastructure/gate`. Classes like `GateOpen`, `GateClosed`, `GateOpening`, and `GateClosing` implement `IGateState`, with `CrossingGate` as the stateful context. That means gate behavior is modeled as explicit state transitions rather than ad hoc conditionals; a diagram should show the gate as a state machine attached to the simulation.

7. The `edu.nd.sarec.drag` package is a small JavaFX-style interactive app with `DragApplication`, `Controller`, and `drag.fxml`. It appears to be a separate UI exercise centered on drag-and-drop or pointer interaction, and should be diagrammed as a self-contained MVC-like app with an FXML view and controller.

8. The `edu.nd.se2018` tree is a course examples and homework area. It contains many unrelated mini-apps and demos: maze solving, animation timers, observer-pattern weather station and cat/mouse examples, state-pattern gumball machine, and introductory week/homework exercises. These should be shown as a set of independent examples rather than one system.

9. The `headfirst` and `headfirst_design_patterns` trees are classic design-pattern sample implementations. They include adapter, decorator, factory, and strategy-style duck examples, plus multiple variants of the same pattern exercises. Architecturally, these are educational reference implementations with no shared runtime; each subfolder is a standalone demo or test drive.

10. The pipe-and-filter example under `src/pipeandfilter` is another distinct mini-architecture. `PipelineBuilder` in `setup` suggests the pipeline is assembled programmatically, while `infrastructure` contains generic filter stages such as increment, double, reverse-number, and end-of-pipe. A diagram should show a linear dataflow pipeline where numbers pass through composed filters to a terminal sink.

11. Shared assets are minimal but relevant. The `chip`, `images`, and `src/images`/texture directories indicate UI or simulation graphics assets used by some of the JavaFX demos, especially the railway-crossing views and related visual examples. These are supporting resources rather than architectural components.

12. The repo has both source and test material mixed into the same tree. Tests are present for selected examples and the `railwaycrossingnew` package, but there is no central build or deployment boundary visible in the tree. For architecture purposes, assume local execution of individual demos/tests rather than a unified server or production deployment.

13. The main architectural boundary across the entire repository is “example/application package versus support pattern/demo package.” Each application area is mostly self-contained, with its own entry point, UI, model, and tests. There is little evidence of cross-module coupling, so an accurate diagram should emphasize a portfolio of independent Java exercises rather than a layered enterprise system.

Main entry points: [`src/images`](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/images) (Assets), [`src/chatclient/FXMLDocument.fxml`](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/FXMLDocument.fxml) (Chat UI), [`src/chatserver/ChatServer.java`](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatserver/ChatServer.java) (Chat server), [`src/edu/nd/sarec/railwaycrossing/Simulation.java`](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/railwaycrossing/Simulation.java) (Rail sim)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat system"]
  node_chat_ui["Chat UI<br/>JavaFX view/controller<br/>[FXMLDocument.fxml]"]
  node_chat_gateway["Gateway<br/>client adapter<br/>[ChatGateway.java]"]
  node_chat_client["Chat client<br/>client runtime<br/>[ChatClient.java]"]
  node_chat_server["Chat server<br/>server runtime<br/>[ChatServer.java]"]
  node_chat_transcript["Transcript<br/>message log<br/>[Transcript.java]"]
  node_chat_shared["Chat constants<br/>shared constants<br/>[ChatConstants.java]"]
end

subgraph group_railway["Railway crossing"]
  node_rail_old_sim["Rail sim<br/>simulation entry<br/>[Simulation.java]"]
  node_rail_old_model["Model"]
  node_rail_old_gate{{"Gate FSM<br/>state machine"}}
  node_rail_old_view["View<br/>rendering layer"]
  node_rail_new_sim["Rail sim new<br/>simulation entry<br/>[Simulation.java]"]
  node_rail_new_model["Model new<br/>domain model"]
  node_rail_new_gate{{"Gate FSM new<br/>state machine"}}
  node_rail_new_view["View new<br/>rendering layer"]
end

subgraph group_examples["Course examples"]
  node_drag_app["Drag app<br/>JavaFX app"]
  node_drag_controller["Drag controller<br/>UI controller<br/>[Controller.java]"]
  node_se_examples["SE examples<br/>demo portfolio"]
  node_se_homework["Homework<br/>exercise set"]
end

subgraph group_patterns["Pattern samples"]
  node_headfirst_patterns["Head First<br/>pattern demos"]
  node_headfirst_ducks["Duck patterns<br/>strategy demo"]
end

subgraph group_pipeline["Pipe and filter"]
  node_pipeline_builder["Pipeline builder<br/>composition root"]
  node_pipeline_filters["Filters<br/>filter stages"]
end

subgraph group_assets["Shared assets"]
  node_shared_assets["Assets<br/>textures/images"]
end

node_chat_client -->|"launches"| node_chat_ui
node_chat_ui -->|"uses"| node_chat_gateway
node_chat_gateway -->|"connects to"| node_chat_server
node_chat_server -->|"records"| node_chat_transcript
node_chat_ui -.->|"shares"| node_chat_shared
node_chat_server -.->|"shares"| node_chat_shared
node_rail_old_sim -->|"drives"| node_rail_old_model
node_rail_old_sim -->|"renders"| node_rail_old_view
node_rail_old_model -->|"contains"| node_rail_old_gate
node_rail_old_view -.->|"loads"| node_shared_assets
node_rail_new_sim -->|"drives"| node_rail_new_model
node_rail_new_sim -->|"renders"| node_rail_new_view
node_rail_new_model -->|"contains"| node_rail_new_gate
node_rail_new_view -.->|"loads"| node_shared_assets
node_drag_app -->|"binds"| node_drag_controller
node_drag_app -.->|"loads"| node_shared_assets
node_se_examples -.->|"separated from"| node_se_homework
node_headfirst_patterns -.->|"parallel demos"| node_headfirst_ducks
node_pipeline_builder -->|"composes"| node_pipeline_filters
node_pipeline_filters -.->|"optional assets"| node_shared_assets

click node_chat_ui "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/FXMLDocument.fxml"
click node_chat_gateway "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/ChatGateway.java"
click node_chat_client "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/ChatClient.java"
click node_chat_server "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatserver/ChatServer.java"
click node_chat_transcript "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatserver/Transcript.java"
click node_chat_shared "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chat/ChatConstants.java"
click node_rail_old_sim "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/railwaycrossing/Simulation.java"
click node_rail_old_model "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossing/model"
click node_rail_old_gate "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossing/model/infrastructure/gate"
click node_rail_old_view "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossing/view"
click node_rail_new_sim "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/railwaycrossingnew/Simulation.java"
click node_rail_new_model "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossingnew/model"
click node_rail_new_gate "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossingnew/model/infrastructure/gate"
click node_rail_new_view "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossingnew/view"
click node_drag_app "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/drag/DragApplication.java"
click node_drag_controller "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/drag/Controller.java"
click node_se_examples "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/se2018/examples"
click node_se_homework "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/se2018/homework"
click node_headfirst_patterns "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/headfirst/designpatterns"
click node_headfirst_ducks "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/headfirst_design_patterns/ducks"
click node_pipeline_builder "https://github.com/sarec-lab/softwareengineering2018/blob/master/src/pipeandfilter/setup/PipelineBuilder.java"
click node_pipeline_filters "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/pipeandfilter/infrastructure"
click node_shared_assets "https://github.com/sarec-lab/softwareengineering2018/tree/master/src/images"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat_ui,node_chat_gateway,node_chat_client,node_chat_server,node_chat_transcript,node_chat_shared toneBlue
class node_rail_old_sim,node_rail_old_model,node_rail_old_gate,node_rail_old_view,node_rail_new_sim,node_rail_new_model,node_rail_new_gate,node_rail_new_view toneAmber
class node_drag_app,node_drag_controller,node_se_examples,node_se_homework toneMint
class node_headfirst_patterns,node_headfirst_ducks toneRose
class node_pipeline_builder,node_pipeline_filters toneIndigo
class node_shared_assets toneTeal
```

## Components

### Chat system

Client-server JavaFX chat example with shared constants and transcript logging.

- [Chat UI](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/FXMLDocument.fxml): JavaFX view/controller · FXML-based chat client UI and controller boundary. · `src/chatclient/FXMLDocument.fxml`
- [Gateway](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/ChatGateway.java): client adapter · Client-side bridge between UI and server connection. · `src/chatclient/ChatGateway.java`
- [Chat client](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatclient/ChatClient.java): client runtime · Client application entry point and UI host. · `src/chatclient/ChatClient.java`
- [Chat server](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatserver/ChatServer.java): server runtime · Server application entry point for message relay. · `src/chatserver/ChatServer.java`
- [Transcript](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chatserver/Transcript.java): message log · Server-side transcript or persistence/logging component. · `src/chatserver/Transcript.java`
- [Chat constants](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/chat/ChatConstants.java): shared constants · Shared chat protocol or UI constants. · `src/chat/ChatConstants.java`

### Railway crossing

Two iterations of the railway-crossing simulation with model, view, and gate state machine.

- [Rail sim](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/railwaycrossing/Simulation.java): simulation entry · Original railway-crossing simulation entry point. · `src/edu/nd/sarec/railwaycrossing/Simulation.java`
- [Model](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossing/model): domain model · Road, tracks, direction, vehicles, and map assembly for the original simulation. · `src/edu/nd/sarec/railwaycrossing/model`
- [Gate FSM](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossing/model/infrastructure/gate): state machine · Crossing gate state machine with open/closed transitions. · `src/edu/nd/sarec/railwaycrossing/model/infrastructure/gate`
- [View](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossing/view): rendering layer · Map, road, tracks, and car image selection for the original simulation. · `src/edu/nd/sarec/railwaycrossing/view`
- [Rail sim new](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/railwaycrossingnew/Simulation.java): simulation entry · Refactored railway-crossing simulation entry point. · `src/edu/nd/sarec/railwaycrossingnew/Simulation.java`
- [Model new](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossingnew/model): domain model · Refactored road, tracks, direction, vehicles, and map assembly. · `src/edu/nd/sarec/railwaycrossingnew/model`
- [Gate FSM new](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossingnew/model/infrastructure/gate): state machine · Refactored crossing gate state machine attached to the new simulation. · `src/edu/nd/sarec/railwaycrossingnew/model/infrastructure/gate`
- [View new](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/sarec/railwaycrossingnew/view): rendering layer · Refactored map, road, tracks, and car view rendering. · `src/edu/nd/sarec/railwaycrossingnew/view`

### Course examples

Independent demos and homework solutions under the SE 2018 tree.

- [Drag app](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/drag/DragApplication.java): JavaFX app · Standalone drag-and-drop style JavaFX exercise. · `src/edu/nd/sarec/drag/DragApplication.java`
- [Drag controller](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/edu/nd/sarec/drag/Controller.java): UI controller · Controller for the drag interaction UI. · `src/edu/nd/sarec/drag/Controller.java`
- [SE examples](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/se2018/examples): demo portfolio · Independent course demos covering maze, observer, state, animation, MVC, and basics. · `src/edu/nd/se2018/examples`
- [Homework](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/edu/nd/se2018/homework): exercise set · Homework solutions and tests grouped by assignment. · `src/edu/nd/se2018/homework`

### Pattern samples

Standalone design-pattern reference implementations.

- [Head First](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/headfirst/designpatterns): pattern demos · Design-pattern teaching examples and test drives. · `src/headfirst/designpatterns`
- [Duck patterns](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/headfirst_design_patterns/ducks): strategy demo · Alternate duck strategy-pattern implementation set. · `src/headfirst_design_patterns/ducks`

### Pipe and filter

Linear filter pipeline example with a builder and reusable stages.

- [Pipeline builder](https://github.com/sarec-lab/softwareengineering2018/blob/master/src/pipeandfilter/setup/PipelineBuilder.java): composition root · Assembles the pipe-and-filter pipeline. · `src/pipeandfilter/setup/PipelineBuilder.java`
- [Filters](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/pipeandfilter/infrastructure): filter stages · Increment, double, reverse-number, and terminal pipeline stages. · `src/pipeandfilter/infrastructure`

### Shared assets

Image and texture resources used by visual demos.

- [Assets](https://github.com/sarec-lab/softwareengineering2018/tree/master/src/images): textures/images · Shared visual resources used by UI and simulation examples. · `src/images`

## Connections

- Chat client → Chat UI: launches · Client starts the JavaFX UI.
- Chat UI → Gateway: uses · Controller delegates user actions to the gateway.
- Gateway → Chat server: connects to · Gateway sends client messages to the server.
- Chat server → Transcript: records · Server writes or consults transcript state.
- Chat UI → Chat constants: shares · UI and client rely on common chat constants.
- Chat server → Chat constants: shares · Server and client use the same shared constants.
- Rail sim → Model: drives · Simulation advances the domain model.
- Rail sim → View: renders · Simulation updates the visual layer.
- Model → Gate FSM: contains · Gate state machine is part of the infrastructure model.
- View → Assets: loads · View layer uses shared textures and imagery.
- Rail sim new → Model new: drives · New simulation advances the refactored model.
- Rail sim new → View new: renders · New simulation updates the visual layer.
- Model new → Gate FSM new: contains · Gate state machine is embedded in the new model.
- View new → Assets: loads · Refactored views use shared images.
- Drag app → Drag controller: binds · JavaFX app binds the FXML controller.
- Drag app → Assets: loads · App may use shared graphics resources.
- SE examples → Homework: separated from · Examples and homework are distinct teaching areas.
- Head First → Duck patterns: parallel demos · Two independent design-pattern sample trees.
- Pipeline builder → Filters: composes · Builder wires the filter chain together.
- Filters → Assets: optional assets · No strong dependency; visual resources are shared elsewhere.
