File size: 5,300 Bytes
c11a2f8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | # Quick Start Guide
Get the Graph RAG Service up and running in 10 minutes!
## Prerequisites
Before starting, make sure you have:
- Python 3.12 or higher
- Neo4j database (running locally or remotely)
- Redis server (running locally or remotely)
- UV package manager (will be installed if missing)
## Step 1: Clone and Setup
```bash
cd graph-RAG
# Install UV if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies
uv sync
```
## Step 2: Configure Environment
```bash
# Copy environment template
cp .env.example .env
# Edit .env with your settings
# Configure NEO4J_URI, NEO4J_USER, NEO4J_PASSWORD
# Configure REDIS_URL
```
## Step 3: Ensure Backend Services Are Running
Make sure Neo4j and Redis are running and accessible:
- Neo4j should be available at the URI specified in your .env file (default: bolt://localhost:7687)
- Redis should be available at the URL specified in your .env file (default: redis://localhost:6379)
## Step 4: Start the API Server
### On Windows:
```bash
start-server.bat
```
### On Mac/Linux:
```bash
chmod +x start-server.sh
./start-server.sh
```
### Or directly (any OS):
```bash
uv run python main.py
```
The API server will start on `http://localhost:8000`
## Step 5: Start Celery Worker
For asynchronous document ingestion, start a worker in a **new terminal**:
### On Windows:
```bash
start-worker.bat
```
### On Mac/Linux:
```bash
chmod +x start-worker.sh
./start-worker.sh
```
### Or directly:
```bash
uv run celery -A src.graph_rag_service.workers.celery_worker worker --loglevel=info
```
## Step 6: Start the React Frontend
In a **new terminal**:
```bash
cd frontend-react
# Install Node dependencies (first time only)
npm install
# Start the dev server
npm run dev
```
The React UI will open at `http://localhost:5173`
> **Note:** The project uses a **React/Vite** frontend (`frontend-react/`).
> There is no `streamlit run app.py` — any references to Streamlit in older docs are outdated.
Login with: **username** `admin` / **password** `admin`
## Step 7: Test the API
### Using cURL
1. **Get Access Token**
```bash
curl -X POST "http://localhost:8000/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"username": "demo", "password": "demo"}'
```
Save the `access_token` from the response.
2. **Upload a Document**
```bash
curl -X POST "http://localhost:8000/api/documents/upload" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "file=@sample.pdf"
```
3. **Query the Knowledge Base**
```bash
curl -X POST "http://localhost:8000/api/query" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "What is this document about?",
"top_k": 5
}'
```
### Using the Interactive Docs
Open your browser and go to:
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
Click "Authorize" and enter your access token to test endpoints interactively.
## Step 8: Setup Ollama (Optional)
If you want to use local LLMs instead of OpenAI/Anthropic:
```bash
# Install Ollama (https://ollama.ai)
# Then pull models:
ollama pull llama3.2
ollama pull bge-m3
```
Update `.env`:
```
DEFAULT_LLM_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.2
OLLAMA_EMBEDDING_MODEL=bge-m3
```
## Common Commands
### Check System Health
```bash
curl http://localhost:8000/api/system/health
```
### Get System Stats
```bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8000/api/system/stats
```
### View Ontology
```bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8000/api/ontology
```
### Visualize Graph
```bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
"http://localhost:8000/api/graph/visualization?limit=50"
```
## Troubleshooting
### Neo4j Connection Error
```bash
# Verify credentials in .env
# Check Neo4j is accessible
# Access Neo4j browser
open http://localhost:7474
# Try connecting with cypher-shell
cypher-shell -u neo4j -p password
```
### Redis Connection Error
```bash
# Check Redis is running
redis-cli ping
# Test Redis connection
redis-cli -h localhost -p 6379 ping
```
### Worker Not Processing
```bash
# Check worker logs
# If running locally:
celery -A src.graph_rag_service.workers.celery_worker inspect active
```
### API Server Won't Start
```bash
# Check for port conflicts
lsof -i :8000 # On Mac/Linux
netstat -ano | findstr :8000 # On Windows
# View detailed logs
uv run python main.py
```
## Next Steps
- Read the [README.md](README.md) for comprehensive documentation
- Check [ARCHITECTURE.md](ARCHITECTURE.md) for system design details
- Explore the API docs at `http://localhost:8000/docs`
## Using with Different LLM Providers
### OpenAI
```bash
# In .env:
DEFAULT_LLM_PROVIDER=openai
OPENAI_API_KEY=sk-your-key-here
```
### Anthropic
```bash
# In .env:
DEFAULT_LLM_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-your-key-here
```
### Google Gemini
```bash
# In .env:
DEFAULT_LLM_PROVIDER=gemini
GOOGLE_API_KEY=your-key-here
```
Services will be available at:
- API: `http://localhost:8000`
- Neo4j Browser: `http://localhost:7474`
## Need Help?
- Check the troubleshooting section above
- Read the full [README.md](README.md)
- Open an issue on GitHub
Happy building! 🚀
|