Skip to content

Commit f5b559d

Browse files
authored
Merge pull request #522 from FalkorDB/copilot/merge-code-graph-repositories
Merge code-graph and code-graph-backend into unified structure following QueryWeaver model
2 parents 88cbc05 + 9e9d770 commit f5b559d

137 files changed

Lines changed: 13755 additions & 10084 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.template

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
PORT=<PORT>
2-
HOST=<HOST>
1+
# FalkorDB connection
2+
FALKORDB_HOST=localhost
3+
FALKORDB_PORT=6379
34

5+
# OpenAI API key for LLM features
6+
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
7+
8+
# Secret token for API authentication
9+
SECRET_TOKEN=<YOUR_SECRET_TOKEN>
10+
11+
# Flask server settings
12+
FLASK_RUN_HOST=0.0.0.0
13+
FLASK_RUN_PORT=5000
14+
15+
# Set to 1 to enable public access for analyze_repo/switch_commit endpoints
16+
CODE_GRAPH_PUBLIC=0

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/nextjs.yml

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,39 @@
1-
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2-
#
3-
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4-
#
5-
name: Build Next.js site
1+
name: Build
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
105
branches: ["main"]
11-
126
pull_request:
13-
14-
# Allows you to run this workflow manually from the Actions tab
157
workflow_dispatch:
168

17-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
18-
permissions:
19-
contents: read
20-
pages: write
21-
id-token: write
22-
23-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
24-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
25-
concurrency:
26-
group: "pages"
27-
cancel-in-progress: false
28-
299
jobs:
30-
# Build job
3110
build:
3211
runs-on: ubuntu-latest
3312
steps:
3413
- name: Checkout
3514
uses: actions/checkout@v4
36-
- name: Detect package manager
37-
id: detect-package-manager
38-
run: |
39-
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
40-
echo "manager=yarn" >> $GITHUB_OUTPUT
41-
echo "command=install" >> $GITHUB_OUTPUT
42-
echo "runner=yarn" >> $GITHUB_OUTPUT
43-
exit 0
44-
elif [ -f "${{ github.workspace }}/package.json" ]; then
45-
echo "manager=npm" >> $GITHUB_OUTPUT
46-
echo "command=ci" >> $GITHUB_OUTPUT
47-
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
48-
exit 0
49-
else
50-
echo "Unable to determine package manager"
51-
exit 1
52-
fi
15+
5316
- name: Setup Node
5417
uses: actions/setup-node@v4
5518
with:
56-
node-version: "24"
57-
cache: ${{ steps.detect-package-manager.outputs.manager }}
58-
- name: Restore cache
59-
uses: actions/cache@v3
60-
with:
61-
path: |
62-
.next/cache
63-
# Generate a new cache whenever packages or source files change.
64-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
65-
# If source files changed but packages didn't, rebuild from a prior cache.
66-
restore-keys: |
67-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
68-
- name: Install dependencies
69-
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
70-
- name: Build with Next.js
71-
run: ${{ steps.detect-package-manager.outputs.runner }} next build
19+
node-version: "20"
7220

21+
- name: Install frontend dependencies
22+
working-directory: ./app
23+
run: npm ci
24+
25+
- name: Build frontend
26+
working-directory: ./app
27+
run: npm run build
28+
29+
- name: Lint frontend
30+
working-directory: ./app
31+
run: npm run lint
32+
33+
- name: Setup Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.12"
7337

38+
- name: Install backend dependencies
39+
run: pip install -e ".[test]"

