Local Development Setup¶
This guide helps you set up TruSpace for active development with hot reload capabilities.
Prerequisites¶
- Node.js 20+ (check with
node --version) - npm 10+ or pnpm
- Docker 20.10+
- Docker Compose 2.0+
- Git
Step 1: Clone and Configure¶
# Clone the repository
git clone git@github.com:openkfw/TruSpace.git
cd TruSpace
# Copy environment configuration
cp .env.example .env
Step 2: Start Infrastructure Services¶
Start only the backend services (IPFS, database, AI):
This starts:
- IPFS node and cluster
- Backend API server
- Ollama and Open Web UI (optional)
Step 3: Start Frontend in Dev Mode¶
In a new terminal:
The frontend will be available at http://localhost:3000 with hot reload.
Step 4: (Optional) Start Backend in Dev Mode¶
For backend development with hot reload:
Project Structure¶
TruSpace/
├── backend/ # Express.js API
│ ├── src/
│ │ ├── routes/ # API endpoints
│ │ ├── services/ # Business logic
│ │ ├── types/ # TypeScript interfaces
│ │ └── index.ts # Entry point
│ └── package.json
├── frontend/ # Next.js application
│ ├── src/
│ │ ├── app/ # App router pages
│ │ ├── components/ # React components
│ │ └── lib/ # Utilities
│ └── package.json
├── docker-compose.yml # Main compose file
├── .env.example # Environment template
└── start.sh # Startup script
Development Workflow¶
Running Tests¶
Linting and Formatting¶
Building for Production¶
Debug Configuration¶
VS Code¶
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Backend: Debug",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/backend",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"console": "integratedTerminal"
},
{
"name": "Frontend: Debug",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/frontend"
}
]
}
Environment Variables for Development¶
Create a .env.local in the frontend directory:
Common Issues¶
Port Conflicts¶
If ports are already in use: