# Quickstart

## Cloud

### 1. Log in

[quill.co/sign-in](https://quill.co/sign-in)

![Sign in to Quill, with Google or an email address](https://quill.co/bi-tool/sign-in.webp "quill.co/sign-in")

### 2. Connect an environment

![Connect database, with the PostgreSQL credentials of the environment's database](https://quill.co/bi-tool/connect-database.webp "quill.co/dashboards")

#### IPs to whitelist

Make sure these IPs are allowed to access your database.

```
18.218.111.39/32
3.131.177.71/32
18.217.193.46/32
```

### 3. Create a tenant

![Create tenant: an Organization tenant, row level, with public.organizations as the tenant table and organization_id as the foreign key](https://quill.co/bi-tool/create-tenant.webp "quill.co/dashboards")

### 4. Create a virtual table

![New virtual table: SELECT organization_id, id, amount, created_at FROM public.orders, run, with its 90 rows](https://quill.co/bi-tool/virtual-table-query.webp "quill.co/virtual-tables")

![Add Virtual Table: the query named orders, owned by the Organization tenant](https://quill.co/bi-tool/virtual-table-name.webp "quill.co/virtual-tables")

### 5. Create a dashboard

![New dashboard, named Sales](https://quill.co/bi-tool/new-dashboard.webp "quill.co/dashboards")

![Report builder: Revenue, a line chart of the sum of amount from orders, grouped by created_at](https://quill.co/bi-tool/report-builder.webp "quill.co/report-builder?destinationDashboardName=Sales")

![The Sales dashboard, with the saved Revenue line chart](https://quill.co/bi-tool/dashboard-report.webp "quill.co/dashboards")

## Self-hosted

### 1. Install @quillsql/admin

```sh
npm install @quillsql/admin
```

### 2. Add an endpoint

```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,
    adminEnabled: isAdmin(req.user),
  });
  res.send(result);
});
```

```tsx
import { AdminProvider, DashboardManager } from "@quillsql/admin";

function Admin() {
  return (
    <AdminProvider publicKey={process.env.QUILL_PUBLIC_KEY} queryEndpoint="https://yourserver.com/quill">
      <DashboardManager />
    </AdminProvider>
  );
}
```

### 3. Create a tenant

![Create tenant: an Organization tenant, row level, with public.organizations as the tenant table and organization_id as the foreign key](https://quill.co/bi-tool/create-tenant.webp "yourapp.com/admin")

### 4. Create a virtual table

![New virtual table: SELECT organization_id, id, amount, created_at FROM public.orders, run, with its 90 rows](https://quill.co/bi-tool/virtual-table-query.webp "yourapp.com/admin")

![Add Virtual Table: the query named orders, owned by the Organization tenant](https://quill.co/bi-tool/virtual-table-name.webp "yourapp.com/admin")

### 5. Create a dashboard

![New dashboard, named Sales](https://quill.co/bi-tool/new-dashboard.webp "yourapp.com/admin")

![Report builder: Revenue, a line chart of the sum of amount from orders, grouped by created_at](https://quill.co/bi-tool/report-builder.webp "yourapp.com/admin")

![The Sales dashboard, with the saved Revenue line chart](https://quill.co/bi-tool/dashboard-report.webp "yourapp.com/admin")