.github/workflows/playwright.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,61 @@ jobs:
1919
- 6379:6379
2020
steps:
2121
- uses: actions/checkout@v4
22+
2223
- uses: actions/setup-node@v4
2324
with:
2425
node-version: 24
25-
- name: Install dependencies
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.12'
30+
31+
- name: Install backend dependencies
32+
run: pip install -e .
33+
34+
- name: Install frontend dependencies
35+
working-directory: ./app
2636
run: npm ci
27-
- name: Install Playwright Browsers
28-
run: npx playwright install --with-deps
29-
- name: Set up environment variables and run tests
37+
38+
- name: Build frontend
39+
working-directory: ./app
40+
env:
41+
VITE_SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
42+
run: npm run build
43+
44+
- name: Seed test data into FalkorDB
45+
run: python e2e/seed_test_data.py
46+
47+
- name: Install Playwright
48+
run: |
49+
npm ci
50+
npx playwright install --with-deps
51+
52+
- name: Run Playwright tests
3053
env:
31-
FALKORDB_URL: ${{ secrets.FALKORDB_URL }}
3254
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3355
SECRET_TOKEN: ${{ secrets.SECRET_TOKEN }}
34-
NEXT_PUBLIC_MODE: UNLIMITED
35-
BACKEND_URL: ${{ secrets.BACKEND_URL }}
56+
CODE_GRAPH_PUBLIC: "1"
57+
MODEL_NAME: "openai/gpt-4.1-mini"
3658
run: |
37-
npm run build
38-
NEXTAUTH_SECRET=SECRET npm start & npx playwright test --shard=${{ matrix.shard }}/2 --reporter=dot,list
59+
flask --app api/index.py run --host 0.0.0.0 --port 5000 &
60+
# Wait for Flask to be ready
61+
timeout 30 bash -c 'until curl -s http://localhost:5000/ > /dev/null 2>&1; do sleep 0.5; done'
62+
npx playwright test --shard=${{ matrix.shard }}/2 --reporter=dot,list
63+
3964
- name: Ensure required directories exist
4065
if: always()
4166
run: |
4267
mkdir -p playwright-report
4368
mkdir -p playwright-report/artifacts
69+
4470
- uses: actions/upload-artifact@v4
4571
if: always()
4672
with:
4773
name: playwright-report-shard-${{ matrix.shard }}
4874
path: playwright-report/
4975
retention-days: 30
76+
5077
- name: Upload failed test screenshots
5178
if: always()
5279
uses: actions/upload-artifact@v4

.github/workflows/release-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
- name: Set tags
1818
run: |
1919
if ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}; then
20-
echo "TAGS=falkordb/code-graph-frontend:latest,falkordb/code-graph-frontend:${{ github.ref_name }}" >> $GITHUB_ENV
20+
echo "TAGS=falkordb/code-graph:latest,falkordb/code-graph:${{ github.ref_name }}" >> $GITHUB_ENV
2121
else
22-
echo "TAGS=falkordb/code-graph-frontend:edge" >> $GITHUB_ENV
22+
echo "TAGS=falkordb/code-graph:edge" >> $GITHUB_ENV
2323
fi
2424
2525
- name: Login to DockerHub

.gitignore

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
.yarn/install-state.gz
4+
node_modules/
5+
6+
# frontend build output
7+
app/dist/
88

99
# testing
1010
/coverage
1111

12-
# next.js
13-
/.next/
14-
/out/
15-
1612
# production
1713
/build
1814

@@ -26,20 +22,39 @@ yarn-debug.log*
2622
yarn-error.log*
2723

2824
# local env files
25+
.env
2926
.env*.local
3027

3128
# vercel
3229
.vercel
3330

3431
# typescript
3532
*.tsbuildinfo
36-
next-env.d.ts
37-
3833

3934
# vscode
4035
/.vscode/
41-
node_modules/
36+
37+
# test results
4238
/test-results/
4339
/playwright-report/
4440
/blob-report/
4541
/playwright/.cache/
42+
43+
# Python
44+
__pycache__/
45+
*.pyc
46+
*.pyo
47+
*.pyd
48+
*.egg-info/
49+
.eggs/
50+
dist/
51+
venv/
52+
env/
53+
.virtualenv/
54+
htmlcov/
55+
*.cover
56+
.coverage
57+
.cache/
58+
pytest_cache/
59+
*.log
60+
repositories/

