# kakadiya5986/inventory-system architecture

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

- Interactive diagram: https://gitdiagram.com/kakadiya5986/inventory-system
- Repository: https://github.com/kakadiya5986/inventory-system

## Overview

This repository is a single Jakarta EE 8 application packaged as a WAR-style monolith. It combines JSF/PrimeFaces UI pages, CDI backing beans, EJB business logic, JPA entities, JWT-based security, and a small REST layer. The main architectural boundary is between the web presentation layer and the server-side business/persistence layer.

1. Presentation layer: JSF pages  
The UI lives under `src/main/webapp` as `.xhtml` pages, with separate areas for `Customer`, `Navbar`, login/register, and error pages like `Forbidden.xhtml` and `common/unauthorized.xhtml`. This suggests role-specific navigation and access-controlled views rather than a single generic front end.

2. UI backing beans  
There are two bean groupings: `JSFbeans` and `CDIBeans` / `BusinessOwnerCDIBeans`. These are the controllers for JSF pages, handling form submission, page state, and navigation. The split implies different user journeys, especially business-owner/admin workflows versus customer-facing flows.

3. Business/service layer  
The `ejb` package contains `AdminBean`, `UserBean`, and their local interfaces, plus a `Helper` class. This is the core application logic layer and likely mediates all significant operations before touching persistence. The use of EJBs indicates transaction-aware, server-managed services.

4. Domain model and persistence  
The `entity` package contains the JPA entities: `User`, `Roles`, `Business`, `Society`, `Product`, `Delivery`, and `Delivereditem`. `src/main/resources/META-INF/persistence.xml` defines the persistence unit, and `dropDB.sql` suggests the project can initialize or reset the database schema. This is the main data boundary for the application.

5. Data transfer objects for API/serialization  
The `JSONClasses` package mirrors the domain with DTO-style classes such as `Business`, `Customer`, `Employee`, `Product`, `Delivery`, `SuccessResponse`, and `ErrorResponse`. These are separate from the JPA entities, which usually means the app distinguishes internal persistence models from payloads used in REST calls or JSON mapping.

6. Security and authentication  
Security is split across `config/Security.java`, `auth/SecureAuthentication.java`, `jwtrest/TokenProvider.java`, `jwtrest/JWTCredential.java`, and `jwtrest/Constants.java`. Together these indicate JWT-based authentication and authorization. The presence of forbidden/unauthorized pages and role filters shows the app enforces access control both at the view level and through server-side request filtering.

7. Role-based request filters  
`filters/BusinessOwnerFilter.java`, `CustomerFilter.java`, and `EmployeeFilter.java` are likely servlet filters or request interceptors protecting different page groups. These are an important architectural boundary: they gate access before a request reaches the JSF backing beans or business services.

8. Outbound REST client integration  
The `client` package contains `RESTClient` and `RESTFilter`, which strongly suggests the app also consumes external REST services. The `JSONClasses` package likely supports this integration. This is a secondary data flow: application UI/business logic -> REST client -> external service -> JSON DTOs -> back into the app.

9. Exposed REST endpoint(s)  
`com.mycompany.dropapplication.resources.JakartaEE8Resource` and `servlet/testServlet.java` show the app is not only a JSF site; it also exposes at least one REST resource and one servlet endpoint for testing or integration. This is a small but separate inbound channel from the main JSF page flow.

10. Front-end structure and role segmentation  
The web content layout suggests the system is organized around user roles and functional areas: customer browsing/profile, business-owner management screens, and shared navigation. Pages like `Navbar/customers.xhtml`, `employees.xhtml`, `products.xhtml`, `societies.xhtml`, and `profile.xhtml` map to distinct management modules.

11. Overall request/data flow  
Typical flow is: browser request -> JSF page -> backing bean -> EJB service -> JPA entity/persistence. For protected pages, filters/security checks happen first. For API-style interactions, JSON DTOs and JWT utilities are used, and outbound calls go through the REST client.

12. Deployment/runtime footprint  
The build artifacts show a Jakarta EE application packaged with PrimeFaces, Jackson, and JJWT in `WEB-INF/lib`. That indicates a server-deployed Java web app, not a standalone microservice or SPA. The architecture is therefore centered on container-managed components, server-side rendering, and relational persistence.

Main entry points: [`src/main/java/CDIBeans/CustomerIndexBean.java`](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/CustomerIndexBean.java) (Customer Index), [`src/main/java/ejb/UserBean.java`](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/ejb/UserBean.java) (User Bean), [`src/main/java/filters`](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/filters) (Access Filters), [`src/main/java/BusinessOwnerCDIBeans`](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/BusinessOwnerCDIBeans) (Owner Beans)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_home_page["Home<br/>JSF view<br/>[index.xhtml]"]
  node_customer_pages["Customer UI<br/>JSF views"]
  node_navbar_pages["Nav Pages<br/>JSF views"]
  node_auth_pages["Auth Pages<br/>JSF views<br/>[Login.xhtml]"]
