A custom SQL-like query engine for PQL (Process Query Language), using ANTLR4 to parse queries and Apache CouchDB as the underlying document database for process-mining event logs in the XES format.
Bachelor's thesis project in Computer Science — Poznań University of Technology.
Process-mining event logs in the IEEE XES format are hierarchical (log → trace → event) and schema-flexible. This makes them difficult to represent with a fixed relational schema, especially when querying data across different levels of the hierarchy.
This project combines Apache CouchDB with a purpose-built PQL query engine. It allows users to write declarative, SQL-like queries instead of working directly with CouchDB's native JSON query syntax.
Note: The PQL language specification was created by the ProcessM research project. The original contribution of this repository is the engine that parses, translates, and executes PQL queries against a NoSQL document database.
- ANTLR4-based parser for the PQL language.
- Query translation from PQL into CouchDB Mango
_findselectors. - Query operations including filtering, aggregation, grouping, sorting, and per-scope pagination.
- Cross-scope queries over log, trace, and event attributes.
- Streaming parser based on StAX for processing XES XML without loading the entire document into memory.
- Format support for
.xes,.xes.gz, and.ziparchives. - Batched and parallelized ingestion into CouchDB.
- XES export that reconstructs the hierarchical event-log structure from the stored documents.
- Spring Boot REST API for interacting with the query engine.
- Built-in web GUI for importing logs and executing queries.
- Docker Compose setup with a pre-configured CouchDB instance.
flowchart TD
Client(["Browser GUI or HTTP client"]) --> Ctrl["PqlRestController<br/>Spring Boot REST API"]
Ctrl -->|"POST /api/pql/import"| Detect["LogFileDetector"]
Detect --> Parse["StaxXesParser<br/>(streaming StAX reader)"]
Parse --> Map["StreamingXesToCouchDBMapper<br/>(flatten, batch, parallel write)"]
Map -->|"_bulk_docs"| DB[("Apache CouchDB<br/>event_logs")]
Ctrl -->|"POST /api/pql/query"| Grammar["AntlrPqlParser<br/>(ANTLR4 grammar)"]
Grammar --> Translate["PqlToCouchDbTranslator<br/>(query → Mango selector)"]
Translate -->|"_find"| DB
DB --> Exec["PqlQueryExecutor<br/>(grouping, aggregation,<br/>sorting, cross-scope logic)"]
Exec --> JSONOut["JSON result"] --> Ctrl
Ctrl -->|"GET /api/pql/export/{logId}"| Rebuild["XesExporter"]
DB --> Rebuild
Rebuild --> XESOut[".xes file"] --> Ctrl
PQL provides a declarative interface for querying process-mining data. The l:, t:, and e: prefixes refer to log, trace, and event scopes respectively.
-- Event frequency, most common first
SELECT e:name, count(e:name)
GROUP BY e:name
ORDER BY count(e:name) DESC
-- Cross-scope filter
SELECT e:name, t:name
WHERE t:name = 'Order_2'
-- Regex filter on event names
SELECT e:name, t:name
WHERE e:name MATCHES '.*(Invoice|Goods).*'
-- Process-variant mining using the ^ hoist operator
SELECT count(t:name)
GROUP BY ^e:name
ORDER BY count(t:name) DESC
-- Per-scope hierarchical pagination
SELECT e:name, t:name
ORDER BY t:name ASC, e:timestamp ASC
LIMIT e:10 OFFSET t:1, e:5Base path: /api/pql
| Method | Endpoint | Body | Description |
|---|---|---|---|
POST |
/query |
text/plain |
Executes a PQL query and returns the result as JSON |
POST |
/import |
multipart/form-data |
Imports an event log (.xes, .gz, .zip) and returns its logId |
GET |
/export/{logId} |
— | Streams the log back out as a .xes file |
DELETE |
/deleteAll |
— | Drops and recreates the database |
Example:
curl -X POST http://localhost:8080/api/pql/query \
-H "Content-Type: text/plain" \
-d "SELECT e:name, count(e:name) GROUP BY e:name ORDER BY count(e:name) DESC"| Layer | Technology |
|---|---|
| Language | Kotlin 2.1.10 |
| JVM | JDK 23 |
| Framework | Spring Boot 3.4.0 |
| Query parsing | ANTLR4 4.13.1 |
| Database | Apache CouchDB 3.3.3 |
| HTTP client | OkHttp 4.12.0 |
| JSON | Gson 2.11.0 |
| Archive handling | Apache Commons Compress 1.26.0 |
| Build tool | Gradle 8.10 (Kotlin DSL) |
| Testing | JUnit 5.10.0 |
| Infrastructure | Docker / Docker Compose |
src/main
├── antlr/ # PQL lexer and parser grammars
├── kotlin/
│ ├── app/ # REST controllers, log importer, XES exporter
│ ├── db/ # CouchDB HTTP client and Mango integration
│ ├── input/ # Streaming XES parser
│ ├── mapper/ # XES-to-CouchDB document mapping
│ └── pql/ # Parser listeners, translators, and query executor
└── resources/static/ # Built-in web GUI
- JDK 23
- Docker and Docker Compose
- Git
git clone https://github.com/sa111nt/ProcessM-NoSQL-Diploma.git
cd ProcessM-NoSQL-Diplomacd docker
docker compose up -d
cd ..The Docker Compose setup includes an initialization script that configures CouchDB for bulk event-log ingestion.
./gradlew bootRunOpen http://localhost:8080 in your browser to access the built-in GUI.
From there you can:
- Upload an XES event log.
- Execute PQL queries.
- Inspect query results.
- Export an imported log back to XES.
The repository includes an integration test suite that runs against a live CouchDB instance.
Key evaluation areas include:
- Scalability benchmarks: query execution across datasets ranging from small sample logs to approximately 1.05 million events, including aggregation, cross-scope filtering, regex filtering, sorting, and grouping.
- Storage overhead: measurement of the storage cost introduced by event denormalization in CouchDB.
- Language compliance: regression tests covering PQL parsing, translation, and query execution.
Run the test suite with:
./gradlew testSome scalability and storage experiments require the sample datasets available under src/test/resources/.
This is an academic thesis project rather than a production-ready system. Known limitations include:
- CouchDB credentials are currently hard-coded as
admin/adminfor local evaluation. - The test suite is integration-based and requires a running CouchDB instance; there is no isolated unit-test layer.
- The REST API currently allows cross-origin requests from any origin (
@CrossOrigin(origins = ["*"])). LogFileDetectorrecognizesOCEL_JSON, but actual ingestion is currently limited to XES formats.- No CI/CD pipeline is configured in the repository.
- PQL Language Specification: ProcessM Research Project
- Event Log Format: IEEE 1849-2016 XES Standard
Bachelor's thesis project, Poznań University of Technology.