# akashreya/was_cloud architecture

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

- Interactive diagram: https://gitdiagram.com/akashreya/was_cloud
- Repository: https://github.com/akashreya/was_cloud

## Overview

##### Project Type and Purpose
- This is a Java-based full-stack web application (“seat assignment system”) built with Servlet/JSP front-end, Spring 3.1 MVC, Hibernate 3 ORM, and MySQL persistence. It follows a classic layered MVC + DAO architecture.

##### Main Components
a. Client Layer
- Browser/UI – JSP pages (index.jsp, createEmployeeAjax.jsp, createSeatAjax.jsp) plus static assets (CSS, JS, images).
b. Web/Application Server
- Web Container (Tomcat/WebSphere) hosting:
– DispatcherServlet (Spring MVC)
– FrontController (com.smartans.controller.FrontController)
– WASServletContextListener (com.smartans.listener)
c. Service Layer
- Interfaces and implementations for business logic (MaintainEmployees, MaintainSeats, MaintainDesignations, SeatAssignment)
d. Data Access Layer
- DAO interfaces and impls (ManageEmployeesDaoImpl, ManageSeatsDaoImpl, ManageDesignationDaoImpl, SeatAssignmentDaoImpl)
- Mappers (e.g., EmployeeMapper) for DTO ⇄ entity translation
e. Persistence & Cache
- Hibernate SessionFactory (hibernate.cfg.xml, .hbm.xml mapping files)
- Connection pool (c3p0/proxool)
- Second-level cache (Ehcache)
f. Database
- MySQL (scripts/scripts.sql, testdata.sql)
g. Cross-cutting Concerns
- Logging (Log4J)
- Transactions (Spring’s transaction management)
- Validation/Error handling (custom exception classes)

##### Relationships & Data Flow
- User → HTTP Request → DispatcherServlet
- DispatcherServlet → FrontController (routes to specific @Controller or handler)
- FrontController → Service Layer (calls business interfaces)
- Service Layer → DAO Layer (CRUD via Hibernate Session)
- DAO Layer → MySQL DB
- Responses bubble back through layers to UI

