Migrate stack to SQLite and set Coolify defaults
This commit is contained in:
61
README.md
61
README.md
@@ -9,30 +9,25 @@ Turbopack-first rebuild of a fiscal.ai-style terminal with OpenClaw integration.
|
||||
- Elysia route layer mounted in Next Route Handlers
|
||||
- Turbopack for `dev` and `build`
|
||||
- Better Auth (email/password + magic link)
|
||||
- Drizzle ORM (PostgreSQL) + Better Auth Drizzle adapter
|
||||
- Drizzle ORM (SQLite) + Better Auth Drizzle adapter
|
||||
- Internal API routes via Elysia app module (`lib/server/api/app.ts`)
|
||||
- Eden Treaty for type-safe frontend API calls
|
||||
- Workflow DevKit + Postgres World for durable background task execution
|
||||
- PostgreSQL-backed domain storage (watchlist, holdings, filings, tasks, insights)
|
||||
- Workflow DevKit Local World for background task execution
|
||||
- SQLite-backed domain storage (watchlist, holdings, filings, tasks, insights)
|
||||
- OpenClaw/ZeroClaw analysis via OpenAI-compatible chat endpoint
|
||||
|
||||
## Run locally
|
||||
|
||||
```bash
|
||||
bun install
|
||||
bun run db:generate
|
||||
bun run db:migrate
|
||||
bun run dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000).
|
||||
|
||||
Better Auth requires PostgreSQL. Set `DATABASE_URL`, `BETTER_AUTH_SECRET`, and `BETTER_AUTH_BASE_URL` in `.env.local`.
|
||||
Generate/apply schema migrations and set up the workflow world tables before starting the app:
|
||||
|
||||
```bash
|
||||
bun run db:generate
|
||||
bun run db:migrate
|
||||
bun run workflow:setup
|
||||
```
|
||||
The default database path is `data/fiscal.sqlite` via `DATABASE_URL=file:data/fiscal.sqlite`.
|
||||
|
||||
## Production build
|
||||
|
||||
@@ -50,12 +45,32 @@ docker compose up --build -d
|
||||
```
|
||||
|
||||
For local Docker, host port mapping comes from `docker-compose.override.yml` (default `http://localhost:3000`, configurable via `APP_PORT`).
|
||||
The base Docker Compose now includes an internal PostgreSQL service (`postgres`) used by Better Auth by default.
|
||||
On container startup, the app now applies Drizzle migrations automatically before launching Next.js.
|
||||
For Coolify/remote Docker Compose, only app container port `3000` is exposed internally (no fixed host port bind), avoiding host port collisions.
|
||||
If you use an external Postgres instance, set `DATABASE_URL` explicitly.
|
||||
On container startup, the app applies Drizzle migrations automatically before launching Next.js.
|
||||
The app stores SQLite data in Docker volume `fiscal_sqlite_data` (mounted to `/app/data`) and workflow local data in `fiscal_workflow_data` (mounted to `/app/.workflow-data`).
|
||||
|
||||
Workflow Local World uses filesystem state plus an in-memory queue. On container restart, queued in-flight jobs may be lost.
|
||||
|
||||
Docker images use Bun (`oven/bun:1.3.5-alpine`) for build and runtime.
|
||||
|
||||
## Coolify deployment
|
||||
|
||||
This compose setup is compatible with Coolify as-is (it uses named Docker volumes, not host bind mounts).
|
||||
|
||||
Required environment variables in Coolify:
|
||||
|
||||
- `DATABASE_URL=file:/app/data/fiscal.sqlite`
|
||||
- `BETTER_AUTH_SECRET=<long-random-secret>`
|
||||
- `BETTER_AUTH_BASE_URL=https://fiscal.b11studio.xyz`
|
||||
- `BETTER_AUTH_TRUSTED_ORIGINS=https://fiscal.b11studio.xyz`
|
||||
- `WORKFLOW_TARGET_WORLD=local`
|
||||
- Optional: `WORKFLOW_LOCAL_DATA_DIR=/app/.workflow-data`
|
||||
|
||||
Operational constraints for Coolify:
|
||||
|
||||
- Keep this service to a single instance/replica. SQLite is file-based and not appropriate for multi-replica shared-write deployments.
|
||||
- Ensure the two named volumes are persisted (`fiscal_sqlite_data`, `fiscal_workflow_data`).
|
||||
- Workflow Local queueing is in-memory; in-flight queued jobs may be lost on restarts.
|
||||
|
||||
## Environment
|
||||
|
||||
Use root `.env` or root `.env.local`:
|
||||
@@ -63,23 +78,19 @@ Use root `.env` or root `.env.local`:
|
||||
```env
|
||||
# leave blank for same-origin API
|
||||
NEXT_PUBLIC_API_URL=
|
||||
DATABASE_URL=postgres://postgres:postgres@localhost:5432/fiscal_clone
|
||||
POSTGRES_DB=fiscal_clone
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
DATABASE_URL=file:data/fiscal.sqlite
|
||||
BETTER_AUTH_SECRET=replace-with-a-long-random-secret
|
||||
BETTER_AUTH_BASE_URL=http://localhost:3000
|
||||
BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000
|
||||
BETTER_AUTH_BASE_URL=https://fiscal.b11studio.xyz
|
||||
BETTER_AUTH_TRUSTED_ORIGINS=https://fiscal.b11studio.xyz
|
||||
|
||||
OPENCLAW_BASE_URL=http://localhost:4000
|
||||
OPENCLAW_API_KEY=your_key
|
||||
OPENCLAW_MODEL=zeroclaw
|
||||
SEC_USER_AGENT=Fiscal Clone <support@fiscal.local>
|
||||
|
||||
WORKFLOW_TARGET_WORLD=@workflow/world-postgres
|
||||
WORKFLOW_POSTGRES_URL=postgres://postgres:postgres@localhost:5432/fiscal_clone
|
||||
WORKFLOW_POSTGRES_JOB_PREFIX=fiscal_clone
|
||||
WORKFLOW_POSTGRES_WORKER_CONCURRENCY=10
|
||||
WORKFLOW_TARGET_WORLD=local
|
||||
WORKFLOW_LOCAL_DATA_DIR=.workflow-data
|
||||
WORKFLOW_LOCAL_QUEUE_CONCURRENCY=100
|
||||
```
|
||||
|
||||
If OpenClaw is unset, the app uses local fallback analysis so task workflows still run.
|
||||
|
||||
Reference in New Issue
Block a user