From 3f5fa981c6dc90b10acea5440a9e7a3f6722f24b Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 15 May 2026 15:00:55 +0000 Subject: [PATCH] Create wiki page 'Development Setup' --- Development-Setup.md | 113 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Development-Setup.md diff --git a/Development-Setup.md b/Development-Setup.md new file mode 100644 index 0000000..961c92b --- /dev/null +++ b/Development-Setup.md @@ -0,0 +1,113 @@ +# Development Setup + +## Prerequisites + +| Tool | Purpose | +|---|---| +| Rust (stable) | Backend | +| Node.js + Bun | Frontend | +| PostgreSQL | Database | +| 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 backend (tokio runtime) +cargo run -p thoughts-backend +``` + +The backend starts on `http://localhost:3001` by default. + +### Environment Variables (`thoughts-backend/.env.example`) + +``` +DATABASE_URL=postgres://user:pass@localhost:5432/thoughts +JWT_SECRET=your-secret-here +``` + +### Running Tests + +```bash +cd thoughts-backend + +# All tests (requires running PostgreSQL) +cargo test + +# API integration tests only +cargo test -p thoughts-backend --test api +``` + +Tests spin up a test database; set `TEST_DATABASE_URL` in `.env` if it differs from `DATABASE_URL`. + +--- + +## Frontend + +```bash +cd thoughts-frontend + +# Copy and fill in env +cp .env.example .env.local + +# Install dependencies +bun install + +# Start dev server +bun dev +``` + +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 +``` + +--- + +## Running Everything with Docker Compose + +For a fully isolated local environment: + +```bash +# Start all services (backend, frontend, postgres, nginx) +docker compose up + +# Or just the database and let services run natively +docker compose up database +``` + +The `compose.yml` at the repo root defines all services for local development. + +--- + +## Project Structure + +``` +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 +```