##### Architectural Patterns & Principles
- MVC (Spring MVC) separating view (JSP) from controllers and business logic
- Service/DAO layered architecture
- Dependency Injection/IoC (Spring beans defined in applicationContext.xml, dispatcher-servlet.xml)
- ORM + caching (Hibernate + Ehcache)
- Transaction management via Spring
- Exception hierarchy for domain errors

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["Browser/UI (JSP + Static Assets)"]:::ui
        indexJSP["index.jsp"]:::ui
        createEmpJSP["createEmployeeAjax.jsp"]:::ui
        createSeatJSP["createSeatAjax.jsp"]:::ui
        styleCSS["style.css"]:::ui
        scriptJS["script.js"]:::ui
        images["images/"]:::ui
    end

    %% Web/Application Server Layer
    subgraph "Web Layer" 
        direction TB
        Dispatcher["DispatcherServlet"]:::web
        appCtx["applicationContext.xml"]:::web
        dispatchCfg["dispatcher-servlet.xml"]:::web
        FrontCtrl["FrontController"]:::web
        Listener["WASServletContextListener"]:::web
        webXml["web.xml"]:::web
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        EmpServiceIntf["MaintainEmployees (Interface)"]:::service
        EmpServiceImpl["MaintainEmployeesImpl"]:::service
        SeatServiceIntf["MaintainSeats (Interface)"]:::service
        SeatServiceImpl["MaintainSeatsImpl"]:::service
        DesigServiceIntf["MaintainDesignations (Interface)"]:::service
        DesigServiceImpl["MaintainDesignationImpl"]:::service
        AssignServiceIntf["SeatAssignment (Interface)"]:::service
        AssignServiceImpl["SeatAssignmentImpl"]:::service
    end

    %% DAO Layer
    subgraph "Data Access Layer"
        direction TB
        EmpDaoIntf["ManageEmployeesDao (Interface)"]:::dao
        EmpDaoImpl["ManageEmployeesDaoImpl"]:::dao
        EmpMapper["EmployeeMapper"]:::dao
        SeatDaoIntf["ManageSeatsDao (Interface)"]:::dao
        SeatDaoImpl["ManageSeatsDaoImpl"]:::dao
        SeatMapper["SeatMapper"]:::dao
        DesigDaoIntf["ManageDesignationDao (Interface)"]:::dao
        DesigDaoImpl["ManageDesignationDaoImpl"]:::dao
        AssignDaoIntf["SeatAssignmentDao (Interface)"]:::dao
        AssignDaoImpl["SeatAssignmentDaoImpl"]:::dao
        AssignMapper["SeatAssignmentMapper"]:::dao
    end

    %% Persistence & Cache Layer
    subgraph "Persistence & Cache"
        direction TB
        HibernateCfg["hibernate.cfg.xml"]:::infra
        MappingEmp["Employee.hbm.xml"]:::infra
        MappingDesig["Designation.hbm.xml"]:::infra
        MappingSeat["Seat.hbm.xml"]:::infra
        Ehcache["Ehcache (jar)"]:::infra
        C3P0["c3p0 (jar)"]:::infra
        Proxool["proxool (jar)"]:::infra
    end

    %% Database Layer
    subgraph "Database"
        direction TB
        MySQL["MySQL DB"]:::db
        Scripts["scripts.sql / testdata.sql"]:::db
    end

    %% Cross-cutting Concerns
    subgraph "Cross-cutting Concerns"
        direction TB
        Logging["Log4J"]:::infra
        Transactions["Spring Tx"]:::infra
        Validation["Exception Handling"]:::infra
        Constants["WASConstants & Utils"]:::infra
    end

    %% Data Flow
    Browser -->|HTTP request| Dispatcher
    indexJSP --> Browser
    createEmpJSP --> Browser
    createSeatJSP --> Browser
    Browser --> indexJSP
    Browser --> createEmpJSP
    Browser --> createSeatJSP

    Dispatcher -->|routes request| FrontCtrl
    FrontCtrl -->|invoke| EmpServiceIntf
    FrontCtrl -->|invoke| SeatServiceIntf
    FrontCtrl -->|invoke| DesigServiceIntf
    FrontCtrl -->|invoke| AssignServiceIntf

    EmpServiceIntf -->|calls| EmpDaoIntf
    EmpServiceImpl -->|implements| EmpServiceIntf
    SeatServiceImpl -->|implements| SeatServiceIntf
    DesigServiceImpl -->|implements| DesigServiceIntf
    AssignServiceImpl -->|implements| AssignServiceIntf

    EmpDaoIntf -->|CRUD via Hibernate| EmpDaoImpl
    SeatDaoIntf -->|CRUD via Hibernate| SeatDaoImpl
    DesigDaoIntf -->|CRUD via Hibernate| DesigDaoImpl
    AssignDaoIntf -->|CRUD via Hibernate| AssignDaoImpl

    EmpDaoImpl -->|uses| MappingEmp
    SeatDaoImpl -->|uses| MappingSeat
    DesigDaoImpl -->|uses| MappingDesig
    AssignDaoImpl -->|uses| AssignMapper

    EmpDaoImpl --> HibernateCfg
    SeatDaoImpl --> HibernateCfg
    DesigDaoImpl --> HibernateCfg
    AssignDaoImpl --> HibernateCfg

    HibernateCfg --> MySQL
    MappingEmp --> HibernateCfg
    MappingSeat --> HibernateCfg
    MappingDesig --> HibernateCfg

    Ehcache --> HibernateCfg
    C3P0 --> HibernateCfg
    Proxool --> HibernateCfg

    Scripts --> MySQL

    Logging --> Dispatcher
    Transactions --> EmpServiceImpl
    Transactions --> SeatServiceImpl
    Transactions --> DesigServiceImpl
    Transactions --> AssignServiceImpl
    Validation --> FrontCtrl

    %% Click Events for component mappings
    click indexJSP "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/index.jsp"
    click createEmpJSP "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/createEmployeeAjax.jsp"
    click createSeatJSP "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/createSeatAjax.jsp"
    click styleCSS "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/css/style.css"
    click scriptJS "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/js/script.js"
    click images "https://github.com/akashreya/was_cloud/tree/1.0.0/WAS/WebContent/images/"
    click dispatchCfg "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/WEB-INF/dispatcher-servlet.xml"
    click appCtx "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/WEB-INF/applicationContext.xml"
    click FrontCtrl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/controller/FrontController.java"
    click Listener "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/listener/WASServletContextListener.java"
    click webXml "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/WebContent/WEB-INF/web.xml"
    click EmpServiceIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/employees/interfaces/MaintainEmployees.java"
    click EmpServiceImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/employees/impl/MaintainEmployeesImpl.java"
    click SeatServiceIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seats/interfaces/MaintainSeats.java"
    click SeatServiceImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seats/impl/MaintainSeatsImpl.java"
    click DesigServiceIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/designation/interfaces/MaintainDesignations.java"
    click DesigServiceImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/designation/impl/MaintainDesignationImpl.java"
    click AssignServiceIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seatassignement/interfaces/SeatAssignment.java"
    click AssignServiceImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seatassignement/impl/SeatAssignmentImpl.java"
    click EmpDaoIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/employees/dao/ManageEmployeesDao.java"
    click EmpDaoImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/employees/dao/impl/ManageEmployeesDaoImpl.java"
    click EmpMapper "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/employees/mapper/EmployeeMapper.java"
    click SeatDaoIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seats/dao/ManageSeatsDao.java"
    click SeatDaoImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seats/dao/impl/ManageSeatsDaoImpl.java"
    click SeatMapper "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seats/mapper/SeatMapper.java"
    click DesigDaoIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/designation/dao/ManageDesignationDao.java"
    click DesigDaoImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/designation/dao/impl/ManageDesignationDaoImpl.java"
    click AssignDaoIntf "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seatassignement/dao/SeatAssignmentDao.java"
    click AssignDaoImpl "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seatassignement/dao/impl/SeatAssignmentDaoImpl.java"
    click AssignMapper "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/seatassignement/mapper/SeatAssignmentMapper.java"
    click HibernateCfg "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/hibernate.cfg.xml"
    click MappingEmp "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/entity/Employee.hbm.xml"
    click MappingDesig "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/entity/Designation.hbm.xml"
    click MappingSeat "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/entity/Seat.hbm.xml"
    click Scripts "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/scripts/scripts.sql"
    click Scripts "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/scripts/testdata.sql"
    click Logging "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/log4j.properties"
    click Constants "https://github.com/akashreya/was_cloud/blob/1.0.0/WAS/src/main/java/com/smartans/common/constants/WASConstants.java"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#00796B,color:#004D40
    classDef web fill:#E8F5E9,stroke:#388E3C,color:#1B5E20
    classDef service fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef dao fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
    classDef infra fill:#ECEFF1,stroke:#546E7A,color:#263238
    classDef db fill:#FFE0B2,stroke:#EF6C00,color:#E65100
```