end

subgraph group_business["Business"]
  node_login_bean["Login Bean<br/>JSF backing bean<br/>[LoginBean.java]"]
  node_register_bean["Register Bean<br/>JSF backing bean<br/>[RegisterBean.java]"]
  node_customer_index_bean["Customer Index<br/>CDI bean"]
  node_customer_service["Customer Service<br/>CDI service"]
  node_product_service["Product Service<br/>CDI service"]
  node_owner_beans["Owner Beans<br/>CDI bean set"]
  node_admin_ejb["Admin Bean<br/>EJB service<br/>[AdminBean.java]"]
  node_user_ejb["User Bean<br/>EJB service<br/>[UserBean.java]"]
end

subgraph group_data["Data"]
  node_domain_entities[("Entities<br/>JPA model")]
  node_persistence_unit["Persistence<br/>JPA config<br/>[persistence.xml]"]
end

subgraph group_security["Security"]
  node_jwt_security{{"JWT Security<br/>auth stack"}}
  node_request_filters{{"Access Filters<br/>servlet filters"}}
end

subgraph group_integration["Integration"]
  node_json_dtos["JSON DTOs<br/>payload model"]
  node_rest_resource["REST Resource<br/>JAX-RS endpoint"]
  node_rest_client["REST Client<br/>outbound client<br/>[RESTClient.java]"]
end

node_home_page -->|"renders"| node_customer_index_bean
node_customer_pages -->|"backed by"| node_customer_index_bean
node_navbar_pages -->|"backed by"| node_owner_beans
node_auth_pages -->|"uses"| node_login_bean
node_auth_pages -->|"uses"| node_register_bean
node_login_bean -->|"authenticates"| node_jwt_security
node_register_bean -->|"creates via"| node_user_ejb
node_customer_index_bean -->|"delegates"| node_customer_service
node_customer_index_bean -->|"delegates"| node_product_service
node_owner_beans -->|"delegates"| node_admin_ejb
node_owner_beans -->|"delegates"| node_user_ejb
node_admin_ejb -->|"persists"| node_domain_entities
node_user_ejb -->|"persists"| node_domain_entities
node_domain_entities -->|"mapped by"| node_persistence_unit
node_rest_resource -->|"returns"| node_json_dtos
node_rest_client -->|"maps"| node_json_dtos
node_rest_client -->|"integrates with"| node_user_ejb
node_request_filters -->|"enforces"| node_jwt_security
node_request_filters -->|"protects"| node_customer_pages
node_request_filters -->|"protects"| node_navbar_pages
node_jwt_security -->|"supports"| node_auth_pages
node_rest_resource -.->|"coexists with"| node_home_page

