How kakadiya5986/inventory-system works
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: CustomerIndexBean.java Customer Index · UserBean.java User Bean · filters Access Filters · BusinessOwnerCDIBeans Owner Beans
Components 19
Presentation
JSF pages and page-level controllers
- Home · Entry page and general landing view.
src/main/webapp/index.xhtml - Customer UI · Customer-facing pages and profile flow.
src/main/webapp/Customer - Nav Pages · Role-oriented management screens and shared navigation pages.
src/main/webapp/Navbar - Auth Pages · Login, registration, logout, and access-denied views.
src/main/webapp/Login.xhtml
Business
EJB services and CDI-facing workflows
- Login Bean · Handles sign-in and authentication form flow.
src/main/java/JSFbeans/LoginBean.java - Register Bean · Handles account registration flow.
src/main/java/JSFbeans/RegisterBean.java - Customer Index · Coordinates customer landing and browsing behavior.
src/main/java/CDIBeans/CustomerIndexBean.java - Customer Service · Customer-oriented business coordination for UI actions.
src/main/java/CDIBeans/CustomerService.java - Product Service · Product-related application logic used by UI flows.
src/main/java/CDIBeans/ProductService.java - Owner Beans · Business-owner management screens for customers, employees, products, societies, and profile.
src/main/java/BusinessOwnerCDIBeans - Admin Bean · Administrative business operations.
src/main/java/ejb/AdminBean.java - User Bean · User-facing business operations and shared transactional logic.
src/main/java/ejb/UserBean.java
Data
Domain entities and persistence
- Entities · Core persisted domain model for users, roles, businesses, products, deliveries, and societies.
src/main/java/entity - Persistence · JPA persistence unit configuration.
src/main/resources/META-INF/persistence.xml
Security
Authentication, authorization, and access filters
- JWT Security · JWT credential handling, token creation, and security configuration.
src/main/java/jwtrest - Access 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 · API and client-facing transfer objects mirrored from domain concepts.
src/main/java/JSONClasses - REST Resource · Exposed Jakarta REST endpoint.
src/main/java/com/mycompany/dropapplication/resources/JakartaEE8Resource.java - REST Client · Consumes external REST services and maps JSON payloads.
src/main/java/client/RESTClient.java
Connections 22
- 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.