Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
.git*
.vscode
backend
node_modules
34 changes: 34 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Backend CI

on:
pull_request:
paths:
- 'backend1/**'

defaults:
run:
working-directory: backend1

permissions:
contents: read

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v5

- name: Detect Bun version
id: detect-bun-version
run: echo "BUN_VERSION=$(jq -r '.engines.bun' package.json)" >> $GITHUB_OUTPUT

- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ steps.detect-bun-version.outputs.BUN_VERSION }}

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Run Biome
run: bun run ci
35 changes: 0 additions & 35 deletions .github/workflows/backend-formatter.yml

This file was deleted.

19 changes: 9 additions & 10 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Run Backend Tests
on:
pull_request:
paths:
- 'backend/**'
- 'backend1/**'

defaults:
run:
working-directory: backend
working-directory: backend1

permissions:
contents: read
Expand All @@ -19,17 +19,16 @@ jobs:
steps:
- uses: actions/checkout@v5

- name: Install poetry
run: pipx install poetry
- name: Detect Bun version
id: detect-bun-version
run: echo "BUN_VERSION=$(jq -r '.engines.bun' package.json)" >> $GITHUB_OUTPUT

- name: Set up Python 3.14
uses: actions/setup-python@v6
- uses: oven-sh/setup-bun@v2
with:
python-version: '3.14'
cache: 'poetry'
bun-version: ${{ steps.detect-bun-version.outputs.BUN_VERSION }}

- name: Install dependencies
run: poetry install --no-root --with dev
run: bun install --frozen-lockfile

- name: Run tests
run: poetry run pytest
run: bun test
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM oven/bun:1.3.1-alpine

COPY backend1/package.json backend1/bun.lock ./backend1/
COPY frontend/package.json frontend/bun.lock ./frontend/
COPY packages/elysia/package.json ./packages/elysia/
COPY package.json bun.lock ./

RUN bun install --frozen-lockfile

COPY . .

CMD ["bun", "dev", "--host"]
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This repository contains the code for a BPMN Real-Time Collaboration Challenge.
## Prerequisites

- Docker
- Docker Compose

## Running the application

Expand All @@ -15,12 +14,17 @@ This repository contains the code for a BPMN Real-Time Collaboration Challenge.
cd summ-ai
```

2. Build and run the application using Docker Compose:
2. Build the application using Docker:
```bash
docker compose up --build
docker build -t summ-ai .
```

3. Access the application:
3. Run the application using Docker:
```bash
docker run --rm -p 5173:5173 -p 8000:8000 summ-ai
```

4. Access the application:
- Frontend: [http://localhost:5173](http://localhost:5173)
- Backend API: [http://localhost:8000](http://localhost:8000)

Expand All @@ -38,7 +42,6 @@ This repository contains the code for a BPMN Real-Time Collaboration Challenge.
- This restricts locking selected elements
- The lock marker does not prohibit any user from editing the element
- The storage of diagram data inside the frontend application is intended for prototyping purposes only
- End-to-end type safety
- Tests in the frontend application are not implemented

## Demo
Expand Down
13 changes: 13 additions & 0 deletions backend1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Backend

The backend is a Elysia application that handles the WebSocket connections and the API requests. The application communicates with the frontend using the same Elysia application with end-to-end type safety.

### Prerequisites

- Bun 1.3.1

### Installation

1. Navigate to the backend directory
2. Install the dependencies: `bun install --frozen-lockfile`
3. Run the application: `bun dev --host`
39 changes: 39 additions & 0 deletions backend1/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.2/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"includes": ["src/**/*.ts"],
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "all",
"semicolons": "asNeeded"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
28 changes: 28 additions & 0 deletions backend1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "backend1",
"version": "0.1.0",
"engines": {
"bun": "1.3.1"
},
"scripts": {
"dev": "bun --watch --no-clear-screen src/index.ts",
"start": "bun run src/index.ts",
"typecheck": "bun tsc --noEmit",
"check": "biome check .",
"check:fix": "biome check --write .",
"ci": "biome ci",
"lint": "biome lint .",
"lint:fix": "biome lint --write ."
},
"dependencies": {
"@elysiajs/cors": "1.4.0",
"@elysiajs/eden": "catalog:",
"elysia": "catalog:"
},
"devDependencies": {
"@biomejs/biome": "catalog:",
"@types/bun": "catalog:",
"typescript": "catalog:"
},
"module": "src/index.ts"
}
65 changes: 65 additions & 0 deletions backend1/src/diagram-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export class DiagramState {
private currentXml: string = `<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1tmf6t6" targetNamespace="http://bpmn.io/schema/bpmn" exporter="bpmn-js" exporterVersion="17.11.1">
<bpmn:process id="Process_1lclg3e" isExecutable="false">
<bpmn:startEvent id="StartEvent_1sgwknq" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1lclg3e">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1sgwknq">
<dc:Bounds x="156" y="82" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>`
private lockedElements: Map<string, string> = new Map()

getXml(): string {
return this.currentXml
}

updateXml(xml: string): void {
this.currentXml = xml
}

requestLock(elementIds: string[], userId: string): boolean {
// Check if any of the requested elements are already locked by another user
for (const elementId of elementIds) {
const currentOwner = this.lockedElements.get(elementId)
if (currentOwner && currentOwner !== userId) {
return false
}
}

// Lock all requested elements
for (const elementId of elementIds) {
this.lockedElements.set(elementId, userId)
}

return true
}

releaseLock(elementIds: string[]): void {
for (const elementId of elementIds) {
this.lockedElements.delete(elementId)
}
}

hasLockedElements(): boolean {
return this.lockedElements.size > 0
}

getLockedElements(): Record<string, string> {
return Object.fromEntries(this.lockedElements)
}

releaseUserLocks(userId: string): void {
const elementsToRelease: string[] = []
for (const [elementId, owner] of this.lockedElements) {
if (owner === userId) {
elementsToRelease.push(elementId)
}
}
this.releaseLock(elementsToRelease)
}
}
9 changes: 9 additions & 0 deletions backend1/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { app as websocketApp } from '@backend/websocket'
import { cors } from '@elysiajs/cors'
import { Elysia } from 'elysia'

const app = new Elysia().use(cors()).use(websocketApp).listen(8000)

console.log(`Server running on port ${app.server?.port}`)

export type App = typeof app
Loading