---
title: 'Setting Up ResilientDB GraphQL'
description: 'Setup instructions for ResilientDB GraphQL'
---

import { Callout } from 'nextra/components'

# Setting Up ResilientDB GraphQL

This guide will help you set up ResilientDB GraphQL on your system. Follow these steps to get started.

## Prerequisites

- Python 3.10 or higher
- pip (Python package manager)
- Virtual environment (recommended)
- Nginx (for production deployment)

## Installation

1. Clone the repository:
```bash
git clone https://github.com/apache/incubator-resilientdb-graphql.git
cd incubator-resilientdb-graphql
```

2. Create and activate a virtual environment:
```bash
python3 -m venv venv
source venv/bin/activate
```

3. Install dependencies:
```bash
pip install -r requirements.txt
```

4. Start the development server:
```bash
python3 app.py
```

The server will be available at `http://localhost:5000/graphql`

## Production Deployment

For production deployment, follow these steps:

1. Install Nginx:
```bash
sudo apt-get install nginx -y
```

2. Configure Nginx as a reverse proxy:
```bash
sudo vim /etc/nginx/conf.d/flask.conf
```

Add the following configuration:
```nginx
server {
    listen 80;
    server_name your_domain_or_ip;
    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
```

3. Create a systemd service:
```bash
sudo vim /etc/systemd/system/flask.service
```

Add the following configuration:
```ini
[Unit]
Description=Gunicorn instance to serve Flask
After=network.target

[Service]
User=root
Group=www-data
WorkingDirectory=/path/to/your/app
Environment="PATH=/path/to/your/app/venv/bin"
ExecStart=/path/to/your/app/venv/bin/gunicorn --bind 0.0.0.0:8000 wsgi:app

[Install]
WantedBy=multi-user.target
```

4. Start and enable the service:
```bash
sudo systemctl daemon-reload
sudo systemctl start flask
sudo systemctl enable flask
```

## Troubleshooting

<Callout type="warning">
  If you encounter any issues during installation, make sure you have all the prerequisites installed and your Python version is compatible.
</Callout>

Common issues and solutions:

1. **Port already in use**
   - Check if another service is using port 5000
   - Change the port in your configuration

2. **Permission denied**
   - Ensure you have the correct permissions for the installation directory
   - Use `sudo` for system-wide installations

3. **Dependency conflicts**
   - Use a virtual environment to isolate dependencies
   - Check for conflicting package versions

## Next Steps

Once you have completed the setup, you can start using ResilientDB GraphQL. Check out the [Usage Guide](/resilientdb_graphql) for examples and best practices. 