Initial commit: MyCrib API in Go
Complete rewrite of Django REST API to Go with: - Gin web framework for HTTP routing - GORM for database operations - GoAdmin for admin panel - Gorush integration for push notifications - Redis for caching and job queues Features implemented: - User authentication (login, register, logout, password reset) - Residence management (CRUD, sharing, share codes) - Task management (CRUD, kanban board, completions) - Contractor management (CRUD, specialties) - Document management (CRUD, warranties) - Notifications (preferences, push notifications) - Subscription management (tiers, limits) Infrastructure: - Docker Compose for local development - Database migrations and seed data - Admin panel for data management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
175
dev.sh
Executable file
175
dev.sh
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/bin/bash
|
||||
# Development helper script for MyCrib API (Go)
|
||||
|
||||
set -e
|
||||
|
||||
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.dev.yml"
|
||||
|
||||
case "$1" in
|
||||
up)
|
||||
echo "🚀 Starting development environment..."
|
||||
docker-compose $COMPOSE_FILES up
|
||||
;;
|
||||
down)
|
||||
echo "⏹️ Stopping development environment..."
|
||||
docker-compose $COMPOSE_FILES down
|
||||
;;
|
||||
logs)
|
||||
if [ -n "$2" ]; then
|
||||
docker-compose $COMPOSE_FILES logs -f "$2"
|
||||
else
|
||||
docker-compose $COMPOSE_FILES logs -f
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
echo "🔄 Restarting development environment..."
|
||||
docker-compose $COMPOSE_FILES restart
|
||||
;;
|
||||
build)
|
||||
echo "🔨 Rebuilding containers..."
|
||||
docker-compose $COMPOSE_FILES up --build
|
||||
;;
|
||||
bash)
|
||||
echo "🐚 Opening bash in API container..."
|
||||
docker-compose $COMPOSE_FILES exec api sh
|
||||
;;
|
||||
test)
|
||||
echo "🧪 Running tests..."
|
||||
go test -v ./...
|
||||
;;
|
||||
test-docker)
|
||||
echo "🧪 Running tests in Docker..."
|
||||
docker-compose $COMPOSE_FILES exec api go test -v ./...
|
||||
;;
|
||||
lint)
|
||||
echo "🔍 Running linter..."
|
||||
golangci-lint run ./...
|
||||
;;
|
||||
fmt)
|
||||
echo "📝 Formatting code..."
|
||||
go fmt ./...
|
||||
;;
|
||||
build-local)
|
||||
echo "🔨 Building binaries locally..."
|
||||
go build -o bin/api ./cmd/api
|
||||
go build -o bin/worker ./cmd/worker
|
||||
go build -o bin/admin ./cmd/admin
|
||||
echo "✅ Binaries built in ./bin/"
|
||||
;;
|
||||
run-api)
|
||||
echo "🚀 Running API server locally..."
|
||||
go run ./cmd/api
|
||||
;;
|
||||
run-worker)
|
||||
echo "⚙️ Running worker locally..."
|
||||
go run ./cmd/worker
|
||||
;;
|
||||
run-admin)
|
||||
echo "🛠️ Running admin panel locally..."
|
||||
go run ./cmd/admin
|
||||
;;
|
||||
db)
|
||||
echo "🐘 Connecting to PostgreSQL..."
|
||||
docker-compose $COMPOSE_FILES exec db psql -U ${POSTGRES_USER:-mycrib} -d ${POSTGRES_DB:-mycrib}
|
||||
;;
|
||||
redis)
|
||||
echo "📮 Connecting to Redis..."
|
||||
docker-compose $COMPOSE_FILES exec redis redis-cli
|
||||
;;
|
||||
seed)
|
||||
echo "🌱 Seeding lookup data..."
|
||||
docker-compose $COMPOSE_FILES exec -T db psql -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-mycrib} -f - < seeds/001_lookups.sql
|
||||
echo "✅ Lookup data seeded"
|
||||
;;
|
||||
seed-test)
|
||||
echo "🧪 Seeding test data..."
|
||||
docker-compose $COMPOSE_FILES exec -T db psql -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-mycrib} -f - < seeds/002_test_data.sql
|
||||
echo "✅ Test data seeded"
|
||||
;;
|
||||
seed-all)
|
||||
echo "🌱 Seeding all data..."
|
||||
docker-compose $COMPOSE_FILES exec -T db psql -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-mycrib} -f - < seeds/001_lookups.sql
|
||||
docker-compose $COMPOSE_FILES exec -T db psql -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-mycrib} -f - < seeds/002_test_data.sql
|
||||
echo "✅ All data seeded"
|
||||
;;
|
||||
seed-admin)
|
||||
echo "🔐 Seeding GoAdmin tables..."
|
||||
docker-compose $COMPOSE_FILES exec -T db psql -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-mycrib} -f - < migrations/002_goadmin_tables.up.sql
|
||||
echo "✅ GoAdmin tables seeded"
|
||||
;;
|
||||
migrate)
|
||||
echo "📊 Running database migrations..."
|
||||
# GORM auto-migrates on API startup, but we need GoAdmin tables
|
||||
docker-compose $COMPOSE_FILES exec -T db psql -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-mycrib} -f - < migrations/002_goadmin_tables.up.sql
|
||||
echo "✅ Migrations complete"
|
||||
;;
|
||||
clean)
|
||||
echo "🧹 Cleaning up..."
|
||||
docker-compose $COMPOSE_FILES down -v
|
||||
rm -rf bin/
|
||||
echo "✅ Cleaned containers and binaries"
|
||||
;;
|
||||
status)
|
||||
echo "📊 Docker container status:"
|
||||
docker-compose $COMPOSE_FILES ps
|
||||
;;
|
||||
*)
|
||||
# If no argument provided, default to 'up'
|
||||
if [ -z "$1" ]; then
|
||||
echo "🚀 Starting development environment..."
|
||||
docker-compose $COMPOSE_FILES up
|
||||
else
|
||||
echo "Development helper script for MyCrib API (Go)"
|
||||
echo ""
|
||||
echo "Usage: ./dev.sh [command]"
|
||||
echo ""
|
||||
echo "Docker Commands:"
|
||||
echo " (no args) Start development environment (default)"
|
||||
echo " up Start development environment"
|
||||
echo " down Stop development environment"
|
||||
echo " logs [service] View logs (optionally for specific service)"
|
||||
echo " restart Restart all services"
|
||||
echo " build Rebuild and start containers"
|
||||
echo " bash Open shell in API container"
|
||||
echo " status Show container status"
|
||||
echo " clean Stop containers and remove volumes"
|
||||
echo ""
|
||||
echo "Local Development:"
|
||||
echo " build-local Build all binaries locally"
|
||||
echo " run-api Run API server locally"
|
||||
echo " run-worker Run worker locally"
|
||||
echo " run-admin Run admin panel locally"
|
||||
echo " test Run tests locally"
|
||||
echo " test-docker Run tests in Docker"
|
||||
echo " lint Run linter"
|
||||
echo " fmt Format code"
|
||||
echo ""
|
||||
echo "Database:"
|
||||
echo " db Connect to PostgreSQL"
|
||||
echo " redis Connect to Redis"
|
||||
echo " migrate Run database migrations"
|
||||
echo " seed Seed lookup data (categories, priorities, etc.)"
|
||||
echo " seed-test Seed test data (users, residences, tasks)"
|
||||
echo " seed-all Seed all data (lookups + test data)"
|
||||
echo " seed-admin Seed GoAdmin tables"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo " api - API server (port 8000)"
|
||||
echo " worker - Background job worker"
|
||||
echo " admin - Admin panel (port 9000)"
|
||||
echo " db - PostgreSQL database"
|
||||
echo " redis - Redis cache"
|
||||
echo " gorush - Push notification server"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " ./dev.sh # Start dev environment"
|
||||
echo " ./dev.sh up # Same as above"
|
||||
echo " ./dev.sh logs api # View API server logs"
|
||||
echo " ./dev.sh logs worker # View worker logs"
|
||||
echo " ./dev.sh build # Rebuild and start"
|
||||
echo " ./dev.sh run-api # Run API locally (without Docker)"
|
||||
echo " ./dev.sh test # Run tests"
|
||||
echo " ./dev.sh db # Connect to PostgreSQL"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user