Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
890 changes: 890 additions & 0 deletions .cursor/plans/merchant_moltbook_refactor_4fe8076f.plan.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
.env
.env.local
.env.*.local
.local
uploads
.git
.cursor
docs
*.md
27 changes: 27 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,30 @@ BASE_URL=http://localhost:3000
# Twitter/X OAuth (for verification)
TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=

# Image Generation (single key or comma-separated pool for rate limit rotation)
IMAGE_PROVIDER=openai
IMAGE_API_KEY=
# IMAGE_API_KEYS=key1,key2,key3
IMAGE_MODEL=dall-e-3
IMAGE_SIZE=1024x1024
IMAGE_OUTPUT_DIR=./uploads
IMAGE_BASE_URL=https://proxy.shopify.ai/v1

# LLM Text Inference (single key or comma-separated pool for rate limit rotation)
LLM_PROVIDER=openai
LLM_API_KEY=
# LLM_API_KEYS=key1,key2,key3
LLM_MODEL=gpt-4o
LLM_BASE_URL=https://proxy.shopify.ai/v1
TICK_MS=5000
RUN_SEED=42

# Operator Control
OPERATOR_KEY=change-this-in-production

# Anti-trivial Gating
MIN_QUESTION_LEN=20
MIN_OFFER_PRICE_CENTS=1
MIN_OFFER_MESSAGE_LEN=10
MIN_LOOKING_FOR_CONSTRAINTS=2
79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: E2E Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: moltbook
POSTGRES_PASSWORD: moltbook
POSTGRES_DB: moltbook
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

env:
DATABASE_URL: postgresql://moltbook:moltbook@localhost:5432/moltbook
NODE_ENV: development
PORT: 3000
OPERATOR_KEY: ci-operator-key
BASE_URL: http://localhost:3000
JWT_SECRET: ci-jwt-secret

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Apply base schema
run: |
PGPASSWORD=moltbook psql -h localhost -U moltbook -d moltbook -f scripts/schema.sql

- name: Run migrations
run: npm run db:migrate

- name: Start API server
run: |
npm start &
echo "Waiting for API to be ready..."
for i in $(seq 1 15); do
if curl -s http://localhost:3000/api/v1/health | grep -q '"success":true'; then
echo "API is ready!"
break
fi
echo " attempt $i..."
sleep 2
done

- name: Seed demo data
run: node scripts/seed.js

- name: Run smoke test
run: node scripts/smoke-test.js

- name: Run full E2E test suite
run: node scripts/full-test.js

- name: Run concurrency tests
run: node scripts/concurrency-test.js
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ dist/
build/
coverage/
*.tgz
uploads/
.local/
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:20-alpine

WORKDIR /app

# Copy package files and install deps
COPY package.json package-lock.json ./
RUN npm ci --production

# Copy source
COPY . .

# Create uploads directory
RUN mkdir -p uploads

# Expose port
EXPOSE 3000

# Default command: apply schema + migrations + start API
CMD ["node", "scripts/start-production.js"]
13 changes: 13 additions & 0 deletions Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-alpine

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci --production

COPY . .

RUN mkdir -p uploads

# Run the worker process (not the API server)
CMD ["node", "scripts/run-worker.js"]
Loading