# boanlai/assignment0704 architecture

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

- Interactive diagram: https://gitdiagram.com/boanlai/assignment0704
- Repository: https://github.com/boanlai/assignment0704

## Overview

##### Project type and purpose
- This is a Maven-based Java EE web application (an interview assignment implementing a seating chart and employee management UI).
- It follows a classic 3-tier architecture: Presentation (JSP + JavaScript), Business (domain objects and controllers), and Data Access (DAO/Service + Database).

##### File structure
- Top-level artifacts
- pom.xml → Maven build + dependencies
- src/main/webapp → JSPs, JavaScript, web.xml, context.xml
- src/main/java/com/business → domain controllers and model objects
- src/main/java/com/data → DAO interfaces, JNDI DAO implementations, Service façade, VO (Value Objects)
- src/main/java/com/common → XSSFilter
- src/main/webapp/DB → SQL initialization script
- web.xml & context.xml define the web filter, servlet mappings (if any), and JNDI DataSource

##### README
- Minimal description: “an interview assignment,” confirming this is a simple CRUD/demo web app

##### Main components
a. Client Browser
- index.jsp + JavaScript modules (addEventListener.js, changeSeatColor.js, insertEmp.js, insertSeat.js, pageInit.js, resetSeatingChart.js)
b. Web Container (e.g., Apache Tomcat)
- XSSFilter (com.common.XSSFilter)
- JSP Rendering Engine
- Servlet container (executes JSP calls into com.business classes)
c. Presentation Layer
- JSP pages under /presentation
- JavaScript front-end logic
d. Business Layer
- com.business.MainPage, SeatingChart, Employee domain classes
- Orchestrates user actions and calls Service layer
e. Service Layer (facade)
- com.data.employee.EmployeeService
- com.data.seatingChart.SeatService
f. Data Access Layer (DAO)
- Interfaces: EmployeeDAO_interface, SeatDAO_interface
- JNDI implementations: EmployeeJNDIDAO, SeatJNDIDAO
- VO classes: EmployeeVO, SeatVO
g. Database
- RDBMS (configured via JNDI in context.xml)
- Initialized by bank_assignment.sql

##### Relationships & data flow
1. User issues HTTP request → Browser
2. → Web Container
a. XSSFilter sanitizes input
b. Request dispatched to JSP or servlet/controller in com.business
3. Business Layer processes request, builds domain objects
4. Calls Service Layer
5. Service Layer invokes DAO interface
6. DAO (JNDI DAO) obtains JDBC Connection from DataSource → executes SQL on Database
7. Results → VO → Service → Business → JSP
8. JSP renders HTML/JS → Browser

##### Architectural patterns & design principles
- Layered architecture (Presentation → Business → Service → DAO → Database)
- DAO pattern + Service façade
- Use of JNDI for connection pooling
- XSSFilter implements Cross-Site Scripting protection

