Files
Munich-news/docs/LOCAL_DEVELOPMENT.md
2025-11-18 14:45:41 +01:00

4.1 KiB

Local Development Setup

This guide helps you run Munich News Daily locally for development and testing.

Quick Start

# 1. Copy local environment files
cp .env.local .env
cp backend/.env.local backend/.env

# 2. Start services with local configuration
docker-compose -f docker-compose.local.yml up -d

# 3. Check logs
docker-compose -f docker-compose.local.yml logs -f

# 4. Access services
# - Frontend: http://localhost:3000
# - Backend API: http://localhost:5001
# - MongoDB: localhost:27017
# - Ollama: http://localhost:11434

Differences from Production

Feature Production Local Development
Ollama Model gemma3:12b (large) phi3:latest (small, fast)
MongoDB Port Internal only Exposed on 27017
Ollama Port Internal only Exposed on 11434
Container Names munich-news-* munich-news-local-*
Volumes *_data *_data_local
Email Production SMTP Test/disabled

Useful Commands

Start/Stop Services

# Start all services
docker-compose -f docker-compose.local.yml up -d

# Stop all services
docker-compose -f docker-compose.local.yml down

# Restart a specific service
docker-compose -f docker-compose.local.yml restart backend

# View logs
docker-compose -f docker-compose.local.yml logs -f crawler

Testing

# Trigger a news crawl (2 articles for quick testing)
curl -X POST http://localhost:5001/api/admin/trigger-crawl \
  -H "Content-Type: application/json" \
  -d '{"max_articles": 2}'

# Trigger transport crawl
curl -X POST http://localhost:5001/api/transport/crawl

# Check articles in MongoDB
docker exec munich-news-local-mongodb mongosh munich_news \
  --eval "db.articles.find({}, {title: 1, keywords: 1, category: 1}).limit(3)"

# Check transport disruptions
curl http://localhost:5001/api/transport/disruptions

Database Access

# Connect to MongoDB
docker exec -it munich-news-local-mongodb mongosh munich_news

# Or from host (if you have mongosh installed)
mongosh "mongodb://admin:local123@localhost:27017/munich_news"

# Useful queries
db.articles.countDocuments()
db.articles.find({keywords: {$exists: true}}).limit(5)
db.subscribers.find()
db.transport_alerts.find()

Ollama Testing

# List models
curl http://localhost:11434/api/tags

# Test generation
curl http://localhost:11434/api/generate -d '{
  "model": "phi3:latest",
  "prompt": "Summarize: Munich opens new U-Bahn line",
  "stream": false
}'

Cleanup

# Stop and remove containers
docker-compose -f docker-compose.local.yml down

# Remove volumes (WARNING: deletes all data)
docker-compose -f docker-compose.local.yml down -v

# Remove local volumes specifically
docker volume rm munich-news_mongodb_data_local
docker volume rm munich-news_mongodb_config_local
docker volume rm munich-news_ollama_data_local

Switching Between Local and Production

# Switch to local
cp .env.local .env
cp backend/.env.local backend/.env
docker-compose -f docker-compose.local.yml up -d

# Switch to production
cp .env.production .env  # (if you have one)
cp backend/.env.production backend/.env
docker-compose up -d

Troubleshooting

Ollama model not downloading

# Pull model manually
docker exec munich-news-local-ollama ollama pull phi3:latest

MongoDB connection refused

# Check if MongoDB is running
docker-compose -f docker-compose.local.yml ps mongodb

# Check logs
docker-compose -f docker-compose.local.yml logs mongodb

Port already in use

# Check what's using the port
lsof -i :5001  # or :3000, :27017, etc.

# Stop the conflicting service or change port in docker-compose.local.yml

Tips

  1. Use phi3 for speed - It's much faster than gemma3 for local testing
  2. Limit articles - Use max_articles: 2 for quick crawl tests
  3. Watch logs - Keep logs open to see what's happening
  4. Separate volumes - Local and production use different volumes, so they don't interfere

Next Steps

  • See docs/PERSONALIZATION.md for personalization feature development
  • See docs/OLLAMA_SETUP.md for AI configuration
  • See main README.md for general documentation