Dockerfile

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,64 @@
1-
# Use a Node.js base image
2-
FROM node:24
1+
# Multi-stage build: Start with Python 3.12 base
2+
FROM python:3.12-bookworm AS python-base
3+
4+
# Main stage: Use FalkorDB base and copy Python 3.12
5+
FROM falkordb/falkordb:latest
6+
7+
ENV PYTHONUNBUFFERED=1 \
8+
FALKORDB_HOST=localhost \
9+
FALKORDB_PORT=6379
10+
11+
USER root
12+
13+
# Copy Python 3.12 from the python base image
14+
COPY --from=python-base /usr/local /usr/local
15+
16+
# Install netcat for wait loop in start.sh and system build tools
17+
RUN apt-get update && apt-get install -y --no-install-recommends \
18+
netcat-openbsd \
19+
git \
20+
build-essential \
21+
curl \
22+
ca-certificates \
23+
gnupg \
24+
&& rm -rf /var/lib/apt/lists/* \
25+
&& ln -sf /usr/local/bin/python3.12 /usr/bin/python3 \
26+
&& ln -sf /usr/local/bin/python3.12 /usr/bin/python
327

4-
# Set working directory
528
WORKDIR /app
629

7-
# Copy package.json and install dependencies
8-
COPY package*.json ./
9-
RUN npm ci
30+
# Install Python dependencies
31+
COPY pyproject.toml ./
32+
RUN pip install --no-cache-dir --break-system-packages .
33+
34+
# Install Node.js for building the frontend
35+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
36+
&& apt-get update \
37+
&& apt-get install -y nodejs \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& node --version && npm --version
40+
41+
# Copy frontend package files and install dependencies
42+
COPY app/package*.json ./app/
43+
RUN if [ -f ./app/package-lock.json ]; then \
44+
npm --prefix ./app ci --no-audit --no-fund; \
45+
elif [ -f ./app/package.json ]; then \
46+
npm --prefix ./app install --no-audit --no-fund; \
47+
fi
48+
49+
# Copy frontend source and build
50+
COPY ./app ./app
51+
RUN npm --prefix ./app run build
1052

11-
# Copy the rest of the application code
12-
COPY . .
53+
# Copy backend code
54+
COPY ./api ./api
1355

14-
# Expose the port the frontend runs on
15-
EXPOSE 3000
56+
# Copy and make start.sh executable
57+
COPY start.sh /start.sh
58+
RUN chmod +x /start.sh
1659

17-
# Build nextJS
18-
RUN npm run build
60+
EXPOSE 5000 6379
1961

20-
# Start the frontend
21-
CMD ["npm", "start"]
62+
# Use start.sh as entrypoint
63+
ENTRYPOINT ["/start.sh"]
2264

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.PHONY: help install test e2e lint lint-py lint-fe clean build-dev build-prod run-dev run-prod docker-falkordb docker-stop
2+
3+
help: ## Show this help message
4+
@echo 'Usage: make [target]'
5+
@echo ''
6+
@echo 'Targets:'
7+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
8+
9+
install: ## Install all dependencies (backend + frontend)
10+
uv sync --all-extras
11+
npm install --prefix ./app
12+
13+
build-dev: ## Build frontend for development
14+
npm --prefix ./app run build:dev
15+
16+
build-prod: ## Build frontend for production
17+
npm --prefix ./app run build
18+
19+
test: ## Run backend tests
20+
uv run python -m pytest tests/ --verbose
21+
22+
e2e: ## Run end-to-end Playwright tests
23+
npx playwright test
24+
25+
lint: lint-py lint-fe ## Run all linters
26+
27+
lint-py: ## Run Python linting (ruff)
28+
uv run ruff check .
29+
30+
lint-fe: ## Run frontend linting (TypeScript)
31+
npm --prefix ./app run lint
32+
33+
clean: ## Clean up build and test artifacts
34+
rm -rf app/dist/
35+
rm -rf test-results/
36+
rm -rf playwright-report/
37+
rm -rf .pytest_cache/
38+
rm -rf __pycache__/
39+
find . -name "*.pyc" -delete
40+
find . -name "*.pyo" -delete
41+
42+
run-dev: build-dev ## Run development server (Python backend serving built frontend)
43+
uv run flask --app api/index.py run --host $${HOST:-127.0.0.1} --port $${PORT:-5000} --debug
44+
45+
run-prod: build-prod ## Run production server
46+
uv run flask --app api/index.py run --host $${HOST:-0.0.0.0} --port $${PORT:-5000}
47+
48+
docker-falkordb: ## Start FalkorDB in Docker for testing
49+
docker run -d --name falkordb-test -p 6379:6379 falkordb/falkordb:latest
50+
51+
docker-stop: ## Stop test containers
52+
docker stop falkordb-test || true
53+
docker rm falkordb-test || true

0 commit comments

Comments
 (0)