# flypzed/arsw-lab07 architecture

> Architecture diagram of the GitHub repository flypzed/arsw-lab07, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flypzed/arsw-lab07
- Repository: https://github.com/flypzed/arsw-lab07

## Overview

##### Project’s Main Components
- Frontend Client:
– Located in src/main/resources/static, with index.html for the main page and JavaScript files (apiclient.js, apimock.js, app.js) handling client-side logic.
- REST API Layer (Controller):
– Found in the package edu.eci.arsw.blueprints.controllers. The BlueprintAPIController handles incoming HTTP requests, orchestrates service calls, and returns responses.
– Includes error handling components, for example, ResourceNotFoundException.
- Service Layer:
– Present in edu.eci.arsw.blueprints.services. The BlueprintsServices class represents the business logic that processes operations before interacting with persistent storage. This layer acts as the intermediary between the API endpoints and backend storage.
- Persistence Layer:
– Represented by the interfaces and classes in edu.eci.arsw.blueprints.persistence, such as BlueprintsPersistence and its implementation InMemoryBlueprintPersistence. This “in-memory” persistence component simulates the database functionality.
- Filtering Component:
– The project also includes a filtering module (edu.eci.arsw.blueprints.filter and its implementations: RedundancyFilter, SubsamplingFilter), which likely processes or modifies blueprint data as needed (perhaps to remove contradictions or reduce data before storage/display).

##### Relationships and Interactions
– The Frontend Client invokes REST endpoints exposed by the BlueprintAPIController.
– The Controller forwards requests to the Service Layer (BlueprintsServices) to execute the core business logic.
– The Service Layer interacts with the Persistence Layer (using InMemoryBlueprintPersistence) to store, retrieve, or modify blueprint data.
– The Filtering Components are applied (either before persisting data or before sending it back to the client) to ensure data integrity or optimize the results.
– Exception handling components (e.g., ResourceNotFoundException) are incorporated into the REST API to manage error states and display meaningful error messages.

##### Architectural Patterns and Design Principles
– Separation of Concerns / Layered Architecture: Each layer (frontend, controller, service, persistence) handles a distinct responsibility.
– RESTful API Design: The blueprint API is designed to serve data in a client-server manner.
– In-Memory Data Persistence: Although simplified for demo or testing, the use of InMemoryBlueprintPersistence reflects the pattern of abstracting data access behind an interface, potentially allowing a later swap to a more robust database solution.
– Data Filtering: The implementation of different filtering strategies (RedundancyFilter and SubsamplingFilter) suggests the application uses a modular approach to process data.

##### Relevant Technologies and Frameworks
– Java (with Maven indicated by pom.xml) is used on the backend.
– Likely Spring Boot, considering the package structure (the main application class BlueprintsAPIApplication) and the convention for serving static resources.
– HTML5 and JavaScript are used for the frontend.
– In-memory storage is employed, with the possibility to extend to persistent storage.

– Next, show the API Controller acting as the gateway to the backend.
– Below, represent the Persistence component (implemented via an in-memory mechanism) that the services interact with.
– Additionally, illustrate the Filtering Component as an auxiliary service provided during data processing.
– Finally, illustrate exception handling paths that feed back error information to the client as needed.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Section
    F_Client("HTML5/JS Client"):::frontend
    F_index("index.html"):::frontend
    F_apiclient("apiclient.js"):::frontend
    F_apimock("apimock.js"):::frontend
    F_app("app.js"):::frontend

    %% Controller Section
    C_API("BlueprintAPIController"):::controller
    C_Exception("ResourceNotFoundException"):::exception

    %% Service Layer
    S_Services("BlueprintsServices"):::service

    %% Persistence Layer
    P_Imbp("InMemoryBlueprintPersistence"):::persistence

    %% Filtering Modules
    F_Red("RedundancyFilter"):::filter
    F_Sub("SubsamplingFilter"):::filter

    %% Relationships
    F_Client -->|"contains"| F_index
    F_Client -->|"contains"| F_apiclient
    F_Client -->|"contains"| F_apimock
    F_Client -->|"contains"| F_app
    F_Client -->|"RESTAPICall"| C_API

    C_API -->|"invoke"| S_Services
    C_API -->|"handlesError"| C_Exception

    S_Services -->|"CRUD"| P_Imbp
    S_Services -->|"applyFilter"| F_Red
    S_Services -->|"applyFilter"| F_Sub

    %% Click Events
    click F_Client "https://github.com/flypzed/arsw-lab07/tree/main/src/main/resources/static"
    click F_index "https://github.com/flypzed/arsw-lab07/blob/main/src/main/resources/static/index.html"
    click F_apiclient "https://github.com/flypzed/arsw-lab07/blob/main/src/main/resources/static/js/apiclient.js"
    click F_apimock "https://github.com/flypzed/arsw-lab07/blob/main/src/main/resources/static/js/apimock.js"
    click F_app "https://github.com/flypzed/arsw-lab07/blob/main/src/main/resources/static/js/app.js"
    click C_API "https://github.com/flypzed/arsw-lab07/blob/main/src/main/java/edu/eci/arsw/blueprints/controllers/BlueprintAPIController.java"
    click C_Exception "https://github.com/flypzed/arsw-lab07/blob/main/src/main/java/edu/eci/arsw/blueprints/controllers/ResourceNotFoundException.java"
    click S_Services "https://github.com/flypzed/arsw-lab07/blob/main/src/main/java/edu/eci/arsw/blueprints/services/BlueprintsServices.java"
    click P_Imbp "https://github.com/flypzed/arsw-lab07/blob/main/src/main/java/edu/eci/arsw/blueprints/persistence/impl/InMemoryBlueprintPersistence.java"
    click F_Red "https://github.com/flypzed/arsw-lab07/blob/main/src/main/java/edu/eci/arsw/blueprints/filter/impl/RedundancyFilter.java"
    click F_Sub "https://github.com/flypzed/arsw-lab07/blob/main/src/main/java/edu/eci/arsw/blueprints/filter/impl/SubsamplingFilter.java"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef controller fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef service fill:#ffff99,stroke:#000,stroke-width:1px;
    classDef persistence fill:#ffcc99,stroke:#000,stroke-width:1px;
    classDef filter fill:#ff9999,stroke:#000,stroke-width:1px;
    classDef exception fill:#dda0dd,stroke:#000,stroke-width:1px;
```
