Skip to content

Update README.md #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
155 changes: 114 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,160 @@
<div align="center">

# Code Graph

[![Try Free](https://img.shields.io/badge/Try%20Free-FalkorDB%20Cloud-FF8101?labelColor=FDE900&link=https://app.falkordb.cloud)](https://app.falkordb.cloud)
[![Dockerhub](https://img.shields.io/docker/pulls/falkordb/falkordb?label=Docker)](https://hub.docker.com/r/falkordb/falkordb/)
[![Discord](https://img.shields.io/discord/1146782921294884966?style=flat-square)](https://discord.com/invite/6M4QwDXn2w)
[![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)

![image](https://github.com/FalkorDB/code-graph/assets/753206/60f535ed-cf29-44b2-9005-721f11614803)
**Visualize codebases as knowledge graphs to analyze dependencies, detect bottlenecks, and optimize projects.**

![FalkorDB Code Graph](https://github.com/user-attachments/assets/725e8ac0-8a64-474d-b2af-2de49b37293e)

</div>

## Quick Start

Try the [**Live Demo**](https://code-graph.falkordb.com/) to see Code Graph in action!

## Getting Started
[Live Demo](https://code-graph.falkordb.com/)
## Prerequisites

## Run locally
This project is composed of three pieces:
Before running locally, ensure you have:
- Docker installed
- Python 3.8+ with pip
- Node.js 16+ with npm
- OpenAI API key ([get one here](https://platform.openai.com/api-keys))

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

You'll need to start all three components:
Code Graph consists of three components that work together:

### Run FalkorDB
| Component | Purpose | Port |
|-----------|---------|------|
| **FalkorDB** | Graph database for storing and querying code relationships | 6379 |
| **Backend** | API server handling analysis logic | 5000 |
| **Frontend** | Web interface for visualization | 3000 |

### Step 1: Start FalkorDB

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

### Run Code-Graph-Backend

#### Clone the Backend
### Step 2: Setup Backend

#### Clone and configure
```bash
git clone https://github.com/FalkorDB/code-graph-backend.git
cd code-graph-backend
```

#### Setup environment variables

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

#### Set environment variables
```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 FALKORDB_HOST=localhost
export FALKORDB_PORT=6379
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
export SECRET_TOKEN=<YOUR_SECRET_TOKEN>
export FLASK_RUN_HOST=0.0.0.0
export FLASK_RUN_PORT=5000
```

#### Install dependencies & run
> **Tip**: Create a `.env` file with these variables for easier management

#### Install and run
```bash
cd code-graph-backend

pip install --no-cache-dir -r requirements.txt

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

```

### Run Code-Graph-Frontend

#### Clone the Frontend
### Step 3: Setup Frontend

#### Clone and configure
```bash
git clone https://github.com/FalkorDB/code-graph.git
cd code-graph
```

#### Setup environment variables

#### Set 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>
export BACKEND_URL=http://localhost:5000
export SECRET_TOKEN=<YOUR_SECRET_TOKEN>
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
```

#### Install dependencies & run

#### Install and run
```bash
cd code-graph
npm install
npm run dev
```

### Process a local repository
### Step 4: Analyze Your Code

Once all services are running, analyze 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>"
curl -X POST http://127.0.0.1:5000/analyze_folder \
-H "Content-Type: application/json" \
-H "Authorization: <YOUR_SECRET_TOKEN>" \
-d '{
"path": "/path/to/your/repo",
"ignore": [
"./.github",
"./.git",
"./node_modules",
"./build",
"./dist"
]
}'
```

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.
Then visit [http://localhost:3000](http://localhost:3000) to view your code graph!

## Configuration

### Environment Variables

| Variable | Description | Required | Default |
|----------|-------------|----------|---------|
| `OPENAI_API_KEY` | Your OpenAI API key for code analysis | Yes | - |
| `SECRET_TOKEN` | Authorization token for API requests | Yes | - |
| `FALKORDB_HOST` | FalkorDB server hostname | No | localhost |
| `FALKORDB_PORT` | FalkorDB server port | No | 6379 |
| `FLASK_RUN_HOST` | Backend server host | No | 0.0.0.0 |
| `FLASK_RUN_PORT` | Backend server port | No | 5000 |

### Supported Languages

Currently supported:
- **C/C++**
- **Python**

Coming soon:
- **JavaScript/TypeScript**
- **Go**
- **Java**
- **Rust**
## Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

- **Email**: [email protected]
- **Discord**: [Join our community](https://discord.gg/falkordb)
- **Issues**: [GitHub Issues](https://github.com/FalkorDB/code-graph/issues)
- **Docs**: [Documentation](https://docs.falkordb.com)

---

<div align="center">
Made with ❤️ by the FalkorDB team
</div>

### Consider ⭐️ to show your support!

Browse to [http://localhost:3000](http://localhost:3000)
code graph, code visualization, codebase analysis, dependency graph, software architecture, code dependencies, graph database, FalkorDB, code analysis tool, source code visualization, project dependencies, code structure analysis, software development tools, code mapping, dependency tracking, code relationships, software visualization, code exploration, development workflow, code insights, static code analysis, code comprehension, software engineering tools, code quality analysis, project structure visualization
Loading