Skip to content
Merged
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
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,80 @@
## Getting Started
[Live Demo](https://code-graph.falkordb.com/)

## Run locally
This project is composed of three pieces:

1. FalkorDB Graph DB - this is where your graphs are stored and queried
2. Code-Graph-Backend - backend logic
3. Code-Graph-Frontend - website

You'll need to start all three components:

### Run FalkorDB

```bash
docker run -p 6379:6379 -it --rm falkordb/falkordb
```

### Install node packages
### Run Code-Graph-Backend

#### Clone the Backend

```bash
npm install
git clone https://github.com/FalkorDB/code-graph-backend.git
```

### Set your OpenAI key
#### Setup environment variables

`SECRET_TOKEN` - user defined token used to authorize the request

```bash
export FALKORDB_HOST=localhost FALKORDB_PORT=6379 \
OPENAI_API_KEY=<YOUR OPENAI_API_KEY> SECRET_TOKEN=<YOUR_SECRECT_TOKEN> \
FLASK_RUN_HOST=0.0.0.0 FLASK_RUN_PORT=5000
```
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY

#### Install dependencies & run

```bash
cd code-graph-backend

pip install --no-cache-dir -r requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swilly22 why not poetry install?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've specifically created to ease up on the user. we felt like users are more comfortable running pip install


flask --app api/index.py run --debug > flask.log 2>&1 &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve process management and security configuration.

The current Flask configuration has several concerns:

  1. Debug mode should not be used in production
  2. Background process management using & might be unclear for some users

Consider this safer approach:

-flask --app api/index.py run --debug > flask.log 2>&1 &
+# For development
+flask --app api/index.py run --debug
+
+# For production
+flask --app api/index.py run

Also, consider adding instructions for proper process management tools like supervisor or systemd for production deployments.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
flask --app api/index.py run --debug > flask.log 2>&1 &
# For development
flask --app api/index.py run --debug
# For production
flask --app api/index.py run


```

### Run the development server
### Run Code-Graph-Frontend

#### Clone the Frontend

```bash
git clone https://github.com/FalkorDB/code-graph.git
```

#### Setup environment variables

```bash
export BACKEND_URL=http://${FLASK_RUN_HOST}:${FLASK_RUN_PORT} \
SECRET_TOKEN=<YOUR_SECRECT_TOKEN> OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
```

#### Install dependencies & run

```bash
cd code-graph
npm install
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
### Process a local repository
```bash
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>"
```

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

Browse to [http://localhost:3000](http://localhost:3000)
Loading