# avocount/altoroj-mytest architecture

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

- Interactive diagram: https://gitdiagram.com/avocount/altoroj-mytest
- Repository: https://github.com/avocount/altoroj-mytest

## Overview

##### Main Components
- Client Interface: Show the browser (or client) initiating requests to the application. Include different entry points such as the main login pages, admin pages, and REST API endpoints.
- Web Server & Servlet Container: Represent the Tomcat 7 server that hosts this application. Indicate that it serves dynamic JSP pages from the “WebContent” folder and static assets (CSS, images, SWF files, Swagger documentation).
- Frontend / Presentation Layer: Include JSP pages (and their associated fragments like header.jspf, footer.jspf, etc.) in the WebContent. Highlight directories like “bank”, “admin”, “static”, and “swagger” to show different areas of functionality.
- Application Layer (Controller): Represent the servlets and filters found in the Java source packages (under src/com/ibm/security/appscan/altoromutual). In particular, list the various servlets (LoginServlet, AccountViewServlet, AdminServlet, etc.) acting as controllers following an MVC pattern.
- Filters and Listeners: Indicate security and authentication filters (AdminFilter, ApiAuthFilter, AuthFilter) and the StartupListener which initializes the environment.
- Business Logic / Domain Model: Demonstrate the model classes (Account, Feedback, Transaction, User) that represent the core business concepts as well as the utility classes (DBUtil, OperationsUtil, ServletUtil) that support processing.
- Data Layer: Illustrate the database component (Apache Derby) where all persistent banking data is stored. Emphasize that it is automatically set up at first login based on the application’s configuration.
- REST API Component: Clearly note the existence of a fully documented REST API (using Swagger files in WebContent/swagger), which allows third parties or advanced users to interact with the system through API calls.

##### Relationships and Interactions
- Optionally, denote configuration and initialization flows—from the StartupListener reading the properties file (WEB-INF/app.properties) to configuring application parameters.

##### Architectural Patterns and Design Choices
- MVC pattern used implicitly in the application: JSPs (view), servlets (controller), and Java model classes (model).
- Security components via filters and custom authentication (e.g., ApiAuthFilter) to demonstrate access control flows.
- Point out the use of standard Java EE practices (JSP, Servlet, and listeners) rather than using high-level frameworks, which supports the educational purpose of showing raw, “vulnerable” code for learning.

##### Relevant Technologies/Frameworks
- Java EE (Servlets, JSP, etc.)
- Apache Derby as the SQL database.
- Gradle as the build tool (with build.gradle in the root).
- Tomcat 7 as the application server.
- Swagger for REST API documentation.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Client Browser"]:::client
    B["Tomcat Server (Tomcat 7)"]:::server
    A -->|"HTTP_Request"| B

    subgraph "Presentation Layer"
        C1["JSP Content (WebContent)"]:::frontend
        C2["Bank (JSPs)"]:::frontend
        C3["Admin (JSPs)"]:::frontend
        C4["Static Assets"]:::frontend
        C5["Swagger Docs"]:::frontend
        C6["index.jsp"]:::frontend
        C7["login.jsp"]:::frontend
        C8["header.jspf"]:::frontend
        C9["footer.jspf"]:::frontend
    end
    B -->|"serves"| C1

    D["Servlets (Controllers)"]:::controller
    B --> D

    E1["Filters (Auth,Admin)"]:::filter
    B --> E1

    E2["Startup Listener"]:::listener
    B --> E2

    H["REST API (API Servlets)"]:::api
    A -->|"REST_API_Request"| H

    subgraph "Business Logic Layer"
        F1["Model (Accounts,Feedback,etc.)"]:::business
        F2["Utility Classes (DBUtil,etc.)"]:::business
    end
    D -->|"invoke"| F1
    F1 --> F2
    F2 -->|"db_connection"| G["Database (Apache Derby)"]:::db
    H -->|"invoke"| F1

    E2 -->|"init_config"| I["Config (app.properties)"]:::config

    J["Gradle Build (build.gradle)"]:::build
    B --> J

    %% Click Events
    click C1 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/WebContent"
    click C2 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/WebContent/bank"
    click C3 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/WebContent/admin"
    click C4 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/WebContent/static"
    click C5 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/WebContent/swagger"
    click C6 "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/WebContent/index.jsp"
    click C7 "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/WebContent/login.jsp"
    click C8 "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/WebContent/header.jspf"
    click C9 "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/WebContent/footer.jspf"
    click D "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/src/com/ibm/security/appscan/altoromutual/servlet"
    click E1 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/src/com/ibm/security/appscan/altoromutual/filter"
    click E2 "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/src/com/ibm/security/appscan/altoromutual/listener/StartupListener.java"
    click F1 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/src/com/ibm/security/appscan/altoromutual/model"
    click F2 "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/src/com/ibm/security/appscan/altoromutual/util"
    click H "https://github.com/avocount/altoroj-mytest/tree/AltoroJ-3.2/src/com/ibm/security/appscan/altoromutual/api"
    click I "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/WebContent/WEB-INF/app.properties"
    click J "https://github.com/avocount/altoroj-mytest/blob/AltoroJ-3.2/build.gradle"

    %% Styles
    classDef client fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef server fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef frontend fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef controller fill:#fadbd8,stroke:#cd6155,stroke-width:2px;
    classDef filter fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef listener fill:#f5cba7,stroke:#d35400,stroke-width:2px;
    classDef business fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
    classDef db fill:#f2d7d5,stroke:#922b21,stroke-width:2px;
    classDef config fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef build fill:#e8f8f5,stroke:#117a65,stroke-width:2px;
    classDef api fill:#fbeee6,stroke:#ca6f1e,stroke-width:2px;
```
