feat: complete Phase 1 foundation scaffold
Some checks failed
CI / Lint (push) Has been cancelled
CI / TypeCheck (push) Has been cancelled
CI / Test (push) Has been cancelled
Deploy / Docker Build & Push (map[context:. dockerfile:apps/api/Dockerfile name:api]) (push) Has been cancelled
Deploy / Docker Build & Push (map[context:. dockerfile:apps/cms/Dockerfile name:cms]) (push) Has been cancelled
Deploy / Docker Build & Push (map[context:. dockerfile:apps/web/Dockerfile name:web]) (push) Has been cancelled
CI / Build (push) Has been cancelled
Deploy / Deploy (push) Has been cancelled

- Monorepo: Turborepo + pnpm workspaces with 7 apps/packages
- Backend: NestJS scaffold with 9 modules (auth, tenant, curriculum, simulation, portfolio, ai-coach, analytics, classroom, gamification)
- Frontend: React 18 + Vite + TailwindCSS + shadcn/ui with 10 pages, 14 UI primitives, 3 Zustand stores
- Database: Prisma schema with 19 models, 13 enums, seed script, multi-tenant ready
- Docker: Dev, production, and Portainer Compose files with Traefik reverse proxy
- Configuration: .env.example (47 vars), Zod validation, frontend-safe env exposure
- i18n: English + Greek locale files (10 files), ICU MessageFormat, react-i18next
- Shared packages: @investplay/types, @investplay/ui, @investplay/i18n, @investplay/utils
- CI/CD: GitHub Actions (lint, typecheck, test, build, deploy, PR checks)
- Documentation: CONTEXT.md, ARCHITECTURE.md (10 Mermaid diagrams), API.md, LOCALIZATION.md, DEVELOPMENT-ROADMAP.md
- Infrastructure: Dockerfiles (dev + prod), nginx configs, backup/healthcheck scripts
- Security: JWT auth guards, role-based access, rate limiting, Helmet, CORS, PII sanitization
This commit is contained in:
Lefteris Notas
2026-06-12 19:32:57 +03:00
parent fa71c60cfc
commit e75f913f1c
226 changed files with 17547 additions and 0 deletions

127
scripts/setup.sh Normal file
View File

@@ -0,0 +1,127 @@
#!/usr/bin/env bash
set -euo pipefail
# ─── Color output ──────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
ok() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*"; }
# ─── Prerequisites ──────────────────────────────────────────────
info "Checking prerequisites..."
command -v docker >/dev/null 2>&1 || { error "Docker is required but not installed."; exit 1; }
ok "Docker $(docker --version)"
docker compose version >/dev/null 2>&1 || { error "Docker Compose is required but not installed."; exit 1; }
ok "Docker Compose $(docker compose version --short)"
command -v node >/dev/null 2>&1 || { error "Node.js is required but not installed."; exit 1; }
ok "Node.js $(node --version)"
command -v pnpm >/dev/null 2>&1 || { error "pnpm is required but not installed. Install it: npm install -g pnpm"; exit 1; }
ok "pnpm $(pnpm --version)"
# ─── Project root ───────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${PROJECT_ROOT}"
# ─── Environment file ───────────────────────────────────────────
if [ ! -f .env ]; then
if [ -f .env.example ]; then
cp .env.example .env
info "Created .env from .env.example — please review and update credentials."
else
warn "No .env.example found. Creating minimal .env..."
cat > .env <<-EOF
POSTGRES_USER=investplay
POSTGRES_PASSWORD=investplay_dev_pass
POSTGRES_DB=investplay
DATABASE_URL=postgresql://investplay:investplay_dev_pass@localhost:5432/investplay
REDIS_URL=redis://localhost:6379
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin_dev
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_USE_SSL=false
JWT_SECRET=change-me-in-production
EOF
ok "Created minimal .env"
fi
else
ok ".env already exists"
fi
# ─── Start infrastructure services ──────────────────────────────
info "Starting infrastructure (PostgreSQL, Redis, MinIO)..."
docker compose -f docker-compose.dev.yml up -d postgres redis minio
info "Waiting for PostgreSQL to become healthy..."
until docker compose -f docker-compose.dev.yml exec -T postgres pg_isready -U "${POSTGRES_USER:-investplay}" 2>/dev/null; do
sleep 2
done
ok "PostgreSQL is ready"
info "Waiting for Redis to become healthy..."
until docker compose -f docker-compose.dev.yml exec -T redis redis-cli ping 2>/dev/null | grep -q PONG; do
sleep 1
done
ok "Redis is ready"
info "Waiting for MinIO to become healthy..."
until docker compose -f docker-compose.dev.yml exec -T minio mc ready local 2>/dev/null; do
sleep 2
done
ok "MinIO is ready"
# ─── Install dependencies ───────────────────────────────────────
info "Installing pnpm dependencies..."
pnpm install
ok "Dependencies installed"
# ─── Generate Prisma client ─────────────────────────────────────
info "Running Prisma migrations..."
if [ -f apps/api/prisma/schema.prisma ]; then
pnpm --filter @investplay/api exec prisma generate
pnpm --filter @investplay/api exec prisma migrate dev --name init 2>/dev/null || true
ok "Prisma client generated and migrations applied"
else
warn "No Prisma schema found at apps/api/prisma/schema.prisma — skipping migrations"
fi
# ─── Seed database ─────────────────────────────────────────────
if [ -f apps/api/prisma/seed.ts ] || [ -f apps/api/prisma/seed.js ]; then
info "Seeding database..."
pnpm --filter @investplay/api exec prisma db seed 2>/dev/null || true
ok "Database seeded"
else
info "No seed script found — skipping"
fi
# ─── Start remaining services ──────────────────────────────────
info "Starting API, Web, and CMS..."
docker compose -f docker-compose.dev.yml up -d api web cms
ok "All services started"
# ─── Summary ────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}══════════════════════════════════════════════════════════${NC}"
echo -e "${GREEN} InvestPlay development environment is ready!${NC}"
echo -e "${GREEN}══════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " ${CYAN}Web App:${NC} http://localhost:5173"
echo -e " ${CYAN}API:${NC} http://localhost:3001"
echo -e " ${CYAN}CMS:${NC} http://localhost:3000"
echo -e " ${CYAN}MinIO Console:${NC} http://localhost:9001"
echo -e " ${CYAN}PostgreSQL:${NC} localhost:5432"
echo -e " ${CYAN}Redis:${NC} localhost:6379"
echo ""
echo -e " ${YELLOW}Run 'docker compose -f docker-compose.dev.yml logs -f' to tail logs${NC}"
echo ""