##### Elements
- Clear labels: “Browser,” “Tomcat Web Container,” “XSSFilter,” “JSP Pages,” “Business Controllers,” “Service Layer,” “DAO Layer,” “Database”
- Technology stacks: “Java/JSP/JavaScript,” “Maven,” “JNDI DataSource,” “JDBC,” “MySQL/PostgreSQL (SQL script)”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Client Browser"]:::ui
    end

    %% Web Container
    subgraph "Web Container (Tomcat)"
        direction TB
        XSSFilter["XSSFilter"]:::filter
        JSPEngine["JSP Rendering Engine"]:::ui
        JSPPages["index.jsp"]:::ui
        AEL["addEventListener.js"]:::ui
        CSC["changeSeatColor.js"]:::ui
        IE["insertEmp.js"]:::ui
        IS["insertSeat.js"]:::ui
        PI["pageInit.js"]:::ui
        RSC["resetSeatingChart.js"]:::ui
    end

    %% Business Layer
    subgraph "Business Layer"
        direction TB
        MainPage["MainPage.java"]:::business
        SeatingChart["SeatingChart.java"]:::business
        EmployeeBL["Employee.java"]:::business
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        EmployeeService["EmployeeService.java"]:::service
        SeatService["SeatService.java"]:::service
    end

    %% DAO Layer
    subgraph "DAO Layer"
        direction TB
        EmpDAO_I["EmployeeDAO_interface.java"]:::data
        SeatDAO_I["SeatDAO_interface.java"]:::data
        EmpJNDI["EmployeeJNDIDAO.java"]:::data
        SeatJNDI["SeatJNDIDAO.java"]:::data
        EmpVO["EmployeeVO.java"]:::data
        SeatVO["SeatVO.java"]:::data
    end

    %% Database
    subgraph "Database"
        direction TB
        DB["RDBMS<br/>(initialized by SQL script)"]:::database
        SQLScript["bank_assignment.sql"]:::config
    end

    %% Configuration
    pom["pom.xml"]:::config
    webxml["web.xml"]:::config
    context["context.xml"]:::config

    %% Connections
    Browser -->|HTTP Request| XSSFilter
    XSSFilter --> JSPEngine
    JSPEngine --> JSPPages
    JSPPages --> AEL
    JSPPages --> CSC
    JSPPages --> IE
    JSPPages --> IS
    JSPPages --> PI
    JSPPages --> RSC
    JSPPages --> MainPage
    JSPPages --> SeatingChart
    JSPPages --> EmployeeBL

    MainPage -->|calls| EmployeeService
    MainPage -->|calls| SeatService
    SeatingChart -->|calls| EmployeeService
    SeatingChart -->|calls| SeatService
    EmployeeBL -->|calls| EmployeeService
    EmployeeBL -->|calls| SeatService

    EmployeeService --> EmpDAO_I
    SeatService --> SeatDAO_I

    EmpDAO_I --> EmpJNDI
    SeatDAO_I --> SeatJNDI

    EmpJNDI -->|JDBC via DataSource| DB
    SeatJNDI -->|JDBC via DataSource| DB

    EmpJNDI --> EmpVO
    SeatJNDI --> SeatVO

    DB --> SQLScript

    pom -->|build config| Browser
    webxml -->|servlet/filter mapping| XSSFilter
    context -->|JNDI DataSource| EmpJNDI

    %% Click Events
    click JSPPages "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/index.jsp"
    click AEL "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/js/addEventListener.js"
    click CSC "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/js/changeSeatColor.js"
    click IE "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/js/insertEmp.js"
    click IS "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/js/insertSeat.js"
    click PI "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/js/pageInit.js"
    click RSC "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/presentation/js/resetSeatingChart.js"
    click XSSFilter "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/common/XSSFilter.java"
    click webxml "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/WEB-INF/web.xml"
    click context "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/META-INF/context.xml"
    click MainPage "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/business/MainPage.java"
    click SeatingChart "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/business/SeatingChart.java"
    click EmployeeBL "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/business/Employee.java"
    click EmployeeService "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/employee/EmployeeService.java"
    click SeatService "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/seatingChart/SeatService.java"
    click EmpDAO_I "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/employee/EmployeeDAO_interface.java"
    click SeatDAO_I "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/seatingChart/SeatDAO_interface.java"
    click EmpJNDI "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/employee/EmployeeJNDIDAO.java"
    click SeatJNDI "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/seatingChart/SeatJNDIDAO.java"
    click EmpVO "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/employee/EmployeeVO.java"
    click SeatVO "https://github.com/boanlai/assignment0704/blob/main/src/main/java/com/data/seatingChart/SeatVO.java"
    click SQLScript "https://github.com/boanlai/assignment0704/blob/main/src/main/webapp/DB/bank_assignment.sql"
    click pom "https://github.com/boanlai/assignment0704/blob/main/pom.xml"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,color:#004D40;
    classDef filter fill:#FFEBEE,stroke:#B71C1C,color:#B71C1C;
    classDef business fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20;
    classDef service fill:#FFF3E0,stroke:#E65100,color:#E65100;
    classDef data fill:#ECEFF1,stroke:#455A64,color:#263238;
    classDef database fill:#F3E5F5,stroke:#4A148C,color:#4A148C;
    classDef config fill:#FFF9C4,stroke:#F57F17,color:#F57F17;
```
