This is a project for University of Helsinki's UniHelp service. It is based on wunderio/drupal-project. It is designed for deploying to code automatically to Silta environment(s).
- URL: https://production.unihelp.finland.wdr.io
- Drush alias:
drush @prod st - SSH:
ssh www-admin@production-shell.unihelp -J www-admin@ssh.finland.wdr.io
The following secret variables are defined in the silta/silta-prod.secrets file for the silta_finland context:
AZURE_OPENAI_APIKEY- API key for Azure OpenAIAZURE_OPENAI_EMBEDDINGS_ENDPOINT- Embeddings endpoint for Azure OpenAIAZURE_OPENAI_COMPLETIONS_ENDPOINT- Completions endpoint for Azure OpenAIEFECTE_API_KEY- API key for Efecte webform integrationEFECTE_API_KEY_TEST- API key for Efecte endpoint environment webform integrationFLAMMA_USERNAME- Username for Flamma content crawlerFLAMMA_PASSWORD- Password for Flamma content crawlerFLAMMA_BASE_URL- Base URL for Flamma content crawlerHCAPTCHA_SECRET_KEY- Secret key for hCaptchaX_API_KEY_STUDIES_HELSINKI_ARTICLES_PIPELINE- API key for studies.helsinki.fi pipelineX_API_KEY_WWW_HELSINKI_PIPELINE- API key for helsinki.fi main site pipeline
Other environment variables:
UNIHELP_SEARCH_API_BASE_URL- Base URL for the Search APIUSERCENTRICS_SETTINGS_IDoptional - ID for Usercentrics Cookie management, overrides the default Settings ID
- URL: https://main.unihelp.dev.wdr.io
- Drush alias:
drush @main st - SSH:
ssh www-admin@main-shell.unihelp -J www-admin@ssh.dev.wdr.io
The Drush alias for the current Silta feature branch deployment is drush @current st.
The following secret variables are defined in the silta/silta.secrets file for the silta_dev context:
The following secret variables are defined in the silta/silta-prod.secrets file for the silta_finland context:
AZURE_OPENAI_APIKEY- API key for Azure OpenAIAZURE_OPENAI_EMBEDDINGS_ENDPOINT- Embeddings endpoint for Azure OpenAIAZURE_OPENAI_COMPLETIONS_ENDPOINT- Completions endpoint for Azure OpenAIEFECTE_API_KEY- API key for Efecte webform integrationEFECTE_API_KEY_TEST- API key for Efecte endpoint environment webform integrationFLAMMA_USERNAME- Username for Flamma content crawlerFLAMMA_PASSWORD- Password for Flamma content crawlerFLAMMA_BASE_URL- Base URL for Flamma content crawlerHCAPTCHA_SECRET_KEY- Secret key for hCaptchaX_API_KEY_STUDIES_HELSINKI_ARTICLES_PIPELINE- API key for studies.helsinki.fi pipelineX_API_KEY_WWW_HELSINKI_PIPELINE- API key for helsinki.fi main site pipeline
Other environment variables:
UNIHELP_SEARCH_API_BASE_URL- Base URL for the Search APIUSERCENTRICS_SETTINGS_IDoptional - ID for Usercentrics Cookie management, overrides the default Settings ID
This project supports two local development environments: DDEV (preferred) and Lando. Choose the one that best fits your workflow.
DDEV provides a containerized development environment with all necessary services preconfigured.
- Install DDEV
- Ensure Docker is running on your system
- Copy the contents of the Wunder LastPass note named "UniHelp local ddev env file" into a local
.envfile at the project root to provide required environment variables. - Start the environment and set up your project:
# Start the DDEV environment
ddev start
# Authenticate SSH for database syncing
ddev auth ssh
# Synchronize local database with a remote environment
# See `scripts/syncdb.sh` for options
ddev syncdb
# Apply configuration changes
ddev drush deploy
# Apply dataset configuration changes
ddev dcdi
# Get a one-time login link for admin access
ddev drush uliNote: All commands in the DDEV section should be run within the DDEV environment using ddev prefix (e.g., ddev drush uli), or by using ddev ssh to access the container shell first.
The project can be accessed at https://unihelp.ddev.site
For a complete list of all available services, URLs, and ports, use:
ddev describeddev- Display available commandsddev adminer- Launch Adminer database management interfaceddev grumphp <commands>- Run code quality checksddev mailpit- Open Mailpit email testing interfaceddev npm <commands>- Execute npm commandsddev phpunit <commands>- Run test suitesddev varnishadm <commands>- Manage Varnish cacheddev xdebug <mode>- Configure Xdebug debugging modesddev syncdb [environment]- Sync database from remote environment (requires VPN andddev auth ssh, seescripts/syncdb.shfor details)
DDEV Elasticsearch configuration
This project includes Elasticsearch service for robust full-text search capabilities. It's automatically set up during DDEV initialization.
Kibana is also included in ddev for easier debugging and inspection of Elasticsearch index and settings in local environment.
Kibana instance could be accessed at: https://unihelp.ddev.site:5601
- Pre-configured with
analysis-icufor Unicode/multilingual text processing - Additional plugins can be defined in
.ddev/docker-compose.elasticsearch8.yaml
services:
elasticsearch:
environment:
- ELASTICSEARCH_PLUGINS=analysis-icu # Space-separated plugin list# Check Elasticsearch status
ddev exec -s elasticsearch "curl -s localhost:9200"
# List installed plugins
ddev exec -s elasticsearch "bin/elasticsearch-plugin list"Elasticvue is included for visualization and management at http://unihelp.ddev.site:9005
Lando environment
Lando offers another containerized development option with a focus on simplicity and flexibility.
| Service | Description | Access |
|---|---|---|
| Web server | Primary web service | https://unihelp.lndo.site |
| Adminer | Database management via docker-adminer | http://adminer.unihelp.lndo.site |
| Elasticsearch | Search functionality via Elasticsearch (uncomment in .lando.yml to enable) |
http://localhost:9200 or http://elasticsearch.lndo.site |
| Kibana | Elasticsearch visualization (uncomment in .lando.yml to enable) |
http://localhost:5601 or http://kibana.lndo.site |
| Mailpit | Email testing via Mailpit | http://mail.lndo.site |
| Varnish | Caching via Varnish | https://varnish.unihelp.lndo.site |
| Drush | Drupal CLI tool | lando drush @local st |
| SSH | Container shell access | lando ssh (-s <service>) |
| Node | JavaScript tooling | Included in web container |
| Chrome | Browser testing via selenium/standalone-chrome | Available in web container |
- Install Lando
- Start the environment:
lando startlando- Display available commandslando drupal <arguments>- Run Drupal core scriptslando grumphp <commands>- Run code quality checkslando npm <commands>- Execute npm commandslando phpunit <commands>- Run test suiteslando varnishadm <commands>- Manage Varnish cachelando xdebug <mode>- Configure Xdebug debugging modeslando syncdb [environment]- Sync database from remote environment (requires VPN, seescripts/syncdb.shfor details)
Code quality tools
This project includes several tools to maintain code quality and consistency across the codebase.
Markdown files can be checked and automatically fixed using the following npm scripts:
# Check markdown files for linting issues
ddev npm run lint:md
# Automatically fix markdown linting issues where possible
ddev npm run lint:md:fixMarkdown linting rules are configured in .markdownlint.json at the project root.
The project also includes linting for JavaScript and CSS files:
# Check JavaScript files
ddev npm run lint:js
# Check CSS/SCSS files
ddev npm run lint:css
# Run all linting (JS, CSS, and Markdown)
ddev npm run lintCursor AI Code Editor
This project uses Cursor as the recommended AI-powered IDE. Cursor enhances development productivity through AI-assisted coding features while maintaining compatibility with VSCode extensions and settings.
- Rules are stored in
@.cursor/rules/directory - Main configuration file:
@.cursor/rules/common.mdc - Rules provide AI with project-specific context about:
- File organization and key project files
- Development environment setup
- Code standards and technology stack
- Git workflow and commit message formatting
Drupal core updates
- Updating Drupal core.
- Altering scaffold files (e.g.,
robots.txt,.htaccess).
Varnish and Purge configuration
This section describes how to set up Varnish caching and Purge functionality in your local development environment.
Note: Drush commands in this section should be run with the appropriate environment prefix (ddev or lando).
The project includes ready-to-use Varnish configuration:
-
Configuration Import (Recommended)
-
For existing projects, simply import the configuration from
config/sync:drush cim -y
-
This applies all Purge and Varnish settings, including processors and purgers
-
-
Manual Configuration (for new sites)
- If config/sync is not available, follow these steps:
a. Install required modules:
drush en purge purge_drush purge_processor_lateruntime purge_queuer_coretags purge_tokens purge_ui varnish_purger varnish_purge_tags -y
b. Configure Varnish Purger:
- Set a value for Browser and proxy cache maximum age in
admin/config/development/performance - Navigate to
/admin/config/development/performance/purge - Click Add purger and select Varnish Purger:
- Name: "Varnish Purger"
- Type: "Tags"
- Request method: "BAN" (important: use BAN instead of PURGE for compatibility with Silta)
- Headers:
Cache-Tags:[invalidation:expression] - Save the configuration
c. Configure processors:
- Go to
/admin/config/development/performance/purge/processors - Ensure these processors are enabled:
drush_purge_invalidate(for manual invalidation via Drush)lateruntime(for batching invalidations)purge_ui_block_processor(for admin UI functionality)
d. Export the configuration:
drush cex -y
e. Update settings.php:
-
Find the purger ID in
varnish_purger.settings.<PURGER_ID>.yml -
Update
web/sites/default/settings.phpwith the correct purger ID:if (getenv('VARNISH_ADMIN_HOST')) { $config['varnish_purger.settings.<PURGER_ID>']['hostname'] = trim(getenv('VARNISH_ADMIN_HOST')); $config['varnish_purger.settings.<PURGER_ID>']['port'] = getenv('VARNISH_ADMIN_PORT') ? trim(getenv('VARNISH_ADMIN_PORT')) : '80'; }
-
Varnish Configuration: DDEV comes pre-configured with Varnish in
.ddevfolder. -
Testing Configuration:
ddev drush cr ddev exec curl -X BAN -H "Cache-Tags: config:system.performance" http://varnish
If working correctly, you should receive a "200 Ban added" response
-
Viewing Varnish logs:
ddev exec -s varnish varnishlog -i BAN -i Cache
-
Enable Varnish:
- Varnish configuration is already enabled in
.lando.yml&.lando/varnish.vcl.
- Varnish configuration is already enabled in
-
Testing Configuration:
lando drush cr lando ssh -c "curl -X BAN -H 'Cache-Tags: config:system.performance' http://varnish"
-
BAN vs PURGE Method: Always use the "BAN" method in the Varnish purger configuration instead of "PURGE". The Silta Varnish configuration is set up to handle BAN requests but may reject PURGE requests with "405 Method Not Allowed" errors.
-
Processors: The default Purge setup uses the
purge_processor_lateruntimemodule, which empties the purge queue during page requests. This works well for most sites needing immediate cache clearing. Ensure all required processors are enabled. -
Cache Tags: The Varnish configuration is set up to handle cache tag invalidation with the
Cache-Tagsheader.
Running tests
The PHPUnit test framework is predefined in this project. See phpunit.xml for details. A minified web/modules/custom/phpunit_example module from the examples module is included for learning purposes.
Note: Run these commands with the appropriate environment prefix (ddev phpunit or lando phpunit).
- Run one test class:
phpunit path/to/your/class/file.php - List groups:
phpunit --list-groups - Run all tests in a particular group:
phpunit --group Groupname
This project uses Cypress for end-to-end (E2E) testing, including automated accessibility checks powered by axe-core via the cypress-axe plugin.
You can run the E2E test suite in headless mode:
npm run test:e2eOr open the interactive Cypress UI:
npm run test:e2e:openNote: The site must be running locally (e.g., via DDEV or Lando) before running Cypress tests.
Accessibility checks are integrated into the Cypress E2E tests using cypress-axe. These tests automatically scan pages and components for accessibility violations according to WCAG standards.
- Accessibility violations are logged in the terminal with details and CSS selectors to help locate issues.
- To view or debug violations, check the Cypress test output or browser console (when running interactively).
- E2E test files are located in
cypress/e2e/ - Accessibility logging helpers are in
cypress/support/axe-log.ts - Cypress configuration is in
cypress.config.ts
- Add new E2E or accessibility tests in the
cypress/e2e/directory. - Use
cy.injectAxe()aftercy.visit()and beforecy.checkA11y()in your tests to enable accessibility scanning. - For custom accessibility logging, use the
terminalLoghelper.
it('has no detectable accessibility violations on load', () => {
cy.visit('/');
cy.injectAxe();
cy.checkA11y(undefined, undefined, terminalLog);
});- If you see errors about missing Cypress binaries, run
npm run cypress:install. - If accessibility violations are reported, check the terminal output for selectors and descriptions to help you fix the issues.
For more details, see the Cypress documentation and cypress-axe documentation.
Silta CLI is a command-line tool to manage secrets and configurations for Silta projects. Use the following commands:
- Encrypt a file:
silta secrets encrypt --file silta/silta.secrets --secret-key=<secret_key_env> - Decrypt a file:
silta secrets decrypt --file silta/silta.secrets --secret-key=<secret_key_env> - Display help:
silta secrets --help
See the corresponding secret_key_env values in the .circleci/config.yml file for the silta_dev and silta_finland contexts. Refer to the Getting Started section for details.
This project is maintained by Wunder. Contributions from the community are welcome.
Commit message validation and ticketing system integration
We follow the Conventional Commits specification for commit messages, with an additional requirement for ticket IDs. Each commit message must include a valid ticket ID (except for merge commits) and follow the conventional commits format:
[PROJECTKEY-123]: (feat) Add new feature description
- Detailed change description
- Another relevant detail
Refs: file1.ext, file2.extTypes include (used within parentheses):
- feat: New feature (correlates with MINOR in semantic versioning)
- fix: Bug fix (correlates with PATCH in semantic versioning)
- docs: Documentation changes
- style: Changes not affecting code meaning
- refactor: Code changes neither fixing bugs nor adding features
- perf: Performance improvements
- test: Adding or correcting tests
- build: Build system or dependency changes
- ci: CI configuration changes
- chore: Other changes not modifying src or test files
Breaking changes must be indicated by appending a ! after the type/scope or including "BREAKING CHANGE:" in the footer.
Ticket ID formats:
- JIRA:
[PROJECTKEY-123]: (type) Description - GitHub:
GH-123: (type) Description
We leverage autolinked references to automatically convert ticket IDs into clickable links for easy navigation. This enhances traceability and accessibility across platforms.
Validation rules are implemented via the GrumPHP git_commit_message component. See grumphp.yml for configuration details.
Refer to the WunderFlow repository for Git workflow details.
Deployments are managed with CircleCI. Configurations are in .circleci/config.yml.
- Feature branches require manual approval for deployment by default.
- Other branches deploy automatically but can be configured for manual approval.
Manual approvals are managed through the approve-deployment job in the CircleCI UI by clicking the "approve-deployment" job label when marked as "Needs Approval."
See data-pipelines.md for details on data pipeline setup and usage.
The project includes a standalone Node.js search service (search-service/) that handles search queries and AI-powered answer generation. The service features automatic language detection to improve user experience across multiple languages.
The search service automatically detects the language of user queries using the franc library. When a user searches in a language that differs from the current page language, the system:
-
Backend Detection (
search-service/utils/languageDetection.js):- Detects query language using franc (trigram-based statistical analysis)
- Supports Finnish (fi), Swedish (sv), and English (en)
- Requires minimum 10 characters for reliable detection
- Returns null if detection fails or language is unsupported
-
Backend Response (
search-service/server.js):- Compares detected language with page language parameter
- Returns language mismatch response if languages differ
- Response includes
languageMismatch: trueanddetectedLanguageproperties
-
Frontend Handling (
web/themes/custom/unihelp/src/js/search/Search.jsx):- Displays notification instead of AI summary when mismatch detected
- Provides link to search in the correct language
- Preserves query and role parameters in the redirect URL
Related Files:
search-service/utils/languageDetection.js- Language detection utilitysearch-service/server.js- API endpoint with detection logicweb/themes/custom/unihelp/src/js/search/Search.jsx- Frontend React componentweb/themes/custom/unihelp/src/js/i18n/index.js- Translatable strings
Library: franc - Language detection library with support for 187+ languages
The search service automatically logs search statistics to track how users interact with the search system. This data helps monitor search usage patterns, identify popular queries, and improve search quality.
The analytics data is stored in a dedicated Elasticsearch index (unihelp_search_statistics) that is automatically created on search-service startup if it doesn't exist.
Each search event records the following information:
@timestamp: Date and time of the search (ISO 8601 format)query: The search query string (text with keyword subfieldquery.rawfor exact matching)langcode: Language code of the search ("fi","sv", or"en")role: User's role/profile used for the search (empty string if not specified)offset: Pagination offset (0 for initial searches, >0 for paging queries)total_results: Total number of filtered results returned
The analytics system is designed with privacy in mind:
- No PII stored: No IP addresses, User-Agent strings, emails, names, or authentication tokens are logged
- Dynamic fields disabled: The index mapping uses
dynamic: falseto prevent accidental PII field creation - Fire-and-forget: Analytics failures never impact search functionality - if analytics logging fails, the search still works normally
Search analytics can be controlled via environment variables:
SEARCH_ANALYTICS_ENABLED: Set to"false"to disable analytics logging (default:true)SEARCH_ANALYTICS_INDEX: Customize the index name (default:"unihelp_search_statistics")
The index uses cluster defaults for shards and replicas configuration.
The analytics index is automatically created on search-service startup with the correct mappings. If index creation fails, the service will log a warning but continue to start normally (analytics won't work until the index is created manually).
The search service provides an authenticated API endpoint to export analytics data as CSV format for easy import into spreadsheets.
Endpoint: GET /api/analytics
Authentication: Requires API key via one of the following methods:
- HTTP header:
X-API-Key: <your-api-key> - Query parameter:
?api_key=<your-api-key>
Query Parameters:
from: Start date in ISO 8601 format (YYYY-MM-DD), optional. Defaults to 7 days ago.to: End date in ISO 8601 format (YYYY-MM-DD), optional. Defaults to today.api_key: API key for authentication (alternative to header).
Response Format: CSV file with the following columns:
timestamp: Date and time of the searchquery: The search query stringlangcode: Language code (fi,sv, oren)role: User's role/profile (empty if not specified)offset: Pagination offsettotal_results: Total number of results
Default Behavior: If from or to parameters are not provided, the endpoint returns data from the last 7 days (from 7 days ago to today).
Results: All matching records are returned (no pagination limits). Results are sorted by timestamp in descending order (newest first).
Example Requests:
# Export last 7 days (default) using header authentication
curl -H "X-API-Key: your-api-key-here" \
https://your-search-service.com/api/analytics \
-o analytics.csv
# Export specific date range using query parameter authentication
curl "https://your-search-service.com/api/analytics?from=2026-01-01&to=2026-01-31&api_key=your-api-key-here" \
-o analytics-january.csv
# Export last 30 days
curl -H "X-API-Key: your-api-key-here" \
"https://your-search-service.com/api/analytics?from=2026-01-01&to=2026-01-31" \
-o analytics-january.csvConfiguration:
ANALYTICS_API_KEY: Environment variable that must be set to enable the analytics export endpoint. This API key is required for all requests to/api/analytics.
The Elasticsearch indices expose an audience keyword field generated during indexing (see buildAudiencePainlessScript() in web/modules/custom/unihelp_data_pipelines/src/Drush/Commands/UnihelpDataPipelinesCommands.php). Documents may be tagged with any of the following audiences: employee, researcher, teacher, applicant, student, open university, or supervisor.
The search service combines explicit role parameters and intent detector hits to apply soft boosts:
search-service/utils/role.js#getAudienceEmphasis()maps the incoming role to matching audience values, merges intent detections, and emits a single boost config for theaudiencefield. Legacy de-emphasis rules remain in the file but are guarded by aAUDIENCE_DE_EMPHASIS_ENABLEDflag (currentlyfalse).search-service/utils/intentDetector.js#detectAudienceIntents()generalizes the previous Open University detection and currently recognizes both open university and supervisor phrases across Finnish, Swedish, and English inputs.search-service/utils/queryBuilder.js#addAudienceEmphasisClauses()injects the boost into lexicalshouldclauses, whilebuildRescoreFunctions()mirrors the weighting in the ANN rescore phase used by bothsearch-service/services/search.jsandsearch-service/services/answer.js.
This setup keeps the configuration simple (audience values only) and makes it straightforward to introduce additional audiences later by extending the detector registry.
The same helper now re-enables a mild de-emphasis for applicant/student roles: whenever their selected audiences include only study-oriented profiles, any overlapping employee-style audiences (employee, supervisor, researcher, teacher) receive a small multiplier (0.85) via the existing rescore pipeline. This keeps search and answer behaviour aligned without reintroducing domain-based suppression.