Contributor Guide¶
This guide complements Contributing and the root-level
CONTRIBUTING.md file. It provides a deeper walkthrough of the repository
layout, development workflows, and quality expectations so that new
contributors can become productive quickly.
On this page
Project Overview¶
BESSER builds upon the B-UML metamodel to generate deployable applications. Most contributions fall into one of these areas:
B-UML metamodel (
besser.BUML.metamodel): defines the core modeling constructs that generators consume.Generators (
besser.generators): translate models into code for specific stacks (e.g., Django, SQLAlchemy, Flutter).Utilities (
besser.utilities): cross-cutting helpers shared across the metamodel and generators. This package also exposes services that power the backend of the web modeling editor (REST APIs, validation helpers, deployment glue).Examples and tests (
tests): executable specifications that document expected behavior and protect against regressions.Documentation (
docs): user- and contributor-focused guidance built with Sphinx and published to Read the Docs.
Ways to Contribute¶
You don’t need to be a Python expert to help. Useful contributions include:
Code — new generators, metamodel improvements, bug fixes, performance work, refactors.
Documentation — clarifying existing pages, fixing typos, writing tutorials, adding examples to
docs/source/.Tests — improving coverage, adding regression tests, hardening the metamodel and converters.
Issue triage — reproducing reported bugs, narrowing down causes, suggesting workarounds.
Feedback — sharing how you use BESSER, what is missing, what is confusing. Open a discussion or issue.
Examples — contributing new sample models or use cases to BESSER-examples.
If you are looking for a starting point, browse issues labeled good first issue or help wanted.
Repository Layout¶
besser/Python packages that expose the BESSER APIs. Subpackages mirror major feature areas and collectively implement the backend of the web modeling editor:
BUML/metamodel/– Metamodel definitions (structural, state machine, GUI, agents, quantum, etc.).BUML/notations/– Concrete-syntax parsers (PlantUML, OCL, mockup-to-BUML, …).generators/– Code generators implementingGeneratorInterface.utilities/– Reusable helpers, configuration objects, backend for the web modeling editor (REST endpoints, validation, deployment glue).utilities/web_modeling_editor/frontend/– Frontend git submodule (separate repository).
docs/Source files for the documentation site. ReStructuredText lives in
docs/source/and static assets indocs/source/_static.tests/Pytest suites covering the metamodel, generators, utilities, and sample applications. Tests often double as executable examples.
docker-compose.ymlandDockerfileContainer definitions that reproduce the full stack locally, useful for verifying generator output or end-to-end flows.
Frontend assets for the BESSER Web Modeling Editor live in the separate
BESSER-Web-Modeling-Editor
repository (vendored here as the
besser/utilities/web_modeling_editor/frontend submodule). Contribute UI
updates there; this repository focuses on the backend APIs, metamodel,
generators, and utilities consumed by that frontend.
Getting Started¶
Prerequisites¶
Python 3.11 or 3.12 (
setup.cfgdeclarespython_requires = >=3.11; CI tests both).Git, including submodule support.
Node.js 20+ (only if you plan to run the web modeling editor frontend locally).
System packages on Linux (Debian/Ubuntu names):
sudo apt-get install python3-venv unixodbc bubblewrappython3-venv(python3.12-venvon Ubuntu 24.04) providesensurepip, without whichpython -m venvfails.pyodbcneedsunixodbcat import time.bubblewrapis the Spec-Driven Agent’s shell sandbox; CI installs it, and the sandbox tests skip without it.
Fork, clone, and initialize¶
Fork the repository to your own GitHub account.
Clone your fork (with submodules so the frontend is available):
git clone --recurse-submodules https://github.com/<your-username>/BESSER.git cd BESSERIf you already cloned without
--recurse-submodules:git submodule update --init --recursiveAdd the upstream remote so you can keep your fork in sync:
git remote add upstream https://github.com/BESSER-PEARL/BESSER.git
Create a virtual environment¶
python -m venv venv
# Activate it
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windows (cmd / PowerShell)
Keep the environment activated in every terminal you use. The commands below
(pytest, besser-wme-backend) are installed into it. A user-level
pip install outside a virtual environment puts them in ~/.local/bin on
Linux, which is not on the default PATH; run them through the interpreter
instead (python -m pytest). BESSER starts its own child processes with the
interpreter that runs it, so the generators do not depend on PATH.
Install dependencies¶
pip install -e . # editable install of the BESSER package
pip install -r besser/utilities/web_modeling_editor/backend/requirements.txt
The second line is what CI installs, and it is required to run the backend:
FastAPI and its dependencies are not in the root requirements.txt.
Optional but recommended:
pip install -r docs/requirements.txt # Sphinx + theme for building the docs
One test module imports a package that is not in the root
requirements.txt: tests/utilities/web_modeling_editor/backend/test_spreadsheet_import.py
needs openpyxl, which ships in the backend requirements file installed
above. Without it, pytest stops at collection — an error, not a test
failure. torch and tensorflow are needed only to run the generated
neural-network code, not to run tests/generators/nn/, which passes without
them.
Verify the install¶
python tests/BUML/metamodel/structural/library/library.py
python -m pytest tests/ -k library
If both run cleanly, you are ready to go.
Web Modeling Editor Frontend Setup¶
If you want to run or extend the Web Modeling Editor (WME) frontend, use the WME repository directly or the git submodule inside this repo. Prerequisites: Node.js 20+ and npm.
The submodule at besser/utilities/web_modeling_editor/frontend is the
BESSER-Web-Modeling-Editor
repository, checked out at a fixed commit (a detached HEAD). To change the UI,
create a branch inside the submodule and open the pull request in that
repository; see Coordinating Changes Across BESSER and WME.
Using the submodule:
Initialize the submodule:
git submodule update --init --recursive.Install dependencies from the lockfile, in the submodule root:
cd besser/utilities/web_modeling_editor/frontend && npm ci.Start the backend API (from the repo root):
python besser/utilities/web_modeling_editor/backend/backend.py.Start the webapp dev server:
npm run dev(still in the frontend folder).
The Vite dev server runs on http://localhost:8080 and expects the backend at
http://localhost:9000/besser_api in development mode. Open the editor at
http://localhost:8080: the backend’s CORS allow-list (DEFAULT_CORS_ORIGINS)
covers localhost and 127.0.0.1, and any other host name must be added
through CORS_ORIGINS.
The backend logs a warning for each unset optional variable, including
GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET. They are only needed for
GitHub sign-in and deploy; drawing models and generating code work without them.
Using the standalone WME repo:
Clone BESSER-Web-Modeling-Editor.
Run
npm ciandnpm run dev.Start the BESSER backend as above if you need live API integration.
Development Guidelines¶
Code style¶
Follow PEP 8 with 4-space indentation and a 120-character line limit (configured in
pyproject.toml).Use
snake_casefor functions/variables,PascalCasefor classes,UPPER_CASEfor constants.Add type hints for public APIs and write descriptive docstrings.
Order imports: standard library → third-party → local.
Additional formatting, naming, and AI-assistant rules are in
.github/copilot-instructions.md(also available as.cursorrulesfor Cursor users).
Linting¶
We use Ruff for linting (run automatically in CI):
pip install ruff import-linter==2.15
ruff check besser/
lint-imports
The rules live in pyproject.toml ([tool.ruff] and
[tool.importlinter]), so this is exactly what CI runs. Lint besser/
rather than .: CI does not lint the tests.
lint-imports enforces the package layers. From top to bottom:
besser.utilities.web_modeling_editor (the editor backend),
besser.spec_driven_agent, besser.generators, besser.BUML.notations
and besser.BUML.metamodel. A module imports only from the layers below it,
and besser.utilities outside the backend never imports the generators, the
agent or the backend. Inside the backend, services/ never imports
routers/. The few known exceptions are listed in
ignore_imports, each with the change that removes it.
Fix lint warnings before opening a PR. CI will fail on lint errors.
Working in core packages¶
Generators (
besser/generators/) — inherit fromGeneratorInterface; place Jinja2 templates ingenerators/<name>/templates/; register the generator with one entry inbesser/generators/registry.py, which the web editor and the Spec-Driven Agent both read (see Build Your Own Generator).Metamodel (
besser/BUML/metamodel/) — keep changes backward-compatible where possible; mirror existing patterns (private fields with validating setters,Element → NamedElement → …hierarchy).Notations (
besser/BUML/notations/) — use ANTLR grammars and the listener pattern, mirroring the existing PlantUML and OCL parsers.Backend (
besser/utilities/web_modeling_editor/backend/) — the FastAPI app uses a modular router architecture (routers, middleware, services, models). Prefer extending an existing module over creating bespoke helpers.Spec-Driven Agent (
besser/spec_driven_agent/plus.../backend/services/spec_driven/) — the hybrid generation pipeline: a deterministic generator, then an LLM customization loop, then validation with a bounded auto-fix loop.pipeline/orchestrator.pyowns Phases 1 and 2,pipeline/phase3_repair.pyowns validation and repair, andvalidation/issues.pyclassifies severity;agent/tools.pydeclares the LLM’s tool surface andtool_executor.pyimplements it;llm_client.pyholds the provider clients, pricing, and the keyless-tier fallback chain. On the service side,runner.pydrives a run and emits SSE, andrun_manager.pygives runs durable ownership and event replay. A new tool needs its declaration inagent/tools.py, an entry in_TOOL_MODEL_REQUIREMENTSin the same file (so it is only offered when the models it needs are present), and a handler inToolExecutor._handlers. A generator tool is declared instead by theagent_toolof its entry inbesser/generators/registry.py(which carries its requirements), its id inAGENT_TOOL_ORDERand the handler. See Spec-Driven Agent.Bidirectional converters — if you support a feature in
json_to_buml/, add the symmetric path inbuml_to_json/. Round-trips must be lossless.
Validation strategy¶
Three validation layers run together; respect each in the right place:
Construction — setter checks in metamodel classes (fail fast).
Metamodel —
.validate()returns{success, errors, warnings}.Constraints — OCL constraints evaluated against the model.
Collect validation errors instead of throwing on the first one, so users see the full picture.
Testing and Quality Checks¶
Run the full suite before pushing, scoped to tests/:
python -m pytest tests/
CI runs python -m pytest tests/ -n auto -q --tb=short; -n auto is pytest-xdist (in the dev extra) with one worker per core.
While iterating, target the area you are changing:
python -m pytest tests/generators -k sqlalchemy
python -m pytest tests/BUML/metamodel/structural -k library
If openpyxl is not installed, skip the module that imports it so collection
does not fail:
python -m pytest tests/ \
--ignore=tests/utilities/web_modeling_editor/backend/test_spreadsheet_import.py
Guidelines:
Add or update tests alongside any behavior change.
Reuse fixtures from
tests/conftest.py(e.g.,library_book_author_model,employee_self_assoc_model,player_team_domain_model) andtests/generators/conftest.pyinstead of duplicating models.Test round-trips for converters —
JSON → BUML → JSONmust be the identity.Validate behavior, not implementation details. Assertions on observable outputs age better than assertions on internal structure.
Documentation Workflow¶
Documentation lives in docs/source/ and is written in reStructuredText.
Keep it in sync with code: a new generator, endpoint, metamodel concept, or
workflow should be reflected in the docs.
Build locally to check formatting:
cd docs
make html # Linux / macOS
make.bat html # Windows
Open docs/build/html/index.html to preview.
Common pages to update:
buml_language.rst— metamodel additionsgenerators.rst— new deterministic generators (the toctree and the “Choosing a Generator” table)spec_driven_agent/— the Spec-Driven Agent: its pipeline (how_it_works.rst), tool surface (tools.rst), severities (validation.rst), caps and durable runs (runs.rst), the REST + SSE contract (api.rst), and theBESSER_LLM_*reference (configuration.rst)web_editor.rst— editor workflowsweb_editor_backend.rst— backend endpoints and environment variablesweb_editor_github.rst— how the editor and the agent work with GitHubutilities.rst— new utilitiescontributor_guide.rst/ai_assistant_guide.rst— workflow changes
Place images in docs/source/img/ or docs/source/_static/. Cross-link
related pages using :doc:, :mod:, or :ref: roles to help readers
navigate.
Branching and Commits¶
Branch naming¶
Create a topic branch off ``development`` (the integration branch). Use a prefix that matches the type of change:
Prefix |
Use for |
Example |
|---|---|---|
|
New features or capabilities |
|
|
Bug fixes |
|
|
Documentation-only changes |
|
|
Code restructuring without behavior changes |
|
|
Test additions or improvements |
|
|
Tooling, CI, dependency bumps, repo maintenance |
|
Use lowercase, hyphen-separated, descriptive names. Avoid personal
prefixes (arm/...) and avoid umbrella branches that bundle unrelated
changes.
Commit conventions¶
We follow Conventional Commits. Use one of these prefixes in your commit subject:
feat:— a new featurefix:— a bug fixdocs:— documentation-only changesrefactor:— code change that neither fixes a bug nor adds a featuretest:— adding or fixing testschore:— tooling, CI, dependency, or repo-maintenance changes
Keep subjects short, imperative, and lowercase, e.g.:
feat: add quantum circuit generator
fix: handle null cardinality in OCL parser
docs: clarify branch naming in CONTRIBUTING
Group related work into logically scoped commits — reviewers should be able to follow the reasoning commit by commit.
Creating Pull Requests¶
Target branch¶
Important
Open all pull requests against development, not master.
The master branch tracks released versions. The development branch
is where features are integrated and validated before release.
Maintainers periodically merge development into master as part of
the release process — contributors should not target master directly.
When opening the PR on GitHub, the base branch dropdown defaults to
master. Change it to development before clicking Create pull
request:
base repository: BESSER-PEARL/BESSER base: development ← change this!
head repository: <your-fork>/BESSER compare: feature/your-change
If you forget, no harm done — just edit the base branch on the existing PR (GitHub allows changing it after creation). Maintainers will also flag it.
Step-by-step¶
Sync your fork and branch off
development:git checkout development git pull upstream development git checkout -b feature/your-changeCommit your work using the Conventional Commits prefixes. Make focused commits — reviewers should be able to follow your reasoning commit by commit.
Run quality checks locally before pushing:
python -m pytest tests/ # tests ruff check besser/ # lint, as CI runs it python docs/check_docs.py # if you touched the docsPush your branch:
git push -u origin feature/your-changeOpen the PR on GitHub with
developmentas the base branch (see above). If the work is in progress and you want early feedback, open it as a draft PR — maintainers will review when you mark it ready.Rebase or merge
developmentinto your branch before requesting final review, so the PR reflects an up-to-date base:git fetch upstream git rebase upstream/development git push --force-with-leaseRespond to review feedback. Review is a collaborative conversation, not a gate. Push fixup commits during review and let the maintainer squash on merge if appropriate.
Writing a good PR description¶
A great PR description answers four questions: What changed? Why? How was it tested? What should reviewers pay attention to? Use this template (the PR template in this repo follows the same structure):
## What
A 1–3 sentence summary of the change. Stay concrete — name the files,
generators, endpoints, or metamodel concepts you touched.
## Why
The motivation. Link the issue (`Closes #123`), or describe the bug,
limitation, or use case driving the change. Reviewers should not have
to guess the intent.
## How
A brief explanation of the approach, *especially* for non-obvious design
choices. Mention alternatives you considered and why you discarded them.
Skip this section for trivial fixes.
## Testing
- Unit tests added/updated: `tests/path/to/test_thing.py`
- Manual checks: e.g., "ran `python tests/.../library.py` and inspected
output", or "tested in the web editor: created a class diagram with
inheritance, exported it, re-imported, round-trip preserved"
- Edge cases considered: …
## Screenshots / Recordings
(For UI or output changes. Drag-and-drop images or GIFs into the PR.)
## Follow-ups / Known limitations
Anything intentionally out of scope for this PR, or known gaps to address
later. Linking a follow-up issue is even better.
## Checklist
- [ ] Targeted `development` (not `master`)
- [ ] Tests added or updated
- [ ] Docs updated (`docs/source/...`) if user-facing behavior changed
- [ ] Lint passes (`ruff check .`)
- [ ] Frontend submodule pointer updated (if a cross-repo change)
Tips¶
Title matters. Use a Conventional Commits-style title that mirrors your main commit, e.g.
feat: add quantum circuit generator. Reviewers scan PR lists by title.Be specific, not generic. “Fix bug” is not a PR description. “Fix null-pointer in OCL parser when constraint references an unset attribute” is.
Show, don’t tell. For UI work, include before/after screenshots. For generator work, paste a snippet of the generated output. For metamodel work, paste the model that exercises the change.
Call out anything risky. Backward-incompatible changes, schema migrations, performance trade-offs, dependencies bumped — flag them explicitly so reviewers don’t miss them.
Keep it focused. One PR = one logical change. If you find yourself writing “this PR also …”, split it.
Example (good)¶
Title:
feat: add JSONSchema generator with array & enum supportWhat. Adds a new
JSONSchemaGeneratorunderbesser/generators/jsonschema/, registered in the backend generator registry. Supports primitive types, enums, arrays (via multiplicity), and nested associations.Why. Closes #412. Several users asked for JSON Schema export to drive validation in non-Python services.
How. Walks the
DomainModel, emitting one schema file perClass. Reuses the existing primitive-type mapping fromSQLGenerator(extracted intobesser/utilities/type_mapping.py). Templates use Jinja2, consistent with other generators.Testing. Added
tests/generators/jsonschema/with three fixtures (library, enums, self-association). Round-trip-validated outputs against thejsonschemaPython package. Manually exported from the web editor.Follow-ups. OneOf/AnyOf for inheritance is out of scope — tracked in #418.
Review and merging¶
All PRs must pass automated checks. The CI workflow runs three jobs — tests on Python 3.11 and 3.12, the Ruff lint above, and a docs build that fails on any Sphinx warning (
python docs/check_docs.py) — plus CodeQL from the security workflow.At least one maintainer review is required, per the governance rules.
Maintainers choose the merge strategy (squash, rebase, or merge commit) based on the change.
Coordinating Changes Across BESSER and WME¶
If a change impacts both the BESSER backend and the WME frontend (for example, adding a new DSL with graphical notation):
Implement and commit the frontend change in the WME repository, targeting its
developbranch.Implement and commit the backend change in this repository, targeting
development.Update the git submodule pointer in this repo to the new WME commit:
# Fast-forward the submodule to the tip of the branch ``.gitmodules`` # tracks for it (currently ``main``). git submodule update --remote besser/utilities/web_modeling_editor/frontend git add besser/utilities/web_modeling_editor/frontend git commit -m "chore: bump frontend submodule"Link the two pull requests in their descriptions and note the intended merge order.
For the WME-side steps, see the WME contributor guide: Adding a New Diagram Type. For the full cross-repo checklist, see End-to-End: New Diagram Type + DSL.
Need Help?¶
If you are unsure where to start, open a discussion in the issue tracker or reach out via info@besser-pearl.org. We are happy to mentor new contributors and pair on first issues.