Skip to content

Commit eb0b1fe

Browse files
committed
Refactor setup instructions and update dependencies for improved local development
1 parent ae0fde9 commit eb0b1fe

5 files changed

Lines changed: 101 additions & 37 deletions

File tree

SETUP.md

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Before we start, you will need:
1616
1. **An Instagram Business or Creator Account**: Personal accounts do not support the API. You can switch for free in Instagram's settings under **Settings****Account type**.
1717
2. **A Facebook Account**: Meta's developer platform requires a Facebook account.
1818
3. **A Resend Account**: Go to [Resend.com](https://resend.com) to create a free account. This is required to send login emails (magic links).
19-
4. **Docker Desktop** (For local setup only): Download and install it from [Docker's website](https://www.docker.com/products/docker-desktop/).
19+
4. **PostgreSQL & Redis** (one of): Docker Desktop, a local install, or a free cloud account (Neon/Supabase + Upstash). Docker is **optional** — see Step 2.
2020
5. **Node.js** (v18 or higher) installed on your machine.
2121

2222
---
@@ -60,13 +60,70 @@ openssl rand -hex 16
6060
Open the `.env` file in your text editor and fill in the values generated in Step 1.
6161

6262
3. **Start PostgreSQL & Redis (Datastores)**:
63-
Make sure Docker Desktop is running, then run:
63+
64+
Docker is not required. Pick **one** option per datastore — either run Postgres/Redis **locally**, or use a **free cloud** service.
65+
66+
### Option A — Local install (no Docker)
67+
68+
Install PostgreSQL and Redis directly on your machine:
69+
70+
- **macOS**: `brew install postgresql@16 redis`
71+
- **Ubuntu/Debian**: `sudo apt install postgresql redis-server`
72+
- **Windows**: Installers from [postgresql.org](https://www.postgresql.org/download/) and [redis.io](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/).
73+
74+
Then start them:
6475

6576
```bash
66-
docker-compose up -d
77+
# Postgres (macOS via brew)
78+
brew services start postgresql@16
79+
# Postgres (Debian/Ubuntu)
80+
sudo systemctl start postgresql
81+
82+
# Redis (either platform)
83+
redis-server --daemonize yes
84+
```
85+
86+
Create the database and a user matching `.env.example`:
87+
88+
```bash
89+
createdb openinstadm
90+
psql -c "ALTER USER postgres PASSWORD 'postgres';"
6791
```
6892

69-
This downloads and starts PostgreSQL (database) and Redis (queue manager) in the background.
93+
Your `.env` stays as shipped:
94+
95+
```env
96+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/openinstadm
97+
REDIS_URL=redis://localhost:6379
98+
```
99+
100+
> On Debian/Ubuntu the default Postgres user is `postgres`, but `pg_isready`/`psql` need `sudo -u postgres`. If the password fails, run `sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"`.
101+
102+
### Option B — Free cloud Postgres + Redis (no local setup, no Docker)
103+
104+
The free tiers below are plenty for local development:
105+
106+
| Service | What it gives you | Free tier |
107+
| ------- | ----------------- | --------- |
108+
| [Neon](https://neon.tech) | Serverless Postgres | 0.5 GB storage, branch-based DB |
109+
| [Supabase](https://supabase.com) | Postgres + connection pooling | 500 MB, always free |
110+
| [Aiven](https://aiven.io) | Postgres or Redis | Small free nodes per service |
111+
| [Upstash](https://upstash.com) | Redis (serverless) | 10k commands/day, always free |
112+
113+
1. Sign up, create an instance, and copy the connection string for each.
114+
- **Neon/Supabase**: gives a `postgresql://...` URL → paste into `DATABASE_URL`.
115+
- **Upstash/Aiven Redis**: gives a `rediss://...` URL → paste into `REDIS_URL`.
116+
117+
2. Update `.env`:
118+
119+
```env
120+
DATABASE_URL=postgresql://user:password@your-neon-host/dbname?sslmode=require
121+
REDIS_URL=rediss://user:password@your-upstash-host:6379
122+
```
123+
124+
> **Tip**: Prefer the pooler/connection-URL, not the direct one, on Supabase/Neon — Prisma handles pooled connections much better. Make sure the `sslmode=require` (or `?ssl=true` for Supabase) param is present, or Prisma will refuse to connect.
125+
126+
Docker alternative (if you ever want it): `docker-compose.yml` in the project root provides the exact same Postgres (port `5432`) and Redis (port `6379`) for consistent local dev. See the "To reset everything" snippet below.
70127

71128
4. **Initialize the Database**:
72129
Run the following commands to create the tables in your database:
@@ -75,6 +132,24 @@ openssl rand -hex 16
75132
npm run db:migrate
76133
```
77134

135+
- `db:generate` generates the Prisma client from `prisma/schema.prisma`.
136+
- `db:migrate` applies the migration files in `prisma/migrations/` to the database (the `openinstadm` database created by the container).
137+
138+
**To reset everything later** (stop containers, delete all DB/queue data, start fresh):
139+
140+
```bash
141+
docker-compose down -v
142+
docker-compose up -d
143+
npm run db:generate && npm run db:migrate
144+
```
145+
146+
No Docker? Reset your local Postgres/Redis by dropping the database and re-creating it:
147+
148+
```bash
149+
dropdb openinstadm && createdb openinstadm
150+
npm run db:generate && npm run db:migrate
151+
```
152+
78153
---
79154

80155
## 🌐 Step 3: Setting Up a Public Tunnel

app/layout.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Metadata } from "next";
2-
import { Analytics } from "@vercel/analytics/next";
32
import "./globals.css";
3+
import { Inter_Tight } from "next/font/google";
44

55
export const metadata: Metadata = {
66
title: "OpenInstaDM - Open source Instagram comment-to-DM automation",
@@ -15,16 +15,22 @@ export const metadata: Metadata = {
1515
],
1616
};
1717

18+
const inter = Inter_Tight({ subsets: ["latin"], variable: "--font-sans" });
19+
1820
export default function RootLayout({
1921
children,
2022
}: Readonly<{
2123
children: React.ReactNode;
2224
}>) {
2325
return (
2426
<html lang="en" className="h-full dark">
25-
<body className="min-h-full bg-background text-foreground font-sans antialiased">
27+
<body
28+
className={
29+
"min-h-full bg-background text-foreground font-sans antialiased " +
30+
inter.className
31+
}
32+
>
2633
{children}
27-
<Analytics />
2834
</body>
2935
</html>
3036
);

bun.lock

Lines changed: 9 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"@auth/prisma-adapter": "^2.11.3",
1919
"@prisma/adapter-pg": "^7.9.1",
2020
"@prisma/client": "^7.9.1",
21-
"@vercel/analytics": "^2.0.1",
2221
"bullmq": "^5.81.3",
2322
"ioredis": "^5.11.1",
2423
"next": "^16.3.0",
@@ -36,6 +35,7 @@
3635
"@types/react": "^19.2.18",
3736
"@types/react-dom": "^19.2.4",
3837
"babel-plugin-react-compiler": "1.0.0",
38+
"dotenv": "^17.4.2",
3939
"eslint": "^9.39.5",
4040
"eslint-config-next": "^16.3.0",
4141
"prisma": "^7.9.1",

worker/dm-worker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { config as loadEnv } from "dotenv";
2+
loadEnv();
3+
14
import { createDMWorker } from "@/lib/queue/dm-worker";
25
import { recordWorkerHeartbeat } from "@/lib/ops/worker-health";
36
import { reconcileComments } from "@/lib/polling/comment-reconciler";

0 commit comments

Comments
 (0)