# thomas131104/rectangleangularapp architecture

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

- Interactive diagram: https://gitdiagram.com/thomas131104/rectangleangularapp
- Repository: https://github.com/thomas131104/rectangleangularapp

## Overview

##### Project type and purpose
- This is a single-page front-end application built with Angular.
- Its sole purpose is to let users calculate rectangle properties (perimeter & area) or infer rectangle dimensions (length & width) from those properties.

##### File structure
- Top-level artifacts:
- angular.json, package.json / package-lock.json – Angular CLI & npm config
- src/index.html, src/main.ts, src/styles.scss – the application shell, bootstrapping, global styles
- src/app/ – core application code
- Inside src/app/:
- app.component.* – main presentation component (UI template, styles, logic, tests)
- app.config.ts – app-wide constants or configuration
- app.routes.ts – client-side routing definitions (although this one-page app may have just one route)
- models/rectangle.ts – domain model for the rectangle with calculation methods
- services/rectangle.service.ts – business-logic layer offering methods to compute from inputs
- *.spec.ts files – unit tests for each component, model, and service

##### Extract insights from the README
- Confirms Angular & TypeScript stack.
- Describes the domain model (Rectangle) and service (RectangleService) responsibilities and public methods.
- No backend or external data stores—calculations are done entirely in the client.

##### Main components and their interactions
a. Presentation Layer (Angular Component)
- app.component.ts / .html / .scss
- Renders input fields and output displays
- Captures user events (e.g., “Compute” button clicks)
b. Configuration & Routing
- app.config.ts provides any constants (e.g., default values or UI labels)
- app.routes.ts defines any navigable views (if extended to multi-view in the future)
c. Business-Logic Layer (Service)
- RectangleService
- Exposes two main methods: fromEdges(length, width) and fromPerimeterAndArea(perimeter, area)
- Internally instantiates or delegates to the Rectangle model
d. Domain Model
- Rectangle class with methods: getLength(), getWidth(), getPerimeter(), getArea(), setLengthAndWidth(), setPerimeterAndArea()
- Holds the state of one rectangle instance
e. Testing Layer (unit tests)
- rectangle.spec.ts, rectangle.service.spec.ts, app.component.spec.ts

##### Relationships and data-flow
- User → (UI) app.component → calls → RectangleService → uses → Rectangle model → returns results → app.component → updates DOM
- Configuration constants flow into app.component and service as needed

##### Architectural patterns & principles
- Layered architecture (Presentation → Service → Model)
- Dependency injection (Angular’s DI for injecting RectangleService into app.component)
- Separation of concerns: UI logic vs. business logic vs. domain model
- Testability: each layer has its own test suite

##### Technologies & frameworks to annotate
- Angular (Component, Module, Router, DI)
- TypeScript (static typing, classes)
- SCSS for styling
- Jasmine & Karma for unit tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Shell"
        Index["index.html"]:::gray
        Main["main.ts"]:::gray
    end

    subgraph "Configuration & Routing"
        AppConfig["app.config.ts"]:::gray
        AppRoutes["app.routes.ts (Router)"]:::gray
    end

    subgraph "Presentation Layer"
        AppComponent["AppComponent"]:::presentation
    end

    subgraph "Business Logic Layer"
        RectangleService["RectangleService"]:::business
    end

    subgraph "Domain Model Layer"
        RectangleModel["Rectangle Model"]:::model
    end

    subgraph "Testing Layer"
        AppComponentTests["AppComponent Tests"]:::tests
        RectangleServiceTests["RectangleService Tests"]:::tests
        RectangleModelTests["Rectangle Model Tests"]:::tests
    end

    Index --> Main
    Main --> AppRoutes
    AppRoutes --> AppComponent
    AppConfig --> AppComponent
    AppConfig --> RectangleService
    AppComponent -->|"calls"| RectangleService
    RectangleService -->|"uses"| RectangleModel
    RectangleModel -->|"returns results"| AppComponent

    AppComponentTests -.-> AppComponent
    RectangleServiceTests -.-> RectangleService
    RectangleModelTests -.-> RectangleModel

    click AppComponent "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/app.component.ts"
    click AppComponentTests "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/app.component.spec.ts"
    click AppConfig "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/app.config.ts"
    click AppRoutes "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/app.routes.ts"
    click RectangleService "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/services/rectangle.service.ts"
    click RectangleServiceTests "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/services/rectangle.service.spec.ts"
    click RectangleModel "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/models/rectangle.ts"
    click RectangleModelTests "https://github.com/thomas131104/rectangleangularapp/blob/master/src/app/models/rectangle.spec.ts"

    classDef presentation fill:#ADD8E6,stroke:#000;
    classDef business fill:#90EE90,stroke:#000;
    classDef model fill:#FFA500,stroke:#000;
    classDef gray fill:#D3D3D3,stroke:#000;
    classDef tests fill:#E6E6FA,stroke:#000,stroke-dasharray:5 5;
```