click node_home_page "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/webapp/index.xhtml"
click node_customer_pages "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/webapp/Customer"
click node_navbar_pages "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/webapp/Navbar"
click node_auth_pages "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/webapp/Login.xhtml"
click node_login_bean "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/JSFbeans/LoginBean.java"
click node_register_bean "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/JSFbeans/RegisterBean.java"
click node_customer_index_bean "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/CustomerIndexBean.java"
click node_customer_service "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/CustomerService.java"
click node_product_service "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/ProductService.java"
click node_owner_beans "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/BusinessOwnerCDIBeans"
click node_admin_ejb "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/ejb/AdminBean.java"
click node_user_ejb "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/ejb/UserBean.java"
click node_domain_entities "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/entity"
click node_persistence_unit "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/resources/META-INF/persistence.xml"
click node_json_dtos "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/JSONClasses"
click node_rest_resource "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/com/mycompany/dropapplication/resources/JakartaEE8Resource.java"
click node_rest_client "https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/client/RESTClient.java"
click node_jwt_security "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/jwtrest"
click node_request_filters "https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/filters"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home_page,node_customer_pages,node_navbar_pages,node_auth_pages toneBlue
class node_login_bean,node_register_bean,node_customer_index_bean,node_customer_service,node_product_service,node_owner_beans,node_admin_ejb,node_user_ejb toneAmber
class node_domain_entities,node_persistence_unit toneMint
class node_jwt_security,node_request_filters toneRose
class node_json_dtos,node_rest_resource,node_rest_client toneIndigo
```

## Components

### Presentation

JSF pages and page-level controllers

- [Home](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/webapp/index.xhtml): JSF view · Entry page and general landing view. · `src/main/webapp/index.xhtml`
- [Customer UI](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/webapp/Customer): JSF views · Customer-facing pages and profile flow. · `src/main/webapp/Customer`
- [Nav Pages](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/webapp/Navbar): JSF views · Role-oriented management screens and shared navigation pages. · `src/main/webapp/Navbar`
- [Auth Pages](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/webapp/Login.xhtml): JSF views · Login, registration, logout, and access-denied views. · `src/main/webapp/Login.xhtml`

### Business

EJB services and CDI-facing workflows

- [Login Bean](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/JSFbeans/LoginBean.java): JSF backing bean · Handles sign-in and authentication form flow. · `src/main/java/JSFbeans/LoginBean.java`
- [Register Bean](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/JSFbeans/RegisterBean.java): JSF backing bean · Handles account registration flow. · `src/main/java/JSFbeans/RegisterBean.java`
- [Customer Index](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/CustomerIndexBean.java): CDI bean · Coordinates customer landing and browsing behavior. · `src/main/java/CDIBeans/CustomerIndexBean.java`
- [Customer Service](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/CustomerService.java): CDI service · Customer-oriented business coordination for UI actions. · `src/main/java/CDIBeans/CustomerService.java`
- [Product Service](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/CDIBeans/ProductService.java): CDI service · Product-related application logic used by UI flows. · `src/main/java/CDIBeans/ProductService.java`
- [Owner Beans](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/BusinessOwnerCDIBeans): CDI bean set · Business-owner management screens for customers, employees, products, societies, and profile. · `src/main/java/BusinessOwnerCDIBeans`
- [Admin Bean](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/ejb/AdminBean.java): EJB service · Administrative business operations. · `src/main/java/ejb/AdminBean.java`
- [User Bean](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/ejb/UserBean.java): EJB service · User-facing business operations and shared transactional logic. · `src/main/java/ejb/UserBean.java`

### Data

Domain entities and persistence

- [Entities](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/entity): JPA model · Core persisted domain model for users, roles, businesses, products, deliveries, and societies. · `src/main/java/entity`
- [Persistence](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/resources/META-INF/persistence.xml): JPA config · JPA persistence unit configuration. · `src/main/resources/META-INF/persistence.xml`

### Security

Authentication, authorization, and access filters

- [JWT Security](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/jwtrest): auth stack · JWT credential handling, token creation, and security configuration. · `src/main/java/jwtrest`
- [Access Filters](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/filters): servlet filters · Role-based request gating for business owners, customers, and employees. · `src/main/java/filters`

### Integration

REST endpoints, client calls, and JSON DTOs

- [JSON DTOs](https://github.com/kakadiya5986/inventory-system/tree/main/src/main/java/JSONClasses): payload model · API and client-facing transfer objects mirrored from domain concepts. · `src/main/java/JSONClasses`
- [REST Resource](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/com/mycompany/dropapplication/resources/JakartaEE8Resource.java): JAX-RS endpoint · Exposed Jakarta REST endpoint. · `src/main/java/com/mycompany/dropapplication/resources/JakartaEE8Resource.java`
- [REST Client](https://github.com/kakadiya5986/inventory-system/blob/main/src/main/java/client/RESTClient.java): outbound client · Consumes external REST services and maps JSON payloads. · `src/main/java/client/RESTClient.java`

## Connections

- Home → Customer Index: renders · Home and customer views are driven by CDI backing beans.
- Customer UI → Customer Index: backed by · Customer views rely on customer-facing CDI state and actions.
- Nav Pages → Owner Beans: backed by · Management screens are powered by business-owner CDI beans.
- Auth Pages → Login Bean: uses · Login page submits to the login backing bean.
- Auth Pages → Register Bean: uses · Register page submits to the registration backing bean.
- Login Bean → JWT Security: authenticates · Login flow issues or validates JWT-based credentials.
- Register Bean → User Bean: creates via · Registration delegates user creation to server-side logic.
- Customer Index → Customer Service: delegates · Customer UI flow is coordinated through the customer service layer.
- Customer Index → Product Service: delegates · Customer browsing and product actions route through product logic.
- Owner Beans → Admin Bean: delegates · Owner management screens call administrative business services.
- Owner Beans → User Bean: delegates · Shared owner workflows use the user service layer.
- Admin Bean → Entities: persists · Administrative operations work on JPA entities.
- User Bean → Entities: persists · Core business operations read and update persisted domain objects.
- Entities → Persistence: mapped by · Entities are stored through the configured JPA persistence unit.
- REST Resource → JSON DTOs: returns · REST responses are shaped with JSON transfer objects.
- REST Client → JSON DTOs: maps · Outbound REST integration uses DTOs for payload exchange.
- REST Client → User Bean: integrates with · Remote data can feed business operations through the client layer.
- Access Filters → JWT Security: enforces · Role filters depend on JWT/security context.
- Access Filters → Customer UI: protects · Customer pages are gated before reaching JSF controllers.
- Access Filters → Nav Pages: protects · Role-specific management pages are protected at request time.
- JWT Security → Auth Pages: supports · Security stack underpins login and access-denied flows.
- REST Resource → Home: coexists with · Application exposes both page-based and REST-style entry points.
