Application Structure ​
BlackLab Frontend has a Java backend and a Vue application. The backend serves the HTML skeleton, configuration, static resources and article content. Vue Router handles navigation within the frontend.
Application and feature entry points ​
src/frontend/src/app/entrypoint/main.ts creates the application shell and its shared services, including authentication, API clients, corpus context, i18n and the customization registry. Search and article setup are loaded on demand and installed once per application, before their route components render.
| Routes | Frontend entry | Responsibility |
|---|---|---|
| All pages | app/entrypoint/main.ts | Shared services, navigation, common controls and corpus configuration |
/ | pages/corpora/CorporaPage.vue | Corpus overview and management |
/:corpus/search/:results? | pages/search/entrypoint.ts | Search forms, stores, results, history and URL synchronization |
/:corpus/docs/:docId | pages/article/entrypoint.ts | Article state, document display and URL synchronization |
/configwizard, /:corpus/configwizard/* | pages/config/entrypoint.ts | Corpus picker and configuration wizard |
/about, /help, /:corpus/about, /:corpus/help | pages/info/InfoPage.vue | Static page content |
/callback | app/entrypoint/callback.ts | OIDC authentication callback |
The search and article entries export both their page component and their feature plugin. This gives each feature a single dynamic import boundary. The composition root passes dependencies into each plugin.
Monaco loads when the format editor opens. Article statistics and Highcharts load when statistics are enabled. The Vue template compiler loads only through the explicit customization API. Locale bundles are loaded as needed.
Production builds use Rolldown's shared-module grouping: application modules used by multiple entries and their static dependencies join a common bundle. Feature code and optional libraries remain lazy. The server template loads both main.css and shared.css; feature styles load with their JavaScript. npm run test:bundles checks the production dependency boundaries and startup stylesheet links. Add -- --report to inspect page request counts and bundle sizes.
npm run build builds the OIDC callback separately into a standalone callback.js. Both it and the common application payload include their own authentication library, avoiding a shared auth request on normal pages or loading application code in the callback.
Finding frontend code ​
Paths below are relative to src/frontend/src/.
| Location | What belongs there |
|---|---|
app/entrypoint/ | Browser startup, first-page readiness and the standalone OIDC callback |
app/router/ | Route definitions, route metadata, the active corpus ID and page readiness across navigations |
app/router/url/ | Shared URL synchronization and codecs used across pages, including article links generated by search results |
app/shell/ | The application root, navigation bar and layout shared across routes |
pages/<page>/ | The route's components, models and bindings. The eager pages/corpus/CorpusRouteLayout.vue gates child routes on corpus availability. |
features/ | Corpus loading, the form engine and the CQL builder. Each has an owner independent of a route component. |
shared/ | Services and UI usable across pages, including API clients, authentication, i18n and Vue injection helpers |
customization-api/ and interop/ | Customization contracts and registrations, and their integration with scripts and browser globals |
Naming state and wiring ​
- A page's
entrypoint.tsexports the components and setup that share a lazy import. Its*-plugin.tswires dependencies and installs providers. Pages that need only one component can load that component directly. - Name TypeScript files in kebab-case and Vue components in PascalCase. Use a domain noun for an instance that owns behavior (
corpus-context.ts,form-runtime.ts), and*-state.tsfor state owned by an instance. A module-level legacy singleton uses*-store.ts. - A
create*function or class constructor builds an instance from explicit dependencies. Aprovide*function publishes a value and its matchinguse*function retrieves it in Vue. Use*-injection.tswhen this contract has its own file. Small modules can keep the contract alongside the instance. For example,form-runtime-injection.tsexposes the runtime built elsewhere, whilearticle-page-state.tsdefines both the state factory and its accessors. - When construction and installation are separate, a service can expose both through its directory. For example,
shared/api/index.tsconstructs the two API clients, andshared/api/plugin.tslets the application or a test provide its own clients. - A
use-*.tsfile implements a component composable. A*-binding.tsfile connects existing owners, such as search state and the URL.
Corpus configuration and custom scripts ​
The corpus context contains normalized corpus metadata, page configuration and tagset data. Shared legacy configuration lives under app/legacy-stores/. It includes UI and article settings, filters and tagsets for existing customization scripts. These small compatibility modules do not depend on search or article page implementations.
On corpus publication, the composition root initializes shared configuration. If search has already been installed, it resets result settings and loads saved searches for the new corpus at the same checkpoint. Configured scripts then register callbacks and set defaults. The search form graph reacts to those settings. The form stays inert while declared scripts or URL restoration are pending. Later customization registration replaces the current draft with fields restored from the submitted search. Only declared script loading is part of the loading barrier. If a user first visits another page and opens search later, feature installation preserves the configuration already supplied by scripts.
The customization registry owns registrations and script disposal. It does not construct forms or execute result hooks itself. Search owns form construction and ongoing result customization; article display consumes only the configuration it needs.
interop/window-globals.ts is the sole publisher of customization globals. Common configuration is available on every page. The search compatibility facade is added when search is installed. Internal application code receives dependencies directly or uses component injection rather than reading these globals.
Search and article state ​
pages/search/search-plugin.ts composes submitted search state, the form runtime, active results, query history and URL restoration. The form runtime holds the editable draft. Submission applies the compiled form and its result preset, and result controls can change the current view independently. QueryForm.vue owns the selected-subcorpus count used to confirm large explore queries. It follows the committed search filter and field and cancels pending work when the form unmounts.
pages/article/article-plugin.ts provides article state and its URL binding. Document loading and display remain within the article feature; article configuration can be set by corpus scripts before that feature is loaded.
Each feature owns its URL binding. Incoming navigation restores that page's state, and subsequent user changes publish URL updates. URL bindings stop on application unmount. Opening another page does not initialize the other feature's implementation.
Article pagination uses zero-based, half-open word ranges in the displayed annotated field. Parallel hit navigation reads that version's ranges from the query's otherFields results before selecting pages or highlights. Default field names are omitted from document links and contents requests; a separate search field is retained when highlighting a query from another version.
Valid custom starts are preserved. Invalid or empty ranges are repaired within the page size and field length, and starts beyond the document select its last page. Unpaginated contents omit word bounds. The Java frontend also omits bounds at document edges to preserve leading and trailing markup. Statistics use exact word bounds and continue from the actual returned annotation count when BlackLab caps a snippet response.
Built-in article stylesheets preserve data-hit-start and data-hit-end on highlight fragments so navigation can identify a hit split around XML elements. Custom article stylesheets can preserve these attributes too; older stylesheets that only emit .hl elements retain positional navigation.