> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xynehq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Devmode

> Running the application in development mode

If you want to run the Xyne application in dev mode, this guide will help you do so

Deployment of Xyne on Local Machine requires the following dependencies to be installed:

* [Bun](https://bun.sh/docs/installation)
* [Docker](https://docs.docker.com/engine/install/)
* [Docker Compose](https://docs.docker.com/compose/install/)
* [Vespa CLI](https://docs.vespa.ai/en/build-install-vespa.html)
* [ PostgreSQL](https://www.postgresql.org/download/)

***

## Set-Up Xyne Locally in Dev Mode

To Set-Up Xyne, follow the steps listed below :

### Clone the Xyne Repository :

Run the following command to clone the repository :

```javascript theme={null}
git clone https://github.com/xynehq/xyne.git
```

### Setup Environment variables:

The application is dependent on some environment variables that you will need to set up.

You will find a `.env.default` file with default values set in it. You have the option of replacing the necessary values in that file, with the provided values here.
Or you could rename it to `.env` or `.env.development` based on your preference, and then add the values.

<Warning> We suggest not having multiple .env files during development because it might interfere with the way bun loads the environment files. For better clarity on order of precedence of the environment files refer to the [Set up Environment Variables](https://bun.sh/guides/runtime/set-env) </Warning>

In the environment file, you can paste the following :

```javascript environment file theme={null}
ENCRYPTION_KEY=<YOUR_ENCRYPTION_KEY>
# If you wish to execute authorization using Service Account then use :
 SERVICE_ACCOUNT_ENCRYPTION_KEY=<YOUR_SERVICE_ACCOUNT_ENCRYPTION_KEY> 


GOOGLE_CLIENT_ID=<YOUR_GOOGLE_CLIENT_ID>
GOOGLE_CLIENT_SECRET=<YOUR_GOOGLE_CLIENT_SECRET>
GOOGLE_REDIRECT_URI=http://localhost:3000/v1/auth/callback

# Optional: Keycloak web login for local development
# Disable Google web login if you want to test Keycloak-only login locally
GOOGLE_WEB_LOGIN_ENABLED=false
KEYCLOAK_WEB_ENABLED=true
KEYCLOAK_PORT=8082
KEYCLOAK_PUBLIC_BASE_URL=http://localhost:8082
# In local dev the server runs on the host, not inside Docker,
# so the backchannel URL must also be localhost.
KEYCLOAK_INTERNAL_BASE_URL=http://localhost:8082
KEYCLOAK_REALM=xyne-shared
KEYCLOAK_CLIENT_ID=xyne-web
KEYCLOAK_CLIENT_SECRET=<YOUR_KEYCLOAK_CLIENT_SECRET>
KEYCLOAK_WORKSPACE_EXTERNAL_ID=xyne-shared-workspace
KEYCLOAK_LOGOUT_REDIRECT_URL=/auth
KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD=admin
XYNE_BOOTSTRAP_ADMIN_EMAIL=admin@xyne.local
XYNE_BOOTSTRAP_ADMIN_NAME="Xyne Admin"
XYNE_BOOTSTRAP_ADMIN_PASSWORD=<YOUR_BOOTSTRAP_ADMIN_PASSWORD>
XYNE_BOOTSTRAP_WORKSPACE_NAME="Xyne Shared"
XYNE_BOOTSTRAP_WORKSPACE_DOMAIN=xyne.local
KEYCLOAK_BOOTSTRAP_RESET_ADMIN_PASSWORD=false

HOST=http://localhost:3000
DATABASE_URL=postgresql://xyne:xyne@localhost:5432/xyne

JWT_SECRET=<YOUR_JWT_SECRET>

DATABASE_HOST=localhost
VESPA_HOST=localhost


## If using AWS Bedrock
AWS_ACCESS_KEY=<YOUR_AWS_ACCESS_KEY>
AWS_SECRET_KEY=<YOUR_AWS_ACCESS_SECRET>
AWS_REGION=<YOUR_AWS_REGION>
  
## OR [ If using Open AI ]
OPENAI_API_KEY=<YOUR_OPEN_API_KEY>

## OR [ If using Ollama ] 
OLLAMA_MODEL=<YOUR_OLLAMA_MODEL_NAME> 

## OR  [ If using Together AI ] 
TOGETHER_API_KEY=<YOUR_TOGETHER_API_KEY>
TOGETHER_MODEL=<YOUR_TOGETHER_MODEL>
TOGETHER_FAST_MODEL=<YOUR_TOGETHER_FAST_MODEL>

## OR  [ If using Fireworks AI ] 
FIREWORKS_API_KEY=<YOUR_FIREWORKS_API_KEY>
FIREWORKS_MODEL=<YOUR_FIREWORKS_MODEL>
FIREWORKS_FAST_MODEL=<YOUR_FIREWORKS_FAST_MODEL>

## OR [If using Google AI]
GEMINI_API_KEY=<YOUR_GEMINI_API_KEY> 
GEMINI_MODEL=<YOUR_GEMINI_MODEL_NAME>  

## If you are using custom OpenAI or Together AI endpoints
BASE_URL=<YOUR_BASE_URL>
```

### Set up Docker

Set up docker by running the follow command :

```javascript theme={null}
docker compose -f deployment/docker-compose.dev.yml up -d
```

Running this command will host PostgreSQL, Keycloak, Vespa, and the other local infrastructure containers inside Docker.
Keycloak Admin Console will be available at `http://localhost:8082/admin/`.

Bootstrap the Keycloak realm, client, default workspace, and local admin user:

```javascript theme={null}
cd server
bun run migrate
bun run keycloak:bootstrap
```

If you want to stop the local infrastructure, use:

```javascript theme={null}
docker compose -f deployment/docker-compose.dev.yml down
```

# Set permission to run the init-script

We first need to set the executable permission to run the init-script, for that, run the following command :

```javascript theme={null}
sudo chmod +x init-script.sh [ For Mac OS and Unix ]

OR 

icacls init-script.sh /grant Everyone:F [If using PowerShell in Windows]


```

### Run the init-script to initialize the application

Navigate to the server folder using `cd server` and run the following commands :

```javascript theme={null}
./init-script.sh
```

This will initialize all the dependencies required by the server to run the application successfully.

Once that is completed, inside the same `server` folder run the following command :

```javascript theme={null}
bun run dev
```

this will start the server, which will be listening on port `3000`

### Start the Xyne client

To start the client side, navigate to the `frontend` folder :

#### Client side .env

Create a new `.env ` in the `frontend` folder, use the following command :

```javascript theme={null}
touch .env
```

Now paste the following inside the `.env` file :

```javascript theme={null}
 VITE_API_BASE_URL=http://localhost:3000
 VITE_WS_BASE_URL=ws://localhost:3000
```

Save the file.

```javascript theme={null}
bun install
```

This installs all dependencies required by the client side to run.

Then start the client using the command :

```javascript theme={null}
bun run dev
```

The app will now be available in port `5173`.  [Go to xyne](http://localhost:5173/)

<Tip>In case of any required support, feel free to [Contact Us](mailto:founders@xynehq.com)</Tip>
​
