# hodinhtuankiet/zoo-hnv-demo architecture

> Architecture diagram of the GitHub repository hodinhtuankiet/zoo-hnv-demo, 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/hodinhtuankiet/zoo-hnv-demo
- Repository: https://github.com/hodinhtuankiet/zoo-hnv-demo

## Overview

##### Main Components
- Frontend (HNV-Demo-FE): This module is responsible for presenting the user interface. It contains HTML pages, JavaScript controllers and templates, CSS assets, and many third‐party libraries (for example, Bootstrap, jQuery variants, datatables, etc.). Its directory structure is highly modular – with folders representing groups, login, user, avatar upload flows, etc.
- Backend (HNV-Demo-BE): This module is built in Java (with Spring Boot–like structure as evidenced by files such as SprB_App, SprB_CfgSecurity, etc.). Its layered package structure shows clear separation into API controllers (e.g., in com/hnv/api/main), service layers for business logic (in com/hnv/api/service, with separate “priv” and “publ” partitions), and database access components (in com/hnv/db). Also, configuration files and many library JARs (Hibernate, Spring, JasperReports, and Google libraries among others) indicate that the backend manages business logic and persistence.
- Database (and/or external resources): Although not explicitly shown as a separate file, the existence of Hibernate configuration files and database-related packages implies that a relational database is used. Some flows like “Upload Avatar” may also involve external storage or file-handling services.
- External Libraries & Tools: There are many included third-party libraries that affect both the client‐(e.g., for UI controls, file inputs, date pickers) and server sides (e.g., Hibernate, Spring, JasperReports).

##### Relationships and Data Flow
- Inside the “Backend” block, further subdivide into layers:
– A “Controller/API Layer” (mapping to the com/hnv/api/main package) that handles HTTP requests.
– A “Service/Business Logic Layer” (found in packages like com/hnv/api/service) that processes the business workflow (for example, processing a “Delete” or “Modify” request).
– A “Data Access Layer” (com/hnv/db packages) that interacts with the underlying database.
1. The UI component sends an HTTP/JSON request to the backend’s API controller.
2. The controller invokes service logic to process the request.
3. The service might interact with the database (or file storage) through the DAO/persistence layer.
4. The server then responds back to the client with a JSON (ShareJSON response) confirming the operation.

##### Architectural Patterns
- Layered/MVC architecture on the backend. Indicate that controllers forward the requests to service beans which in turn use repository/DAO classes (mapping to Hibernate-based ORM).
- For the frontend, note the separation of concerns between view (HTML/CSS/templates) and application logic (JavaScript controllers and middleware).
- Clear integration points where the frontend and backend interact via HTTP APIs (using JSON handling as mentioned in the README).
- That the system uses common design principles like modularity, separation of concerns, and reuse via external libraries.

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "Frontend (HNV-Demo-FE)"
        FE_UI["User Interface (HTML/CSS/Templates)"]:::frontend
        FE_CTRL["JS Controllers/Logic"]:::frontend
        FE_LIB["Third-Party Libraries (Client)"]:::ext
    end

    FE_UI -->|"triggers"| FE_CTRL
    FE_CTRL -->|"HTTP/JSON Request(UploadAvatar/Delete/Modify/Add)"| BE_API

    subgraph "Backend (HNV-Demo-BE)"
        BE_API["API Controllers"]:::backend
        BE_SERVICE["Business Logic / Service Layer"]:::backend
        BE_DB["Database Access Layer"]:::backend
        BE_LIB["External Libraries (Server)"]:::ext
    end

    BE_API -->|"ForwardRequest"| BE_SERVICE
    BE_SERVICE -->|"DBOperation"| BE_DB
    BE_DB -->|"DBResponse"| BE_SERVICE
    BE_SERVICE -->|"AggregatedResponse"| BE_API
    BE_API -->|"JSONResponse(ShareJSON)"| FE_CTRL

    FE_UI -->|"Utilizes"| FE_LIB
    BE_API -->|"Uses"| BE_LIB

    DB["Database (RDBMS)"]:::database
    BE_DB -->|"CRUDOperations"| DB

    click FE_UI "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-FE/WebContent"
    click FE_CTRL "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-FE/WebContent/www/js/app"
    click FE_LIB "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-FE/WebContent/www/js/lib"
    click BE_API "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-BE/src/com/hnv/api/main"
    click BE_SERVICE "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-BE/src/com/hnv/api/service"
    click BE_DB "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-BE/src/com/hnv/db"
    click BE_LIB "https://github.com/hodinhtuankiet/zoo-hnv-demo/tree/master/HNV-Demo-BE/WebContent/WEB-INF/lib"

    classDef frontend fill:#e1f5fe,stroke:#0288d1,stroke-width:2px;
    classDef backend fill:#ffecb3,stroke:#f57f17,stroke-width:2px;
    classDef database fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef ext fill:#e0f2f1,stroke:#00796b,stroke-width:2px;
```
