mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools
Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
* GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
* GET /api/v1/users/me/organizations - User organizations
* POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue
API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules
Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
199 lines
7.0 KiB
Makefile
199 lines
7.0 KiB
Makefile
# Turash Backend Development Makefile
|
||
|
||
.PHONY: help dev dev-build dev-up dev-down dev-logs dev-clean dev-test build test lint clean deps down stop
|
||
|
||
# Default target
|
||
help: ## Show this help message
|
||
@echo "Turash Backend Development Commands:"
|
||
@echo ""
|
||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||
|
||
# Development environment
|
||
dev: ## Start development environment with hot reload
|
||
@echo "🚀 Starting Turash Backend Development Environment"
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml up -d
|
||
@echo "⏳ Waiting for services to be ready..."
|
||
@sleep 10
|
||
@echo "🎉 Development environment is ready!"
|
||
@echo ""
|
||
@echo "Services:"
|
||
@echo " - Neo4j: http://localhost:7474 (neo4j/test123456)"
|
||
@echo " - PostgreSQL: localhost:5432 (turash/turash123)"
|
||
@echo " - Redis: localhost:6379 (password: turash123)"
|
||
@echo " - NATS: localhost:4222, monitoring: http://localhost:8222"
|
||
@echo " - Backend API: http://localhost:8080"
|
||
@echo ""
|
||
@echo "Useful commands:"
|
||
@echo " make dev-logs # Follow all logs"
|
||
@echo " make dev-down # Stop all services"
|
||
@echo " make stop # Stop all services and clean up ports"
|
||
@echo " make dev-clean # Stop and remove volumes"
|
||
|
||
dev-build: ## Build development environment
|
||
@echo "🏗️ Building development environment..."
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml build --no-cache
|
||
|
||
dev-up: ## Start development services
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml up -d
|
||
|
||
dev-down: ## Stop development services
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml down
|
||
|
||
down: stop ## Alias for stop
|
||
stop: ## Stop all services and clean up ports
|
||
@echo "🛑 Stopping development services..."
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml down || true
|
||
@echo "🧹 Cleaning up Go processes on common ports..."
|
||
@-pkill -f "go run" 2>/dev/null || true
|
||
@-pkill -f "main\.go" 2>/dev/null || true
|
||
@-lsof -ti:8080,8081,8082 | xargs kill -9 2>/dev/null || true
|
||
@echo "✅ All services stopped and ports cleaned up"
|
||
|
||
dev-logs: ## Follow development logs
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml logs -f
|
||
|
||
dev-clean: ## Stop development services and remove volumes
|
||
@docker compose -f docker-compose.yml -f docker-compose.override.yml down -v
|
||
|
||
# Infrastructure only (without backend)
|
||
infra: ## Start only infrastructure services (Neo4j, PostgreSQL, Redis, NATS)
|
||
@echo "🏗️ Starting infrastructure services..."
|
||
@docker compose up -d neo4j postgres redis nats
|
||
@echo "⏳ Waiting for infrastructure to be ready..."
|
||
@sleep 15
|
||
@echo "✅ Infrastructure services ready!"
|
||
|
||
infra-down: ## Stop infrastructure services
|
||
@docker compose down
|
||
|
||
infra-clean: ## Stop infrastructure and remove volumes
|
||
@docker compose down -v
|
||
|
||
# Go development commands
|
||
deps: ## Download Go dependencies
|
||
@go mod download
|
||
@go mod tidy
|
||
|
||
build: ## Build the unified CLI application
|
||
@go build -o bin/bugulma-cli ./cmd/cli
|
||
|
||
run: ## Run the application locally (requires infrastructure to be running)
|
||
@./bin/bugulma-cli server
|
||
|
||
test: ## Run tests
|
||
@go test ./...
|
||
|
||
test-verbose: ## Run tests with verbose output
|
||
@go test -v ./...
|
||
|
||
test-cover: ## Run tests with coverage
|
||
@go test -coverprofile=coverage.out ./...
|
||
@go tool cover -html=coverage.out -o coverage.html
|
||
@echo "Coverage report generated: coverage.html"
|
||
|
||
lint: ## Run linter
|
||
@golangci-lint run
|
||
|
||
fmt: ## Format Go code
|
||
@go fmt ./...
|
||
|
||
vet: ## Run go vet
|
||
@go vet ./...
|
||
|
||
# Database operations
|
||
db-migrate: ## Run database migrations (PostgreSQL)
|
||
@echo "Running PostgreSQL migrations..."
|
||
@./bin/bugulma-cli migrate up
|
||
|
||
db-migrate-down: ## Rollback database migrations (PostgreSQL)
|
||
@echo "Rolling back PostgreSQL migrations..."
|
||
@./bin/bugulma-cli migrate down
|
||
|
||
db-migrate-status: ## Check migration status
|
||
@echo "Checking migration status..."
|
||
@./bin/bugulma-cli migrate version
|
||
|
||
db-migrate-version: ## Show current migration version
|
||
@echo "Current migration version:"
|
||
@./bin/bugulma-cli migrate version
|
||
|
||
db-migrate-force: ## Force migration version (use with caution)
|
||
@echo "Forcing migration version (requires -version flag)..."
|
||
@if [ -z "$(version)" ]; then \
|
||
echo "❌ Error: version variable required"; \
|
||
echo "Usage: make db-migrate-force version=123"; \
|
||
exit 1; \
|
||
fi
|
||
@./bin/bugulma-cli migrate force $(version)
|
||
|
||
db-backup: ## Backup production database (turash) - uses dev mode by default
|
||
@./bin/bugulma-cli db backup --dev
|
||
|
||
db-backup-env: ## Backup database using environment variables
|
||
@./bin/bugulma-cli db backup
|
||
|
||
db-backup-conn: ## Backup database using connection string (usage: make db-backup-conn CONN="postgres://user:pass@host:port/db")
|
||
@if [ -z "$(CONN)" ]; then \
|
||
echo "❌ Error: CONN variable required"; \
|
||
echo "Usage: make db-backup-conn CONN=\"postgres://user:pass@host:port/db\""; \
|
||
exit 1; \
|
||
fi
|
||
@./bin/bugulma-cli db backup --conn "$(CONN)"
|
||
|
||
db-restore: ## Restore database from backup (usage: make db-restore BACKUP=backups/turash_backup_YYYYMMDD_HHMMSS.sql.gz)
|
||
@if [ -z "$(BACKUP)" ]; then \
|
||
echo "❌ Error: BACKUP variable required"; \
|
||
echo "Usage: make db-restore BACKUP=backups/turash_backup_YYYYMMDD_HHMMSS.sql.gz"; \
|
||
exit 1; \
|
||
fi
|
||
@./bin/bugulma-cli db restore $(BACKUP) --dev
|
||
|
||
# Docker operations
|
||
docker-build: ## Build production Docker image
|
||
@docker build -t turash-backend:latest .
|
||
|
||
docker-run: ## Run production Docker image
|
||
@docker run -p 8080:8080 --env-file .env turash-backend:latest
|
||
|
||
# Cleanup
|
||
clean: ## Clean build artifacts
|
||
@rm -rf bin/
|
||
@rm -rf tmp/
|
||
@rm -f coverage.out coverage.html
|
||
|
||
clean-all: clean dev-clean ## Clean everything including Docker volumes
|
||
@docker system prune -f
|
||
|
||
# Health checks
|
||
health: ## Check health of all services
|
||
@echo "🔍 Checking service health..."
|
||
@docker compose ps
|
||
@echo ""
|
||
@echo "Testing connections..."
|
||
@-curl -s http://localhost:8080/health > /dev/null && echo "✅ Backend API" || echo "❌ Backend API"
|
||
@-curl -s -u neo4j:test123456 http://localhost:7474/db/data/ > /dev/null && echo "✅ Neo4j" || echo "❌ Neo4j"
|
||
@-docker compose exec -T postgres pg_isready -U turash -d turash > /dev/null && echo "✅ PostgreSQL" || echo "❌ PostgreSQL"
|
||
@-docker compose exec -T redis redis-cli -a turash123 ping | grep -q PONG && echo "✅ Redis" || echo "❌ Redis"
|
||
@-curl -s http://localhost:8222 > /dev/null && echo "✅ NATS" || echo "❌ NATS"
|
||
|
||
# Development helpers
|
||
install-tools: ## Install development tools
|
||
@go install github.com/cosmtrek/air@latest
|
||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||
@echo "Development tools installed"
|
||
|
||
env-setup: ## Setup environment file
|
||
@if [ ! -f .env ]; then \
|
||
cp .env.example .env; \
|
||
echo "✅ .env file created from .env.example"; \
|
||
echo "⚠️ Please update values in .env for your environment"; \
|
||
else \
|
||
echo "ℹ️ .env file already exists"; \
|
||
fi
|
||
|
||
# CI/CD simulation
|
||
ci: deps lint test build ## Run CI pipeline locally
|
||
|
||
# Quick development start
|
||
quick-start: env-setup infra dev-build dev ## Complete development setup
|