# codelibs/fess architecture

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

- Interactive diagram: https://gitdiagram.com/codelibs/fess
- Repository: https://github.com/codelibs/fess

## Overview

##### Main Components
- Frontend Layer: This includes the Search UI (for end users) and Admin UI (for configuration and monitoring). They are deployed as part of the webapp (the “src/main/webapp” directory with numerous JSPs, HTML, CSS, and JavaScript files related to UI).
- Application/Controller Layer: This comprises the web actions, controllers, and entry points (for example, the “app/web” and “app/api” packages) that route user requests to appropriate backend functions.
- Business/Service Layer: This layer includes the core business logic such as job scheduling, crawling coordination (see “app/job”, “app/logic”), indexing, and search query processing. Modules here include helpers, validations, and ranking/search components.
- Crawler/Indexer Components: Fess integrates a crawler subsystem (under packages like “crawler”, “ingest”, “exec”), which is responsible for fetching documents from web servers, file systems, or other data sources. It then feeds data into the index.
- Persistence/Configuration and Plugin Infrastructure: There are configuration files for crawling, indexing, and also DB/ORM related artifacts (dbflute, Maven configurations, etc.) plus support for plugins and themes (as indicated by the “packaging” and “plugin.xml” files).

##### Relationships and Interactions
- Web Clients interact with the Frontend (Search UI and Admin UI) that forward their requests to the Controllers.
- Controllers and API endpoints then invoke the Service Layer to process search queries, manage crawling or configuration tasks, or trigger scheduled jobs.
- The Service Layer interacts in two key directions:
a. It sends search and indexing requests to the OpenSearch backend and receives search results.
b. It drives the Crawler/Indexer module to fetch, parse, and transform data from various sources.
- The Crawler module often collaborates with helper classes and integration components to support multiple data stores and file formats.
- Additionally, the plugin and script components (e.g., Groovy or OGNL script engines) allow for extensibility and customization, feeding into the business logic.
- Configuration and persistence elements (such as DB triggers, properties files, and dependency injection via Lasta Di) support the overall operation.

##### Recognize Architectural Patterns
- Layered Architecture: Separate layers for presentation, application, business logic, integration, and infrastructure.
- Modular/Component–based Design: Each subsystem (crawler, web framework, API, integration with OpenSearch) is built as its own module.
- Plugin/Extensibility: There is an explicit mechanism (files in “plugin.xml”, packaging details, and script directories) that supports extensibility of features.
- Use of Dependency Injection: The project uses Lasta Di for dependency injection, so include a note that components are loosely coupled through DI.

##### Present Key Technologies
- Java with Maven as the build tool.
- OpenSearch as the search engine backend.
- Lasta Flute and Lasta Di as the web framework and DI container.
- Various integration connectors for external systems (git, database, CSV, etc.).
- JSP/HTML/JavaScript for the UI components.
- The support for containerization and package formats (deb, rpm, zip) is also relevant from a deployment perspective.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        F["Frontend Layer (Search UI & Admin UI)"]
    end

    %% Application/Controller Layer
    subgraph "Application/Controller Layer"
        CW["Web Controllers"]
        CA["API Endpoints"]
    end

    %% Business/Service Layer
    subgraph "Business/Service Layer"
        BS["Business Service"]
        BL["Business Logic"]
        BJ["Job Scheduler"]
    end

    %% Crawler/Indexer Components
    subgraph "Crawler/Indexer Components"
        CI1["Crawler Engine"]
        CI2["Ingester Engine"]
        CJ["Crawl Job"]
    end

    %% Integration Layer
    subgraph "Integration Layer"
        IO["OpenSearch Connector"]
        IDS["Data Store Connectors"]
    end

    %% Infrastructure/Configuration & Plugin Layer
    subgraph "Infrastructure/Configuration & Plugin Layer"
        INF["Configuration & Plugin"]
    end

    %% Relationships and data flow
    F -->|"user_request"| CW
    F -->|"user_request"| CA
    CW -->|"forward_request"| BS
    CA -->|"api_call"| BS
    BS -->|"process_logic"| BL
    BS -->|"schedule_crawl"| BJ
    BJ -->|"trigger_crawl"| CI1
    CI1 -->|"process_ingest"| CI2
    CI2 -->|"execute_crawl"| CJ
    CJ -->|"index_update"| BS
    BS -->|"search_query"| IO
    BS -->|"data_fetch"| IDS
    INF --- BS
    INF --- CW
    INF --- CA
    INF --- CI1

    %% Click Events for Component Mappings
    click F "https://github.com/codelibs/fess/tree/master/src/main/webapp"
    click CW "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/app/web"
    click CA "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/app/api"
    click BS "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/app/service"
    click BL "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/app/logic"
    click BJ "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/app/job"
    click CI1 "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/crawler"
    click CI2 "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/ingest"
    click CJ "https://github.com/codelibs/fess/blob/master/src/main/java/org/codelibs/fess/job/CrawlJob.java"
    click IO "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/opensearch"
    click IDS "https://github.com/codelibs/fess/tree/master/src/main/java/org/codelibs/fess/ds"
    click INF "https://github.com/codelibs/fess/blob/master/plugin.xml"
    click INF "https://github.com/codelibs/fess/blob/master/dbflute.xml"
    click INF "https://github.com/codelibs/fess/blob/master/src/main/resources/fess_config.properties"
    click INF "https://github.com/codelibs/fess/blob/master/src/main/resources/fess.xml"
    click INF "https://github.com/codelibs/fess/tree/master/src/packaging"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef controller fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef service fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef crawler fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef integration fill:#d1e7ff,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#f8d7da,stroke:#333,stroke-width:2px;

    class F frontend;
    class CW,CA controller;
    class BS,BL,BJ service;
    class CI1,CI2,CJ crawler;
    class IO,IDS integration;
    class INF infrastructure;
```
