Quick Start
Get the TerraGuard platform running on your local machine in minutes. Covers prerequisites, setup, and verification for all six services.
Prerequisites
Before you begin, ensure the following tools are installed on your machine:
| Tool | Minimum Version | Purpose |
|---|---|---|
| Docker & Docker Compose | 24.x | Infrastructure services (Redis, Inngest) |
| PostgreSQL | 15+ | Primary database (with PostGIS and pgVector extensions) |
| Go | 1.22+ | Event Processor, Web Crawler API server |
| Python | 3.11+ | Backend API, Crawler Python worker |
| Poetry | 1.7+ | Python dependency management |
| Node.js | 20+ | Frontend (Next.js) |
| Rust | 1.75+ | GeoPop API (only if building from source) |
You will also need API keys for:
- OpenAI — GPT-4 for AI agents and embeddings
- Clerk — Authentication (create a free dev instance at clerk.com)
- Serper.dev — Primary web/news search provider (
SERPER_API_KEY) - Brave Search (optional) — Fallback search provider, used only when Serper errors (
BRAVE_API_KEY)
Clone and Setup
Clone the monorepo and run the automated setup:
git clone https://github.com/TerraGuard/terraguard.git
cd terraguard
make setupThe make setup command will:
- Copy
.env.exampleto.envfor each service (if.envdoes not already exist) - Install Python dependencies via Poetry for the backend API
- Install Node.js dependencies for the frontend
- Download Go module dependencies for the Go services
- Pull required Docker images
After setup completes, edit the .env files in each service directory to add your API keys and configure database connection strings.
Configure the Database
TerraGuard requires PostgreSQL with the PostGIS and pgVector extensions. If you are running PostgreSQL locally:
# Create the database
createdb terraguard
# Enable required extensions (connect to the database first)
psql -d terraguard -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql -d terraguard -c "CREATE EXTENSION IF NOT EXISTS vector;"Then update the DATABASE_URL in tg-backend-api/.env:
DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/terraguardRun the database migrations:
cd tg-backend-api
poetry run alembic upgrade headStart All Services
From the repository root:
make devThis starts all services plus infrastructure dependencies. Alternatively, you can start services individually:
# Infrastructure (Redis, Inngest)
cd tg-backend-api/local-services && make up
# Backend API (includes the search layer — Serper + Brave)
cd tg-backend-api && make server
# Event Processor
cd tg-event-processor && make run
# Web Crawler
cd tg-web-crawler-api && make docker-up
# Frontend
cd tg-frontend && npm run dev
# GeoPop API
cd geopop-api && cargo run --releaseThere is no separate search service to start. Web and news search run inside the Backend
API as the app/common/search_providers.py module and require only the SERPER_API_KEY
and BRAVE_API_KEY environment variables in tg-backend-api/.env.
Port Reference
Once everything is running, the services are available at:
| Port | Service | URL |
|---|---|---|
| 4000 | Backend API | http://localhost:4000/api/v1 |
| 5605 | GeoPop API | http://localhost:5605 |
| 4010 | Event Processor | http://localhost:4010 |
| 4020 | Web Crawler API | http://localhost:4020 |
| 4025 | Frontend | http://localhost:4025 |
The search layer is part of the Backend API and has no dedicated port.
Verify Services
Check that all services are healthy:
# Backend API
curl http://localhost:4000/api/v1/health
# Event Processor
curl http://localhost:4010/health
# Web Crawler API
curl http://localhost:4020/v1/health
# GeoPop API
curl http://localhost:5605/health
# Frontend (should return HTML)
curl -s http://localhost:4025 | head -5All health endpoints should return a 200 status with a JSON response.
Trigger a Test Ingestion
To verify the full pipeline, trigger the event processor to fetch recent events:
# Trigger GDACS ingestion
curl -X POST http://localhost:4010/v1/ingest/gdacs
# Trigger USGS ingestion
curl -X POST http://localhost:4010/v1/ingest/usgsAfter a few seconds, events should appear in the database and be visible on the frontend at http://localhost:4025.
Inngest Dashboard
The Inngest dev server provides a dashboard for monitoring background jobs:
# Usually available at
open http://localhost:8288Use this to monitor the enrichment pipeline — you should see functions triggered for web search, content crawling, and vector indexing as new events are processed.
Common Issues
PostgreSQL extensions not found
If you see errors about missing postgis or vector extensions, install them:
# macOS with Homebrew
brew install postgis
brew install pgvector
# Ubuntu/Debian
sudo apt install postgresql-15-postgis-3
sudo apt install postgresql-15-pgvectorSearch returns no results
Web and news search run inside the Backend API and call Serper.dev (primary) with Brave
Search as an error fallback — there is no local search container to start. If searches
return nothing, confirm the API keys are set in tg-backend-api/.env:
SERPER_API_KEY=... # primary provider
BRAVE_API_KEY=... # fallback, used only when Serper errorsIf SERPER_API_KEY is unset, every search falls straight through to Brave; if both are
unset, search returns an empty result set with a logged error.
Clerk authentication errors
For local development, create a Clerk development instance and add the keys to tg-backend-api/.env and tg-frontend/.env:
# Backend
CLERK_SECRET_KEY=sk_test_...
# Frontend
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...Next Steps
- Architecture Overview — Understand the system design
- Dashboard Guide — Learn the main interface
- Local Development (Detailed) — Advanced local setup options
Architecture Overview
High-level architecture of the TerraGuard platform, covering all six services, their responsibilities, and how data flows from disaster sources to end users.
Dashboard & Event Map
The main TerraGuard dashboard provides a real-time map of disaster events worldwide, with filtering, severity indicators, and quick access to event details.