diff --git a/.github/CODEOWNERS.md b/.github/CODEOWNERS.md new file mode 100644 index 0000000..0d1d49d --- /dev/null +++ b/.github/CODEOWNERS.md @@ -0,0 +1,40 @@ + +# Code Owners for Aurganize V6.2 +# +# These owners will be automatically requested for review +# when someone opens a pull request. +# +# Format: path/pattern @github-username + +# Default owners for everything +* @developer1 @developer2 + +# Backend code +/backend/ @developer1 +/backend/internal/handlers/ @developer1 +/backend/internal/services/ @developer1 +/backend/internal/repositories/ @developer1 + +# Frontend code +/frontend/ @developer2 +/frontend/src/routes/ @developer2 +/frontend/src/lib/components/ @developer2 + +# Infrastructure requires both reviewers +/infrastructure/ @developer1 @developer2 +/docker-compose.yml @developer1 @developer2 + +# Database migrations require backend lead +/backend/migrations/ @developer1 + +# Documentation can be reviewed by anyone +/docs/ @developer1 @developer2 + +# CI/CD workflows require both +/.github/workflows/ @developer1 @developer2 + +# Package files require review +/backend/go.mod @developer1 +/backend/go.sum @developer1 +/frontend/package.json @developer2 +/frontend/package-lock.json @developer2 \ No newline at end of file diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..1665750 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,250 @@ +# Contributing to Aurganize V6.2 + +Thank you for contributing to Aurganize! This document provides guidelines and instructions for contributing to the project. + +## 📋 Table of Contents + +- [Code of Conduct](#code-of-conduct) +- [Getting Started](#getting-started) +- [Development Workflow](#development-workflow) +- [Coding Standards](#coding-standards) +- [Commit Message Guidelines](#commit-message-guidelines) +- [Pull Request Process](#pull-request-process) +- [Testing Requirements](#testing-requirements) + +## 🤝 Code of Conduct + +- Be respectful and inclusive +- Provide constructive feedback +- Accept constructive criticism gracefully +- Focus on what is best for the project + +## 🚀 Getting Started + +1. **Fork the repository** +2. **Clone your fork:** +```bash + git clone https://github.com/YOUR_USERNAME/aurganize-v62.git + cd aurganize-v62 +``` +3. **Add upstream remote:** +```bash + git remote add upstream https://github.com/yourorg/aurganize-v62.git +``` +4. **Setup development environment:** Follow [README.md](README.md) + +## 🔄 Development Workflow + +### 1. Sync with Upstream +```bash +git checkout develop +git fetch upstream +git merge upstream/develop +git push origin develop +``` + +### 2. Create Feature Branch +```bash +# Branch from develop +git checkout develop +git checkout -b feature/your-feature-name +``` + +**Branch naming conventions:** +- `feature/` - New features +- `bugfix/` - Bug fixes +- `hotfix/` - Urgent production fixes +- `refactor/` - Code refactoring +- `docs/` - Documentation changes +- `test/` - Adding/improving tests + +### 3. Make Changes + +- Write code following our [coding standards](#coding-standards) +- Write/update tests +- Update documentation if needed +- Test locally before committing + +### 4. Commit Changes +```bash +git add . +git commit -m "feat: add user authentication" +``` + +See [commit message guidelines](#commit-message-guidelines) below. + +### 5. Push to Your Fork +```bash +git push origin feature/your-feature-name +``` + +### 6. Create Pull Request + +- Go to GitHub repository +- Click "New Pull Request" +- Select your feature branch +- Fill out PR template completely +- Request review from team members + +## 📝 Coding Standards + +### Go (Backend) + +**Style Guide:** +- Follow [Effective Go](https://golang.org/doc/effective_go) +- Use `gofmt` for formatting +- Use `golangci-lint` for linting + +**File Organization:** +```go +package handlers + +// Imports grouped and sorted +import ( + "context" + "fmt" + + "github.com/labstack/echo/v4" + + "github.com/yourorg/aurganize-v62/backend/internal/models" +) + +// Constants first +const ( + DefaultTimeout = 30 * time.Second +) + +// Types next +type AuthHandler struct { + service *services.AuthService +} + +// Constructor +func NewAuthHandler(service *services.AuthService) *AuthHandler { + return &AuthHandler{service: service} +} + +// Methods +func (h *AuthHandler) Login(c echo.Context) error { + // Implementation +} +``` + +**Naming Conventions:** +- **Packages:** lowercase, single word (e.g., `handlers`) +- **Files:** lowercase, underscore-separated (e.g., `auth_handler.go`) +- **Functions:** PascalCase for exported, camelCase for private +- **Variables:** camelCase +- **Constants:** PascalCase or SCREAMING_SNAKE_CASE for globals + +**Error Handling:** +```go +// Always check errors +result, err := someFunction() +if err != nil { + return fmt.Errorf("failed to do something: %w", err) +} + +// Use %w to wrap errors (enables errors.Is and errors.As) +``` + +**Comments:** +```go +// Package-level comment +// package handlers provides HTTP request handlers for the API. +package handlers + +// Exported functions must have doc comments +// Login handles user authentication requests. +// It validates credentials and returns a JWT token. +func Login(c echo.Context) error { + // Implementation comments for complex logic + // ... +} +``` + +### TypeScript (Frontend) + +**Style Guide:** +- Follow [TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html) +- Use ESLint and Prettier (configured) + +**File Organization:** +```typescript +// Imports +import type { User } from '$lib/types'; +import { authStore } from '$lib/stores/auth'; + +// Types/Interfaces +interface LoginForm { + email: string; + password: string; +} + +// Constants +const MAX_LOGIN_ATTEMPTS = 5; + +// Functions +export async function login(form: LoginForm): Promise { + // Implementation +} +``` + +**Naming Conventions:** +- **Files:** kebab-case (e.g., `auth-service.ts`) +- **Components:** PascalCase (e.g., `LoginForm.svelte`) +- **Functions:** camelCase +- **Constants:** SCREAMING_SNAKE_CASE +- **Types/Interfaces:** PascalCase + +**Svelte Components:** +```svelte + + +
+ +
+ + +``` + +### SQL (Database) + +**Style:** +- Keywords in UPPERCASE +- Table/column names in lowercase with underscores +- Indent for readability +```sql +-- Good +SELECT + u.id, + u.email, + t.name AS tenant_name +FROM users u +INNER JOIN tenants t ON u.tenant_id = t.id +WHERE u.is_active = TRUE +ORDER BY u.created_at DESC; + +-- Bad +select u.id, u.email, t.name from users u join tenants t on u.tenant_id=t.id where u.is_active=true; +``` + +## 💬 Commit Message Guidelines + +We follow [Conventional Commits](https://www.conventionalcommits.org/). + +### Format \ No newline at end of file diff --git a/README.md b/README.md index afe355f..7a6b15f 100644 --- a/README.md +++ b/README.md @@ -341,13 +341,6 @@ Proprietary - All Rights Reserved See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines. -## 📞 Support - -- **Documentation:** See `/docs` directory -- **Issues:** Create GitHub issue -- **Questions:** Ask in team Slack channel - ---- **Made with ❤️ by the Aurganize Team** -EOF \ No newline at end of file +EOF diff --git a/backend/.air.toml b/backend/.air.toml new file mode 100644 index 0000000..0785915 --- /dev/null +++ b/backend/.air.toml @@ -0,0 +1,94 @@ +# ============================================================================ +# AIR CONFIGURATION - HOT RELOAD FOR GO +# ============================================================================ + +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + + + + +[build] + # Array of commands to run before each build + pre_cmd = [] + + # Just plain old shell command + cmd = "go build -o ./tmp/main.exe ./cmd/api" + + # Binary file yields from `cmd` + bin = "tmp/main.exe" + + # Customize binary, can setup environment variables when run your app + # full_bin = "tmp\\main.exe" + + # Watch these filename extensions + include_ext = ["go", "tpl", "tmpl", "html"] + + # Ignore these filename extensions or directories + exclude_dir = ["assets", "tmp", "vendor", "testdata", "migrations"] + + # Watch these directories if you specified + include_dir = [] + + # Exclude files + exclude_file = [] + + # Exclude specific regular expressions + exclude_regex = ["_test\\.go"] + + # Exclude unchanged files + exclude_unchanged = false + + # Follow symbolic links + follow_symlink = false + + # This log file places in your tmp_dir + log = "build-errors.log" + + # Poll for file changes instead of using fsnotify (useful for Docker) + poll = false + + # Poll interval (ms) + poll_interval = 0 + + # It's not necessary to trigger build each time file changes if it's too frequent + delay = 1000 # ms + + # Stop running old binary when build errors occur + stop_on_error = false + + # Send Interrupt signal before killing process (useful for graceful shutdown) + send_interrupt = true + + # Delay after sending Interrupt signal + kill_delay = 1000 # ms + + # Add additional arguments when running binary + args_bin = [] + +[log] + # Show log time + time = true + + # Only show main log (silences the watcher, build, runner) + main_only = false + +[color] + # Customize each part's color + main = "magenta" + watcher = "cyan" + build = "yellow" + runner = "green" + +[misc] + # Delete tmp directory on exit + clean_on_exit = true + +[screen] + # Clear screen on rebuild + clear_on_rebuild = true + + # Enable or disable keep screen scrolling + keep_scroll = true + diff --git a/backend/DockerFile.dev b/backend/DockerFile.dev new file mode 100644 index 0000000..d0dcde2 --- /dev/null +++ b/backend/DockerFile.dev @@ -0,0 +1,33 @@ +# backend/Dockerfile.dev +# Development Dockerfile with hot reload support + +# Stage 1: Base image with Go tools +FROM golang:1.21-alpine AS base + +# Install developement tools +# - git: Required for go get +# - gcc, musl-dev: Required for CGO (some packages need C compiler) +# - air: Hot reload tool for GO +RUN apk add --no-cache \ + git \ + gcc \ + musl-dev && \ + go install github.com/air-verse/air@latest + + +# Set working directory +WORKDIR /app + +# Stage 2: Development environment +FROM base as development + +# Copy dependency files first (for layer caching) +COPY go.mod go.sum./ + +# Download dependencies +# This layer is cached unless go.mod or go.sum changes +RUN go mod download + +# Copy Air configuration + +COPY .air.t \ No newline at end of file diff --git a/backend/Makefile b/backend/Makefile new file mode 100644 index 0000000..545a075 --- /dev/null +++ b/backend/Makefile @@ -0,0 +1,256 @@ +# ============================================================================ +# AURGANIZE V6.2 - BACKEND MAKEFILE +# ============================================================================ +# +# Common development tasks for the backend API server. +# Run 'make help' to see all available commands. + +# Variables +APP_NAME=aurganize-api +VERSION=6.2.0 +MAIN_PATH=cmd/api/main.go +BUILD_DIR=bin +BINARY_NAME=api + +# Go commands +GOCMD=go +GOBUILD=$(GOCMD) build +GOCLEAN=$(GOCMD) clean +GOTEST=$(GOCMD) test +GOGET=$(GOCMD) get +GOMOD=$(GOCMD) mod +GOFMT=$(GOCMD) fmt + +# Build flags +LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)" + +# Colors for output +COLOR_RESET=\033[0m +COLOR_GREEN=\033[32m +COLOR_YELLOW=\033[33m +COLOR_BLUE=\033[34m + +.PHONY: help +help: ## Show this help message + @echo '$(COLOR_BLUE)Aurganize V6.2 - Backend Makefile$(COLOR_RESET)' + @echo '' + @echo '$(COLOR_GREEN)Usage:$(COLOR_RESET)' + @echo ' make [target]' + @echo '' + @echo '$(COLOR_GREEN)Available targets:$(COLOR_RESET)' + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(COLOR_YELLOW)%-15s$(COLOR_RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +.PHONY: dev +dev: ## Run development server with hot reload (requires Air) + @echo '$(COLOR_GREEN)Starting development server...$(COLOR_RESET)' + @if command -v air > /dev/null; then \ + air; \ + else \ + echo '$(COLOR_YELLOW)Air not installed. Run: make install-air$(COLOR_RESET)'; \ + echo '$(COLOR_YELLOW)Running without hot reload...$(COLOR_RESET)'; \ + $(GOCMD) run $(MAIN_PATH); \ + fi + +.PHONY: run +run: ## Run server without hot reload + @echo '$(COLOR_GREEN)Starting server...$(COLOR_RESET)' + $(GOCMD) run $(MAIN_PATH) + +.PHONY: build +build: ## Build production binary + @echo '$(COLOR_GREEN)Building production binary...$(COLOR_RESET)' + @mkdir -p $(BUILD_DIR) + CGO_ENABLED=0 GOOS=linux $(GOBUILD) $(LDFLAGS) -a -installsuffix cgo -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH) + @echo '$(COLOR_GREEN)Binary created at: $(BUILD_DIR)/$(BINARY_NAME)$(COLOR_RESET)' + +.PHONY: build-local +build-local: ## Build binary for local OS + @echo '$(COLOR_GREEN)Building local binary...$(COLOR_RESET)' + @mkdir -p $(BUILD_DIR) + $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH) + @echo '$(COLOR_GREEN)Binary created at: $(BUILD_DIR)/$(BINARY_NAME)$(COLOR_RESET)' + +.PHONY: test +test: ## Run all tests + @echo '$(COLOR_GREEN)Running tests...$(COLOR_RESET)' + $(GOTEST) -v -race -coverprofile=coverage.out ./... + @echo '' + @echo '$(COLOR_GREEN)Coverage summary:$(COLOR_RESET)' + @$(GOCMD) tool cover -func=coverage.out | grep total + +.PHONY: test-coverage +test-coverage: test ## Run tests and show coverage report + @echo '$(COLOR_GREEN)Generating HTML coverage report...$(COLOR_RESET)' + $(GOCMD) tool cover -html=coverage.out -o coverage.html + @echo '$(COLOR_GREEN)Coverage report: coverage.html$(COLOR_RESET)' + +.PHONY: test-unit +test-unit: ## Run unit tests only + @echo '$(COLOR_GREEN)Running unit tests...$(COLOR_RESET)' + $(GOTEST) -v -short ./... + +.PHONY: test-integration +test-integration: ## Run integration tests only + @echo '$(COLOR_GREEN)Running integration tests...$(COLOR_RESET)' + $(GOTEST) -v -run Integration ./... + +.PHONY: bench +bench: ## Run benchmarks + @echo '$(COLOR_GREEN)Running benchmarks...$(COLOR_RESET)' + $(GOTEST) -bench=. -benchmem ./... + +.PHONY: clean +clean: ## Clean build artifacts and caches + @echo '$(COLOR_GREEN)Cleaning...$(COLOR_RESET)' + $(GOCLEAN) + rm -rf $(BUILD_DIR) + rm -rf tmp + rm -f coverage.out coverage.html + @echo '$(COLOR_GREEN)Clean complete$(COLOR_RESET)' + +.PHONY: deps +deps: ## Download dependencies + @echo '$(COLOR_GREEN)Downloading dependencies...$(COLOR_RESET)' + $(GOMOD) download + $(GOMOD) tidy + @echo '$(COLOR_GREEN)Dependencies updated$(COLOR_RESET)' + +.PHONY: deps-update +deps-update: ## Update all dependencies + @echo '$(COLOR_GREEN)Updating dependencies...$(COLOR_RESET)' + $(GOGET) -u ./... + $(GOMOD) tidy + @echo '$(COLOR_GREEN)Dependencies updated$(COLOR_RESET)' + +.PHONY: lint +lint: ## Run linter + @echo '$(COLOR_GREEN)Running linter...$(COLOR_RESET)' + @if command -v golangci-lint > /dev/null; then \ + golangci-lint run; \ + else \ + echo '$(COLOR_YELLOW)golangci-lint not installed. Run: make install-linter$(COLOR_RESET)'; \ + fi + +.PHONY: fmt +fmt: ## Format code + @echo '$(COLOR_GREEN)Formatting code...$(COLOR_RESET)' + $(GOFMT) ./... + @if command -v goimports > /dev/null; then \ + goimports -w .; \ + fi + +.PHONY: vet +vet: ## Run go vet + @echo '$(COLOR_GREEN)Running go vet...$(COLOR_RESET)' + $(GOCMD) vet ./... + +.PHONY: check +check: fmt vet lint test ## Run all checks (fmt, vet, lint, test) + @echo '$(COLOR_GREEN)All checks passed!$(COLOR_RESET)' + +.PHONY: migrate-up +migrate-up: ## Run database migrations + @echo '$(COLOR_GREEN)Running database migrations...$(COLOR_RESET)' + @if command -v migrate > /dev/null; then \ + migrate -path migrations -database "$$(grep DB_ .env | xargs | sed 's/ /\&/g' | sed 's/DB_/postgresql:\/\//g')" up; \ + else \ + echo '$(COLOR_YELLOW)golang-migrate not installed. Run: make install-migrate$(COLOR_RESET)'; \ + fi + +.PHONY: migrate-down +migrate-down: ## Rollback last migration + @echo '$(COLOR_GREEN)Rolling back last migration...$(COLOR_RESET)' + @if command -v migrate > /dev/null; then \ + migrate -path migrations -database "$$(grep DB_ .env | xargs | sed 's/ /\&/g' | sed 's/DB_/postgresql:\/\//g')" down 1; \ + else \ + echo '$(COLOR_YELLOW)golang-migrate not installed. Run: make install-migrate$(COLOR_RESET)'; \ + fi + +.PHONY: migrate-create +migrate-create: ## Create new migration (usage: make migrate-create NAME=add_users_table) + @if [ -z "$(NAME)" ]; then \ + echo '$(COLOR_YELLOW)Usage: make migrate-create NAME=add_users_table$(COLOR_RESET)'; \ + exit 1; \ + fi + @echo '$(COLOR_GREEN)Creating migration: $(NAME)...$(COLOR_RESET)' + @if command -v migrate > /dev/null; then \ + migrate create -ext sql -dir migrations -seq $(NAME); \ + else \ + echo '$(COLOR_YELLOW)golang-migrate not installed. Run: make install-migrate$(COLOR_RESET)'; \ + fi + +.PHONY: docker-build +docker-build: ## Build Docker image + @echo '$(COLOR_GREEN)Building Docker image...$(COLOR_RESET)' + docker build -t $(APP_NAME):$(VERSION) -t $(APP_NAME):latest . + @echo '$(COLOR_GREEN)Docker image built: $(APP_NAME):$(VERSION)$(COLOR_RESET)' + +.PHONY: docker-run +docker-run: ## Run Docker container + @echo '$(COLOR_GREEN)Running Docker container...$(COLOR_RESET)' + docker run -p 8080:8080 --env-file .env $(APP_NAME):latest + +.PHONY: install-air +install-air: ## Install Air for hot reload + @echo '$(COLOR_GREEN)Installing Air...$(COLOR_RESET)' + $(GOGET) -u github.com/cosmtrek/air + @echo '$(COLOR_GREEN)Air installed. Run: make dev$(COLOR_RESET)' + +.PHONY: install-linter +install-linter: ## Install golangci-lint + @echo '$(COLOR_GREEN)Installing golangci-lint...$(COLOR_RESET)' + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin + @echo '$(COLOR_GREEN)golangci-lint installed$(COLOR_RESET)' + +.PHONY: install-migrate +install-migrate: ## Install golang-migrate + @echo '$(COLOR_GREEN)Installing golang-migrate...$(COLOR_RESET)' + @if [ "$$(uname)" = "Darwin" ]; then \ + brew install golang-migrate; \ + else \ + echo '$(COLOR_YELLOW)Please install manually: https://github.com/golang-migrate/migrate$(COLOR_RESET)'; \ + fi + +.PHONY: install-tools +install-tools: install-air install-linter install-migrate ## Install all development tools + @echo '$(COLOR_GREEN)All tools installed!$(COLOR_RESET)' + +.PHONY: db-psql +db-psql: ## Connect to database with psql + @if [ -f .env ]; then \ + export $$(cat .env | xargs) && psql "postgresql://$$DB_USER:$$DB_PASSWORD@$$DB_HOST:$$DB_PORT/$$DB_NAME?sslmode=$$DB_SSLMODE"; \ + else \ + echo '$(COLOR_YELLOW).env file not found$(COLOR_RESET)'; \ + fi + +.PHONY: seed +seed: ## Run database seed script + @echo '$(COLOR_GREEN)Seeding database...$(COLOR_RESET)' + $(GOCMD) run scripts/seed/main.go + +.PHONY: mod-graph +mod-graph: ## Show dependency graph + $(GOMOD) graph + +.PHONY: mod-why +mod-why: ## Show why a package is needed (usage: make mod-why PKG=github.com/pkg/errors) + $(GOMOD) why $(PKG) + +.PHONY: version +version: ## Show version information + @echo 'Application: $(APP_NAME)' + @echo 'Version: $(VERSION)' + @echo 'Go version: $(shell go version)' + +.PHONY: info +info: ## Show project information + @echo '$(COLOR_BLUE)Project Information$(COLOR_RESET)' + @echo ' Name: $(APP_NAME)' + @echo ' Version: $(VERSION)' + @echo ' Main Path: $(MAIN_PATH)' + @echo ' Build Dir: $(BUILD_DIR)' + @echo '' + @echo '$(COLOR_BLUE)Environment$(COLOR_RESET)' + @echo ' Go Version: $(shell go version)' + @echo ' GOPATH: $(GOPATH)' + @echo ' GOROOT: $(GOROOT)' \ No newline at end of file diff --git a/backend/cmd/api/main.go b/backend/cmd/api/main.go index fa1ab43..2c853a7 100644 --- a/backend/cmd/api/main.go +++ b/backend/cmd/api/main.go @@ -151,7 +151,7 @@ func main() { log.Info().Msg("Middleware configured") // ========================================================================= - // Middleware Pipeline + // Route Mapping // ========================================================================= e.GET("/health", healthCheckHandler(cfg)) // (Public - health check) @@ -159,7 +159,7 @@ func main() { api.GET("/ping", func(c echo.Context) error { // (Public - connectivity test) return c.JSON(http.StatusOK, map[string]string{ - "message": "pika pikaaa", + "message": "pika pikaaa --- PIKAAA CHUUUUU", "timestamp": time.Now().UTC().Format(time.RFC3339), "version": "0.6.2", }) diff --git a/backend/database/migrations/000001_initial_schema.down.sql b/database/migrations/000001_initial_schema.down.sql similarity index 100% rename from backend/database/migrations/000001_initial_schema.down.sql rename to database/migrations/000001_initial_schema.down.sql diff --git a/backend/database/migrations/000001_initial_schema.up.sql b/database/migrations/000001_initial_schema.up.sql similarity index 100% rename from backend/database/migrations/000001_initial_schema.up.sql rename to database/migrations/000001_initial_schema.up.sql diff --git a/backend/database/scripts/backup_db.sh b/database/scripts/backup_db.sh similarity index 100% rename from backend/database/scripts/backup_db.sh rename to database/scripts/backup_db.sh diff --git a/backend/database/scripts/configure-postgres.sh b/database/scripts/configure-postgres.sh similarity index 100% rename from backend/database/scripts/configure-postgres.sh rename to database/scripts/configure-postgres.sh diff --git a/backend/database/scripts/dev_seed.sh b/database/scripts/dev_seed.sh similarity index 100% rename from backend/database/scripts/dev_seed.sh rename to database/scripts/dev_seed.sh diff --git a/backend/database/scripts/health_check.sh b/database/scripts/health_check.sh similarity index 100% rename from backend/database/scripts/health_check.sh rename to database/scripts/health_check.sh diff --git a/backend/database/scripts/migrate.sh b/database/scripts/migrate.sh similarity index 100% rename from backend/database/scripts/migrate.sh rename to database/scripts/migrate.sh diff --git a/backend/database/scripts/restore_db.sh b/database/scripts/restore_db.sh similarity index 100% rename from backend/database/scripts/restore_db.sh rename to database/scripts/restore_db.sh diff --git a/backend/database/scripts/test_ops.sh b/database/scripts/test_ops.sh similarity index 100% rename from backend/database/scripts/test_ops.sh rename to database/scripts/test_ops.sh diff --git a/backend/database/seeds/001_dev_data.sql b/database/seeds/001_dev_data.sql similarity index 100% rename from backend/database/seeds/001_dev_data.sql rename to database/seeds/001_dev_data.sql diff --git a/backend/database/tests/health_check.sql b/database/tests/health_check.sql similarity index 100% rename from backend/database/tests/health_check.sql rename to database/tests/health_check.sql diff --git a/backend/database/tests/test_operations.sql b/database/tests/test_operations.sql similarity index 100% rename from backend/database/tests/test_operations.sql rename to database/tests/test_operations.sql diff --git a/infrastructure/docker/docker-compose.yml b/infrastructure/docker/docker-compose.yml index 8a1940f..9720c76 100644 --- a/infrastructure/docker/docker-compose.yml +++ b/infrastructure/docker/docker-compose.yml @@ -1,6 +1,10 @@ +# docker-compose.yml version: '3.8' +# Define all services that make up Aurganize services: + + # PostgreSQL 14 - Primary database postgres: image: postgres:14-alpine container_name: aurganize-postgres @@ -21,5 +25,147 @@ services: timeout: 5s retries: 5 + networks: + - aurganize-network + + # Redis 7 - Caching and session storage + redis: + image: redis:7-alpine + container_name: aurganize-redis + restart: unless-stopped + command: redis-server --appendonly yes + ports: + - "6379:6379" + volumes: + - redis_data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - aurganize-network + + # NATS with JetStream - Event bus + nats: + image: nats:latest + container_name: aurganize-nats + restart: unless-stopped + command: ["-js", "-m", "8222"] + ports: + - "4222:4222" # Client connections + - "8222:8222" # HTTP monitoring + volumes: + - nats_data:/data + healthcheck: + test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - aurganize-network + + # MinIO - S3-compatible object storage + minio: + image: minio/minio:latest + container_name: aurganize-minio + restart: unless-stopped + command: server /data --console-address ":9001" + environment: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + ports: + - "9000:9000" # API + - "9001:9001" # Web Console + volumes: + - minio_data:/data + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - aurganize-network + + # Backend - Go API server + backend: + build: + context: ./../../backend + dockerfile: Dockerfile.dev + container_name: aurganize-backend + restart: unless-stopped + environment: + # Application config + ENV: development + PORT: 8080 + + # Database connection + DB_HOST: postgres + DB_PORT: 5432 + DB_USER: aurganize + DB_PASSWORD: dev_password_change_in_prod + DB_NAME: aurganize + DB_SSL_MODE: disable + + # Redis connection + REDIS_HOST: redis + REDIS_PORT: 6379 + REDIS_PASSWORD: "" + + # NATS connection + NATS_URL: nats://nats:4222 + + # MinIO connection + MINIO_ENDPOINT: minio:9000 + MINIO_ACCESS_KEY: minioadmin + MINIO_SECRET_KEY: minioadmin + MINIO_USE_SSL: false + + # JWT secrets (development only) + JWT_SECRET: dev-secret-change-in-production + + # CORS settings + CORS_ORIGINS: http://localhost:3000 + ports: + - "8080:8080" + volumes: + # Mount source code for hot reload + - ./backend:/app + # Exclude node_modules and vendor + - /app/vendor + - /app/bin + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + nats: + condition: service_healthy + minio: + condition: service_healthy + healthcheck: + test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - aurganize-network + + # Frontend - React application + # TODO + +# Named volumes for data persistence volumes: - postgres_data: \ No newline at end of file + postgres_data: + driver: local + redis_data: + driver: local + nats_data: + driver: local + minio_data: + driver: local + +# Custom network for service isolation +networks: + aurganize-network: + driver: bridge \ No newline at end of file