backend-development.md

 1[⬅ Back to Index](./index.md)
 2
 3# Developing Zed's Backend
 4
 5Zed's backend consists of the following components:
 6
 7- The Zed.dev web site
 8  - implemented in the [`zed.dev`](https://github.com/zed-industries/zed.dev) repository
 9  - hosted on [Vercel](https://vercel.com/zed-industries/zed-dev).
10- The Zed Collaboration server
11  - implemented in the [`crates/collab`](https://github.com/zed-industries/zed/tree/main/crates/collab) directory of the main `zed` repository
12  - hosted on [DigitalOcean](https://cloud.digitalocean.com/projects/6c680a82-9d3b-4f1a-91e5-63a6ca4a8611), using Kubernetes
13- The Zed Postgres database
14  - defined via migrations in the [`crates/collab/migrations`](https://github.com/zed-industries/zed/tree/main/crates/collab/migrations) directory
15  - hosted on DigitalOcean
16
17---
18
19## Local Development
20
21Here's some things you need to develop backend code locally.
22
23### Dependencies
24
25- **Postgres** - download [Postgres.app](https://postgresapp.com).
26
27### Setup
28
291. Check out the `zed` and `zed.dev` repositories into a common parent directory
302. Set the `GITHUB_TOKEN` environment variable to one of your GitHub personal access tokens (PATs).
31
32   - You can create a PAT [here](https://github.com/settings/tokens).
33   - You may want to add something like this to your `~/.zshrc`:
34
35     ```
36     export GITHUB_TOKEN=<the personal access token>
37     ```
38
393. In the `zed.dev` directory, run `npm install` to install dependencies.
404. In the `zed directory`, run `script/bootstrap` to set up the database
415. In the `zed directory`, run `foreman start` to start both servers
42
43---
44
45## Production Debugging
46
47### Datadog
48
49Zed uses Datadog to collect metrics and logs from backend services. The Zed organization lives within Datadog's _US5_ [site](https://docs.datadoghq.com/getting_started/site/), so it can be accessed at [us5.datadoghq.com](https://us5.datadoghq.com). Useful things to look at in Datadog:
50
51- The [Logs](https://us5.datadoghq.com/logs) page shows logs from Zed.dev and the Collab server, and the internals of Zed's Kubernetes cluster.
52- The [collab metrics dashboard](https://us5.datadoghq.com/dashboard/y2d-gxz-h4h/collab?from_ts=1660517946462&to_ts=1660604346462&live=true) shows metrics about the running collab server