This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
BELY (Best Electronic Logbook Yet) is a Java EE web application for electronic logbook management. It is deployed on Payara Server (GlassFish fork) and uses MySQL/MariaDB as its database. The project includes:
- LogrPortal: Main Java EE web application (JSF/PrimeFaces frontend + REST API)
- Python web service: Python-based web service components
- MQTT integration: Python framework for handling MQTT events and notifications
- CLI utilities: Command-line tools for searching and querying the system
Always source the environment setup script before running any commands:
source setup.shThis sets up critical environment variables:
LOGR_ROOT_DIR: Root directory of the repositoryLOGR_SUPPORT_DIR: Support software directory (Payara, Java, MySQL, etc.)LOGR_INSTALL_DIR: Installation directoryLOGR_DATA_DIR: Data directoryPYTHONPATH: Includessrc/pythonand Python client paths
# Install support software (Java, Payara, etc.)
make support
# Install MySQL (if needed)
make support-mysql
# Install NetBeans IDE
make support-netbeans
# Create development configuration
make dev-config# Create clean database with schema
make clean-db
# Create test database with test data
make test-db
# Backup database
make backup
# Development database variants
make clean-db-dev
make backup-devDatabase SQL files are located in db/sql/:
clean/: Clean database schema initialization scriptstest/: Test data initialization scriptsstatic/: Static lookup data (e.g., notification providers)updates/: Database migration scripts (e.g.,updateTo2025.3.sql)create_logr_tables.sql: Main table creation scriptcreate_stored_procedures.sql: Stored procedurescreate_views.sql: Database views
# Build the web portal
cd src/java/LogrPortal
ant clean
ant dist
# Deploy to Payara (from project root)
make deploy-web-portal
# Deploy web service
make deploy-web-service
# Undeploy
make undeploy-web-portal
make undeploy-web-service
# Development deployment variants
make deploy-web-portal-dev
make deploy-web-service-dev# Run full test suite (backs up DB, deploys test DB, runs tests, restores DB)
make test
# Manual API tests
cd tools/developer_tools/python-client/
pytest test/api_test.py
# Test requirements
pip install -r tools/developer_tools/python-client/test/requirements.txt# Start the Python web service
./sbin/cdbWebService.shPython code is in src/python/cdb/.
All Java code is under src/java/LogrPortal/src/java/gov/anl/aps/logr/:
portal - Main web portal application
controllers/- JSF managed beans for UI logicmodel/db/entities/- JPA entity classes (e.g.,Log,UserInfo,NotificationConfiguration)model/db/beans/- EJB facades for database operations (stateless session beans)view/- View objects and JSF utilitiesimport_export/- Import/export functionalityplugins/- Plugin support systemutilities/- General utility classes
rest - REST API
routes/- JAX-RS resource classes (e.g.,LogbookRoute,SearchRoute)authentication/- Authentication filters and utilitiesentities/- DTO classes for API responsesprovider/- JAX-RS providers
common - Shared utilities
mqtt/- MQTT integration models and utilitiesobjects/- Common data objectsutilities/- Shared utility classessearch/- Search functionality
api - API client interfaces
Location: src/java/LogrPortal/web/
views/- XHTML pages organized by entity type (e.g.,log/,userInfo/,notificationConfiguration/)templates/- XHTML template filesresources/- Static resources (CSS, JavaScript, images)WEB-INF/- Web application configuration
- Framework: Java EE 8 (JSF 2.3, EJB 3.2, JPA 2.2, JAX-RS 2.1)
- UI: PrimeFaces 11 + PrimeFaces Extensions, OmniFaces 3
- App Server: Payara 5.2022.5 (GlassFish fork)
- Database: MySQL/MariaDB (driver: mariadb-java-client-3.1.0.jar)
- ORM: EclipseLink (JPA implementation)
- Build: Apache Ant + NetBeans project
- API Docs: Swagger/OpenAPI 2.1.5
- PDF Generation: iText 5.5.13.1
- Markdown: Flexmark 0.64.8
- Logging: Log4j 2.17.0
The MQTT notification framework is a pluggable Python system for handling MQTT events:
- Location:
tools/developer_tools/bely-mqtt-message-broker/ - Features: Type-safe Pydantic models, topic matching with wildcards, notification handlers (email, Slack, Discord)
- See
tools/developer_tools/bely-mqtt-message-broker/README.mdfor details
BELY supports custom plugins for extending functionality:
- Templates:
tools/developer_tools/logr_plugins/pluginTemplates/ - Deployment:
make deploy-cdb-pluginormake deploy-cdb-plugin-dev
- Open NetBeans:
netbeans & - File > Open Project > Select
src/java/LogrPortal - Resolve missing server: Right-click project > "Resolve Missing Server Problem"
- Add Payara Server pointing to
$LOGR_SUPPORT_DIR/netbeans/payara - Copy MariaDB driver to Payara:
cp src/java/LogrPortal/lib/mariadb-java-client-3.1.0.jar \ $LOGR_SUPPORT_DIR/netbeans/payara/glassfish/domains/domain1/lib/ - Run project from NetBeans
When adding new database entities (e.g., notification system):
- Update
db/sql/create_logr_tables.sqlwith new table definitions - Add static data SQL files to
db/sql/static/if needed - Create JPA
@Entityclass inportal/model/db/entities/ - Create
@Statelessfacade inportal/model/db/beans/(extendsAbstractFacade) - Create JSF controller in
portal/controllers/(extends appropriate base controller) - Create XHTML views in
web/views/<entity_name>/ - Update database with
make clean-dbor create migration indb/sql/updates/
Version updates go in db/sql/updates/updateToYYYY.X.sql (e.g., updateTo2025.3.sql)
- Entity/Facade/Controller: Standard Java EE pattern - JPA entities, EJB facades for CRUD, JSF controllers for UI
- Named Queries: Use JPA
@NamedQueryannotations on entities for common queries - Lazy Loading: JSF data tables use lazy loading models
- Session Management: Session-scoped JSF beans maintain user state
- REST Authentication: Token-based auth via
rest/authentication/ - MQTT Events: Notification configurations trigger MQTT messages handled by Python framework
Makefile: Top-level make targets for building, deploying, testingsetup.sh: Environment variable setup (must be sourced)sbin/: Deployment and utility scriptssrc/java/LogrPortal/build.xml: Ant build filesrc/java/LogrPortal/nbproject/project.properties: NetBeans project configurationdb/sql/create_logr_tables.sql: Main database schema
- The project is also known as "ComponentDB" or "CDB" in some contexts
- Default database name:
logr(development:logr_dev) - Application URL after deployment:
https://<hostname>:8181/belyorhttps://<hostname>:8181/cdb - The main branch is
master(notmain) - Always run database operations and deployments from the repository root after sourcing
setup.sh