Update wiki page 'Development-Setup'

2026-05-15 15:05:20 +00:00
parent 50e7260816
commit ef3fae91bf

@@ -2,50 +2,52 @@
## Prerequisites
| Tool | Purpose |
|---|---|
| Rust (stable) | Backend |
| Node.js + Bun | Frontend |
| PostgreSQL | Database |
| Docker + Docker Compose | Optional: run deps in containers |
| Tool | Version | Purpose |
|---|---|---|
| Rust | stable 1.80+ | Backend |
| Node.js + Bun | latest | Frontend |
| PostgreSQL | 15+ | Database |
| NATS | optional | Event transport (federation + notifications) |
| Docker + Docker Compose | optional | Run deps in containers |
## Backend
```bash
cd thoughts-backend
# Copy and fill in env
cp .env.example .env
# Run migrations
cargo run -p migration
# Start the API server (runs migrations automatically on startup)
cargo run -p bootstrap
# Start the backend (tokio runtime)
cargo run -p thoughts-backend
# In a second terminal: start the event worker (optional)
cargo run -p worker
```
The backend starts on `http://localhost:3001` by default.
The API server starts on `http://localhost:8000`.
Both processes read from the same `.env` file.
### Environment Variables (`thoughts-backend/.env.example`)
### Environment Variables (`.env.example`)
```env
DATABASE_URL=postgres://postgres:password@localhost:5432/thoughts
JWT_SECRET=change-me
BASE_URL=http://localhost:8000
NATS_URL=nats://localhost:4222 # optional
```
DATABASE_URL=postgres://user:pass@localhost:5432/thoughts
JWT_SECRET=your-secret-here
```
`BASE_URL` is used to construct ActivityPub actor URLs and AP object IDs — must be the publicly reachable URL in production.
### Running Tests
```bash
cd thoughts-backend
# Unit tests — no database required
cargo test -p application
# All tests (requires running PostgreSQL)
cargo test
# API integration tests only
cargo test -p thoughts-backend --test api
# Full workspace (requires DATABASE_URL pointing to a running PostgreSQL)
cargo test --workspace
```
Tests spin up a test database; set `TEST_DATABASE_URL` in `.env` if it differs from `DATABASE_URL`.
The `application` crate uses in-memory fakes from `domain`'s `test-helpers` feature for fast, isolated unit tests of all business logic.
---
@@ -54,39 +56,36 @@ Tests spin up a test database; set `TEST_DATABASE_URL` in `.env` if it differs f
```bash
cd thoughts-frontend
# Copy and fill in env
cp .env.example .env.local
# Install dependencies
bun install
# Start dev server
bun dev
bun run dev # http://localhost:3000
```
The frontend starts on `http://localhost:3000` and proxies `/api/*` to the backend.
### Environment Variables (`thoughts-frontend/.env.example`)
```
NEXT_PUBLIC_API_URL=http://localhost:3001
```env
NEXT_PUBLIC_API_URL=http://localhost:8000 # client-side requests
NEXT_PUBLIC_SERVER_SIDE_API_URL=http://localhost:8000 # SSR requests
```
---
## Running Everything with Docker Compose
For a fully isolated local environment:
```bash
# Start all services (backend, frontend, postgres, nginx)
# Start all services (api, worker, frontend, postgres, nats, nginx)
docker compose up
# Or just the database and let services run natively
# Or just the database
docker compose up database
# Or database + NATS only
docker compose up database nats
```
The `compose.yml` at the repo root defines all services for local development.
`compose.yml` at the repo root defines all services for local development.
---
@@ -94,20 +93,32 @@ The `compose.yml` at the repo root defines all services for local development.
```
thoughts/
├── compose.yml # Dev Docker Compose
├── compose.prod.yml # Production Docker Compose
├── nginx/ # Nginx config
├── thoughts-backend/ # Rust backend (workspace)
│ ├── api/ # HTTP layer
│ ├── app/ # Business logic
│ ├── models/ # Domain types
│ ├── common/ # Shared utilities
│ ├── doc/ # OpenAPI generation
│ ├── migration/ # DB migrations
── utils/ # Test helpers
└── thoughts-frontend/ # Next.js frontend
├── app/ # App Router pages
── components/ # React components
├── hooks/ # Custom hooks
└── lib/ # API client, utils
├── Cargo.toml # Workspace root
├── .env.example # Backend env template
├── compose.yml # Dev Docker Compose
├── compose.prod.yml # Production Docker Compose
├── Dockerfile # Multi-stage build (api + worker binaries)
├── nginx/
├── crates/
│ ├── domain/ # Pure domain types & port traits
│ ├── application/ # Use cases (business logic)
│ ├── api-types/ # REST request/response DTOs
── presentation/ # Axum HTTP router, OpenAPI
│ ├── bootstrap/ # API server binary
├── worker/ # Event worker binary
── adapters/
│ ├── auth/
│ ├── postgres/ # SQL repos + migrations/
│ ├── postgres-search/
│ ├── postgres-federation/
│ ├── activitypub-base/
│ ├── activitypub/
│ ├── nats/
│ ├── event-payload/
│ └── event-transport/
└── thoughts-frontend/ # Next.js frontend
├── app/ # App Router pages
├── components/ # React components (incl. federation/)
├── hooks/
└── lib/ # API client, utils
```