Create wiki page 'Development Setup'
113
Development-Setup.md
Normal file
113
Development-Setup.md
Normal file
@@ -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
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user