Skip to content

Commit bab0090

Browse files
authored
Merge pull request #358 from FalkorDB/staging
Staging
2 parents 051c6d8 + e58cc3b commit bab0090

40 files changed

+5990
-3987
lines changed

.github/workflows/nextjs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setup Node
5454
uses: actions/setup-node@v4
5555
with:
56-
node-version: "20"
56+
node-version: "24"
5757
cache: ${{ steps.detect-package-manager.outputs.manager }}
5858
- name: Restore cache
5959
uses: actions/cache@v3

.github/workflows/playwright.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v4
2222
- uses: actions/setup-node@v4
2323
with:
24-
node-version: lts/*
24+
node-version: 24
2525
- name: Install dependencies
2626
run: npm ci
2727
- name: Install Playwright Browsers
@@ -36,17 +36,22 @@ jobs:
3636
run: |
3737
npm install
3838
npm run build
39-
NEXTAUTH_SECRET=SECRET npm start &
40-
npx playwright test --shard=${{ matrix.shard }}/2 --reporter=dot,list
39+
NEXTAUTH_SECRET=SECRET npm start & npx playwright test --shard=${{ matrix.shard }}/2 --reporter=dot,list
40+
- name: Ensure required directories exist
41+
if: always()
42+
run: |
43+
mkdir -p playwright-report
44+
mkdir -p playwright-report/artifacts
4145
- uses: actions/upload-artifact@v4
42-
if: ${{ !cancelled() }}
46+
if: always()
4347
with:
4448
name: playwright-report-shard-${{ matrix.shard }}
4549
path: playwright-report/
4650
retention-days: 30
47-
- uses: actions/upload-artifact@v4
48-
if: ${{ !cancelled() }}
51+
- name: Upload failed test screenshots
52+
if: always()
53+
uses: actions/upload-artifact@v4
4954
with:
50-
name: test-results-shard-${{ matrix.shard }}
51-
path: test-results/
55+
name: failed-test-screenshots-shard-${{ matrix.shard }}
56+
path: playwright-report/artifacts/
5257
retention-days: 30

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use a Node.js base image
2-
FROM node:22
2+
FROM node:24
33

44
# Set working directory
55
WORKDIR /app

README.md

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,114 @@
1+
# CodeGraph - Knowledge Graph Visualization Tool
2+
3+
### Visualize your repository with our graph for code analysis
4+
15
[![Try Free](https://img.shields.io/badge/Try%20Free-FalkorDB%20Cloud-FF8101?labelColor=FDE900&link=https://app.falkordb.cloud)](https://app.falkordb.cloud)
26
[![Dockerhub](https://img.shields.io/docker/pulls/falkordb/falkordb?label=Docker)](https://hub.docker.com/r/falkordb/falkordb/)
37
[![Discord](https://img.shields.io/discord/1146782921294884966?style=flat-square)](https://discord.com/invite/6M4QwDXn2w)
48
[![Workflow](https://github.com/FalkorDB/code-graph/actions/workflows/nextjs.yml/badge.svg?branch=main)](https://github.com/FalkorDB/code-graph/actions/workflows/nextjs.yml)
9+
-
10+
11+
![Alt Text](https://res.cloudinary.com/dhd0k02an/image/upload/v1739719361/FalkorDB_-_Github_-_readme_jr6scy.gif)
512

6-
![image](https://github.com/FalkorDB/code-graph/assets/753206/60f535ed-cf29-44b2-9005-721f11614803)
13+
**👉🏻[Live Demo](https://code-graph.falkordb.com/)**
714

8-
## Getting Started
9-
[Live Demo](https://code-graph.falkordb.com/)
15+
## Running Locally
1016

11-
## Run locally
12-
This project is composed of three pieces:
17+
This project consists of three core components:
1318

14-
1. FalkorDB Graph DB - this is where your graphs are stored and queried
15-
2. Code-Graph-Backend - backend logic
16-
3. Code-Graph-Frontend - website
19+
1. **FalkorDB Graph DB** – Stores and queries your graphs.
20+
2. **Code-Graph-Backend** – Handles backend logic.
21+
3. **Code-Graph-Frontend** – Provides the web interface.
1722

18-
You'll need to start all three components:
23+
To set up the project, you’ll need to start all three components.
1924

20-
### Run FalkorDB
25+
### 1. Start FalkorDB
26+
27+
Run the following command to start FalkorDB using Docker:
2128

2229
```bash
2330
docker run -p 6379:6379 -it --rm falkordb/falkordb
2431
```
2532

26-
### Run Code-Graph-Backend
33+
### 2. Start the Backend
2734

28-
#### Clone the Backend
35+
#### Clone the Backend Repository
2936

3037
```bash
3138
git clone https://github.com/FalkorDB/code-graph-backend.git
39+
cd code-graph-backend
3240
```
3341

34-
#### Setup environment variables
42+
#### Set Up Environment Variables
3543

36-
`SECRET_TOKEN` - user defined token used to authorize the request
44+
Define the required environment variables:
3745

3846
```bash
3947
export FALKORDB_HOST=localhost FALKORDB_PORT=6379 \
40-
OPENAI_API_KEY=<YOUR OPENAI_API_KEY> SECRET_TOKEN=<YOUR_SECRECT_TOKEN> \
48+
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> SECRET_TOKEN=<YOUR_SECRET_TOKEN> \
4149
FLASK_RUN_HOST=0.0.0.0 FLASK_RUN_PORT=5000
4250
```
4351

44-
#### Install dependencies & run
52+
`SECRET_TOKEN` is a user-defined token used for request authorization.
4553

46-
```bash
47-
cd code-graph-backend
54+
#### Install Dependencies & Start the Backend
4855

56+
```bash
4957
pip install --no-cache-dir -r requirements.txt
50-
5158
flask --app api/index.py run --debug > flask.log 2>&1 &
52-
5359
```
5460

55-
### Run Code-Graph-Frontend
61+
### 3. Start the Frontend
5662

57-
#### Clone the Frontend
63+
#### Clone the Frontend Repository
5864

5965
```bash
6066
git clone https://github.com/FalkorDB/code-graph.git
67+
cd code-graph
6168
```
6269

63-
#### Setup environment variables
70+
#### Set Up Environment Variables
6471

6572
```bash
6673
export BACKEND_URL=http://${FLASK_RUN_HOST}:${FLASK_RUN_PORT} \
67-
SECRET_TOKEN=<YOUR_SECRECT_TOKEN> OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
74+
SECRET_TOKEN=<YOUR_SECRET_TOKEN> OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
6875
```
6976

70-
#### Install dependencies & run
77+
#### Install Dependencies & Start the Frontend
7178

7279
```bash
73-
cd code-graph
7480
npm install
7581
npm run dev
7682
```
7783

78-
### Process a local repository
84+
### 4. Process a Local Repository
85+
86+
Use the following `curl` command to analyze a local repository:
87+
7988
```bash
80-
curl -X POST http://127.0.0.1:5000/analyze_folder -H "Content-Type: application/json" -d '{"path": "<PATH_TO_LOCAL_REPO>", "ignore": ["./.github", "./sbin", "./.git","./deps", "./bin", "./build"]}' -H "Authorization: <YOUR_SECRECT_TOKEN>"
89+
curl -X POST http://127.0.0.1:5000/analyze_folder \
90+
-H "Content-Type: application/json" \
91+
-H "Authorization: <YOUR_SECRET_TOKEN>" \
92+
-d '{"path": "<PATH_TO_LOCAL_REPO>", "ignore": ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"]}'
8193
```
8294

8395
Note: At the moment code-graph can analyze both the Java & Python source files.
8496
Support for additional languages e.g. C, JavaScript, Go is planned to be added
8597
in the future.
8698

87-
Browse to [http://localhost:3000](http://localhost:3000)
99+
### 5. Access the Web Interface
100+
101+
Once everything is running, open your browser and go to:
102+
103+
[http://localhost:3000](http://localhost:3000)
104+
105+
## Community
106+
107+
Have questions or feedback? Reach out via:
108+
109+
* [GitHub Issues](https://github.com/FalkorDB/GraphRAG-SDK/issues)
110+
* Join our [Discord](https://discord.com/invite/6M4QwDXn2w)
111+
112+
⭐️ If you find this repository helpful, please consider giving it a star!
113+
114+
Knowledge Graph, Code Analysis, Code Visualization, Dead Code Analysis, Graph Database

app/api/repo/route.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextResponse } from "next/server";
1+
import { NextRequest, NextResponse } from "next/server";
22
import { getEnvVariables } from "../utils";
33

44
export async function GET() {
@@ -22,39 +22,41 @@ export async function GET() {
2222
return NextResponse.json({ result: repositories }, { status: 200 })
2323
} catch (err) {
2424
console.error(err)
25-
return NextResponse.json((err as Error).message, { status: 400 })
25+
return NextResponse.json(err instanceof Error ? err.message : String(err), { status: 400 })
2626
}
2727
}
2828

29-
// export async function POST(request: NextRequest) {
30-
31-
// const repo_url = request.nextUrl.searchParams.get('url');
32-
33-
// try {
34-
35-
// if (!repo_url) {
36-
// throw new Error("URL parameter is missing");
37-
// }
38-
39-
// const { url, token } = getEnvVariables();
40-
41-
// const result = await fetch(`${url}/process_repo`, {
42-
// method: 'POST',
43-
// body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }),
44-
// headers: {
45-
// "Authorization": token,
46-
// 'Content-Type': 'application/json'
47-
// },
48-
// cache: 'no-store'
49-
// });
50-
51-
// if (!result.ok) {
52-
// throw new Error(await result.text());
53-
// }
54-
55-
// return NextResponse.json({ message: "success" }, { status: 200 });
56-
// } catch (err) {
57-
// console.error(err)
58-
// return NextResponse.json((err as Error).message, { status: 400 });
59-
// }
60-
// }
29+
export async function POST(request: NextRequest) {
30+
31+
const repo_url = request.nextUrl.searchParams.get('url');
32+
33+
try {
34+
35+
if (!repo_url) {
36+
throw new Error("URL parameter is missing");
37+
}
38+
39+
const { url, token } = getEnvVariables();
40+
41+
const isLocal = repo_url.startsWith("file://")
42+
43+
const result = await fetch(`${url}/${isLocal ? "analyze_folder" : "analyze_repo"}`, {
44+
method: 'POST',
45+
body: JSON.stringify({ repo_url, ignore: ["./.github", "./sbin", "./.git", "./deps", "./bin", "./build"] }),
46+
headers: {
47+
"Authorization": token,
48+
'Content-Type': 'application/json'
49+
},
50+
cache: 'no-store'
51+
});
52+
53+
if (!result.ok) {
54+
throw new Error(await result.text());
55+
}
56+
57+
return NextResponse.json({ message: "success" }, { status: 200 });
58+
} catch (err) {
59+
console.error(err)
60+
return NextResponse.json(err instanceof Error ? err.message : String(err), { status: 400 });
61+
}
62+
}

0 commit comments

Comments
 (0)