From 17c128cbc0cdf7edb184df7ca0740d773f27d67b Mon Sep 17 00:00:00 2001 From: Daniel Rosel Date: Sun, 8 Mar 2026 13:54:16 +0100 Subject: [PATCH] implementing nx management for the framework --- backend/project.json | 33 ++++++++++++++++ backend/provider/project.json | 39 +++++++++++++++++++ backend/server/project.json | 39 +++++++++++++++++++ backend/worker/project.json | 39 +++++++++++++++++++ backend/worker/requirements.txt | 3 ++ engine/project.json | 46 ++++++++++++++++++++++ nx.json | 68 +++++++++++++++++++++++++++++++++ package.json | 27 +++++++++++++ paper/project.json | 36 +++++++++++++++++ tests/e2e/project.json | 49 ++++++++++++++++++++++++ web/project.json | 52 +++++++++++++++++++++++++ 11 files changed, 431 insertions(+) create mode 100644 backend/project.json create mode 100644 backend/provider/project.json create mode 100644 backend/server/project.json create mode 100644 backend/worker/project.json create mode 100644 backend/worker/requirements.txt create mode 100644 engine/project.json create mode 100644 nx.json create mode 100644 package.json create mode 100644 paper/project.json create mode 100644 tests/e2e/project.json create mode 100644 web/project.json diff --git a/backend/project.json b/backend/project.json new file mode 100644 index 0000000..138d792 --- /dev/null +++ b/backend/project.json @@ -0,0 +1,33 @@ +{ + "$schema": "../node_modules/nx/schemas/project-schema.json", + "name": "platform", + "projectType": "application", + "sourceRoot": "backend", + "targets": { + "up": { + "executor": "nx:run-commands", + "options": { + "command": "docker compose up -d", + "cwd": "." + } + }, + "down": { + "executor": "nx:run-commands", + "options": { + "command": "docker compose down", + "cwd": "." + } + }, + "logs": { + "executor": "nx:run-commands", + "options": { + "command": "docker compose logs --tail=100 -f", + "cwd": "." + } + } + }, + "tags": [ + "scope:platform", + "type:infra" + ] +} diff --git a/backend/provider/project.json b/backend/provider/project.json new file mode 100644 index 0000000..3541d09 --- /dev/null +++ b/backend/provider/project.json @@ -0,0 +1,39 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "pricing-provider", + "projectType": "application", + "sourceRoot": "backend/provider", + "targets": { + "install": { + "executor": "nx:run-commands", + "options": { + "command": "bash -lc '[ -x ../../.venv/bin/python ] || python3 -m venv ../../.venv; ../../.venv/bin/python -m ensurepip --upgrade; ../../.venv/bin/python -m pip install -r requirements.txt'", + "cwd": "backend/provider" + } + }, + "dev": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "../../.venv/bin/uvicorn app:app --host 0.0.0.0 --port ${PROVIDER_PORT:-5001} --reload", + "cwd": "backend/provider" + } + }, + "start": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "../../.venv/bin/uvicorn app:app --host 0.0.0.0 --port ${PROVIDER_PORT:-5001}", + "cwd": "backend/provider" + } + } + }, + "tags": [ + "scope:backend", + "type:provider" + ] +} diff --git a/backend/server/project.json b/backend/server/project.json new file mode 100644 index 0000000..e454b9f --- /dev/null +++ b/backend/server/project.json @@ -0,0 +1,39 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "backend-server", + "projectType": "application", + "sourceRoot": "backend/server", + "targets": { + "install": { + "executor": "nx:run-commands", + "options": { + "command": "bash -lc '[ -x ../../.venv/bin/python ] || python3 -m venv ../../.venv; ../../.venv/bin/python -m ensurepip --upgrade; ../../.venv/bin/python -m pip install -r requirements.txt'", + "cwd": "backend/server" + } + }, + "dev": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "../../.venv/bin/uvicorn app:app --host 0.0.0.0 --port ${BACKEND_PORT:-5000} --reload", + "cwd": "backend/server" + } + }, + "start": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "../../.venv/bin/uvicorn app:app --host 0.0.0.0 --port ${BACKEND_PORT:-5000}", + "cwd": "backend/server" + } + } + }, + "tags": [ + "scope:backend", + "type:api" + ] +} diff --git a/backend/worker/project.json b/backend/worker/project.json new file mode 100644 index 0000000..781ec40 --- /dev/null +++ b/backend/worker/project.json @@ -0,0 +1,39 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "backend-worker", + "projectType": "application", + "sourceRoot": "backend/worker", + "targets": { + "install": { + "executor": "nx:run-commands", + "options": { + "command": "bash -lc '[ -x ../../.venv/bin/python ] || python3 -m venv ../../.venv; ../../.venv/bin/python -m ensurepip --upgrade; ../../.venv/bin/python -m pip install -r requirements.txt'", + "cwd": "backend/worker" + } + }, + "dev": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "../../.venv/bin/celery -A main:app worker --loglevel=info", + "cwd": "backend/worker" + } + }, + "start": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "../../.venv/bin/python main.py", + "cwd": "backend/worker" + } + } + }, + "tags": [ + "scope:backend", + "type:worker" + ] +} diff --git a/backend/worker/requirements.txt b/backend/worker/requirements.txt new file mode 100644 index 0000000..8b9fc5b --- /dev/null +++ b/backend/worker/requirements.txt @@ -0,0 +1,3 @@ +celery>=5.3,<6 +python-dotenv>=1.0.0 +redis>=5.0.0 diff --git a/engine/project.json b/engine/project.json new file mode 100644 index 0000000..b325196 --- /dev/null +++ b/engine/project.json @@ -0,0 +1,46 @@ +{ + "$schema": "../node_modules/nx/schemas/project-schema.json", + "name": "research", + "projectType": "application", + "sourceRoot": "engine", + "targets": { + "install": { + "executor": "nx:run-commands", + "options": { + "command": "make install", + "cwd": "." + } + }, + "test": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "make test.backend", + "cwd": "." + } + }, + "train": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "make train", + "cwd": "." + } + }, + "stats": { + "executor": "nx:run-commands", + "options": { + "command": "make stats.lines", + "cwd": "." + } + } + }, + "tags": [ + "scope:research", + "type:python" + ] +} diff --git a/nx.json b/nx.json new file mode 100644 index 0000000..a931e25 --- /dev/null +++ b/nx.json @@ -0,0 +1,68 @@ +{ + "$schema": "./node_modules/nx/schemas/nx-schema.json", + "useInferencePlugins": false, + "defaultBase": "main", + "namedInputs": { + "sharedGlobals": [ + "{workspaceRoot}/nx.json", + "{workspaceRoot}/package.json", + "{workspaceRoot}/Makefile", + "{workspaceRoot}/pyproject.toml", + "{workspaceRoot}/docker-compose.yml" + ], + "default": [ + "{projectRoot}/**/*", + "sharedGlobals" + ], + "production": [ + "default", + "!{projectRoot}/node_modules/**/*", + "!{projectRoot}/.next/**/*", + "!{projectRoot}/test-results/**/*", + "!{projectRoot}/build/**/*" + ] + }, + "targetDefaults": { + "build": { + "cache": true, + "inputs": [ + "production", + "^production" + ] + }, + "test": { + "cache": false, + "inputs": [ + "default", + "^production" + ] + }, + "install": { + "cache": false + }, + "dev": { + "cache": false + }, + "start": { + "cache": false + }, + "watch": { + "cache": false + }, + "clean": { + "cache": false + }, + "train": { + "cache": false + }, + "up": { + "cache": false + }, + "down": { + "cache": false + }, + "logs": { + "cache": false + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6f5d85a --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "phantom-monorepo", + "private": true, + "workspaces": [ + "web", + "tests/e2e" + ], + "scripts": { + "nx": "nx", + "projects": "nx show projects", + "graph": "nx graph", + "web:dev": "nx run web:dev", + "web:build": "nx run web:build", + "backend:server": "nx run backend-server:dev", + "backend:provider": "nx run pricing-provider:dev", + "backend:worker": "nx run backend-worker:dev", + "paper:build": "nx run paper:build", + "platform:up": "nx run platform:up", + "platform:down": "nx run platform:down", + "platform:logs": "nx run platform:logs", + "research:test": "nx run research:test", + "e2e:test": "nx run e2e:test" + }, + "devDependencies": { + "nx": "^20.4.0" + } +} diff --git a/paper/project.json b/paper/project.json new file mode 100644 index 0000000..6158bab --- /dev/null +++ b/paper/project.json @@ -0,0 +1,36 @@ +{ + "$schema": "../node_modules/nx/schemas/project-schema.json", + "name": "paper", + "projectType": "application", + "sourceRoot": "paper/src", + "targets": { + "build": { + "executor": "nx:run-commands", + "outputs": [ + "{projectRoot}/build" + ], + "options": { + "command": "make pdf.build", + "cwd": "." + } + }, + "watch": { + "executor": "nx:run-commands", + "options": { + "command": "make pdf.watch", + "cwd": "." + } + }, + "clean": { + "executor": "nx:run-commands", + "options": { + "command": "make pdf.clean", + "cwd": "." + } + } + }, + "tags": [ + "scope:paper", + "type:latex" + ] +} diff --git a/tests/e2e/project.json b/tests/e2e/project.json new file mode 100644 index 0000000..bd7c950 --- /dev/null +++ b/tests/e2e/project.json @@ -0,0 +1,49 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "e2e", + "projectType": "application", + "sourceRoot": "tests/e2e", + "targets": { + "install": { + "executor": "nx:run-commands", + "options": { + "command": "npm install", + "cwd": "tests/e2e" + } + }, + "test": { + "executor": "nx:run-commands", + "outputs": [ + "{projectRoot}/test-results" + ], + "options": { + "command": "make test.e2e", + "cwd": "." + } + }, + "test-ui": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "npm run test:ui", + "cwd": "tests/e2e" + } + }, + "test-debug": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "npm run test:debug", + "cwd": "tests/e2e" + } + } + }, + "tags": [ + "scope:test", + "type:e2e" + ] +} diff --git a/web/project.json b/web/project.json new file mode 100644 index 0000000..41f561d --- /dev/null +++ b/web/project.json @@ -0,0 +1,52 @@ +{ + "$schema": "../node_modules/nx/schemas/project-schema.json", + "name": "web", + "projectType": "application", + "sourceRoot": "web/src", + "targets": { + "install": { + "executor": "nx:run-commands", + "options": { + "command": "npm install", + "cwd": "web" + } + }, + "dev": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "options": { + "command": "npm run dev", + "cwd": "web" + } + }, + "build": { + "executor": "nx:run-commands", + "dependsOn": [ + "install" + ], + "outputs": [ + "{projectRoot}/.next" + ], + "options": { + "command": "npm run build", + "cwd": "web" + } + }, + "start": { + "executor": "nx:run-commands", + "dependsOn": [ + "build" + ], + "options": { + "command": "npm run start", + "cwd": "web" + } + } + }, + "tags": [ + "scope:web", + "type:frontend" + ] +}