# Self-hosted

Quill is designed to be self-hosted. Instead of having to set up
infrastructure, you simply install a dependency on your server and make
a single POST endpoint. This allows you to reuse your existing authentication
system and have full control over your data and security.

```mermaid self-hosted
flowchart LR
  subgraph yours["Your infrastructure"]
    app["Your app"] -- POST /quill --> server["Your server"]
    server --> db[("Your database")]
  end
  yours <-->|queries to run| quill["Quill API"]
```

```ts
import { Quill } from "@quillsql/node";

const quill = new Quill({
  privateKey: process.env.QUILL_PRIVATE_KEY,
  databaseConnectionString: process.env.POSTGRES_READ,
  databaseType: "postgresql",
});

app.post("/quill", authenticateJWT, async (req, res) => {
  const result = await quill.query({
    tenants: [{ tenantField: "organization_id", tenantIds: [req.user.orgId] }],
    metadata: req.body.metadata,
  });
  res.send(result);
});
```

[Server SDK docs](https://quill.co/docs/server/node.md)
