init project structure

This commit is contained in:
GW_MC
2026-03-06 13:28:14 +00:00
parent 4ce28b9005
commit 9c55a11712
34 changed files with 7035 additions and 22 deletions

View File

@@ -21,13 +21,11 @@ setup:
setup-rust-tools:
@echo "📦 Installing Rust dependencies..."
cargo fetch
@echo "🔧 Installing cargo tools..."
cargo install --locked
# Setup frontend dependencies
setup-frontend:
@echo "📦 Installing frontend dependencies..."
cd frontend && bun install
cd apps/nxmesh-frontend && bun install
# =============================================================================
# Development Commands
@@ -48,7 +46,7 @@ dev-backend:
# Start Vite frontend development server
dev-frontend:
@echo "⚛️ Starting Vite frontend..."
cd frontend && bun dev
cd apps/nxmesh-frontend && bun dev
# Start services (called by devcontainer post-start)
start-services:
@@ -73,20 +71,23 @@ build-backend:
# Build frontend and embed into backend
build-frontend:
@echo "⚛️ Building frontend..."
cd frontend && bun run build
cd apps/nxmesh-frontend && bun run build
@echo "📦 Embedding frontend into backend static files..."
mkdir -p dist
cp -r frontend/dist/* dist/ 2>/dev/null || true
mkdir -p apps/nxmesh-master/dist
cp -r apps/nxmesh-frontend/dist/* apps/nxmesh-master/dist/ 2>/dev/null || true
# =============================================================================
# Database Commands
# =============================================================================
db *ARGS:
cd crates && sea-orm-cli {{ARGS}}
# Setup database
db-setup:
@echo "🐘 Setting up PostgreSQL database..."
just db-wait
sea-orm-cli setup 2>/dev/null || true
cd crates && sea-orm-cli setup 2>/dev/null || true
just db-migrate
# Wait for database to be ready
@@ -98,23 +99,34 @@ db-wait:
# Run database migrations
db-migrate:
@echo "🔄 Running database migrations..."
sea-orm-cli migrate up
cd crates && sea-orm-cli migrate up
# Create new database migration
db-new-migration name:
@echo "📝 Creating new migration: {{name}}"
sea-orm-cli migrate generate {{name}}
@echo "📝 Creating new migration: {{ name }}"
cd crates && sea-orm-cli migrate generate {{ name }}
# Reset database (drop and recreate)
db-reset:
@echo "⚠️ Resetting database..."
sea-orm-cli database reset
cd crates && sea-orm-cli database reset
# Connect to database with psql
db-console:
@echo "🐘 Connecting to PostgreSQL..."
psql $DATABASE_URL
# Generate SeaORM entities from database schema
db-generate:
@echo "⚙️ Generating SeaORM entities from database..."
cd crates && sea-orm-cli generate entity \
--database-url $DATABASE_URL \
--output-dir ../apps/nxmesh-master/src/db/entities \
--with-serde both \
--with-copy-enums \
--date-time-crate chrono
@echo "✅ Entities generated at apps/nxmesh-master/src/db/entities/"
# =============================================================================
# Testing Commands
# =============================================================================
@@ -133,7 +145,7 @@ test-backend:
# Run frontend tests
test-frontend:
@echo "⚛️ Running frontend tests..."
cd frontend && bun test
cd apps/nxmesh-frontend && bun test
# =============================================================================
# Lint & Format Commands
@@ -153,7 +165,7 @@ fmt-rust:
# Format frontend code
fmt-frontend:
@echo "⚛️ Formatting frontend..."
cd frontend && bun run format
cd apps/nxmesh-frontend && bun run format
# Lint all code
lint:
@@ -169,7 +181,7 @@ lint-rust:
# Lint frontend code
lint-frontend:
@echo "⚛️ Linting frontend..."
cd frontend && bun run lint
cd apps/nxmesh-frontend && bun run lint
# =============================================================================
# Docker Commands
@@ -195,9 +207,10 @@ nginx-reload:
bash .devcontainer/scripts/nginx-reload.sh
# Full nginx control via shared PID namespace
# Usage: just nginx-ctl <reload|stop|quit|reopen|upgrade|status>
nginx-ctl cmd="reload":
@bash .devcontainer/scripts/nginx-ctl.sh {{cmd}}
@bash .devcontainer/scripts/nginx-ctl.sh {{ cmd }}
# Quick status check
nginx-status:
@@ -233,8 +246,8 @@ nginx-update:
clean:
@echo "🧹 Cleaning build artifacts..."
cargo clean
cd frontend && rm -rf dist node_modules bun.lockb
rm -rf dist
cd apps/nxmesh-frontend && rm -rf dist node_modules bun.lockb
rm -rf apps/nxmesh-master/dist
# Full clean (includes database)
clean-all: clean
@@ -245,7 +258,7 @@ clean-all: clean
update:
@echo "📦 Updating dependencies..."
cargo update
cd frontend && bun update
cd apps/nxmesh-frontend && bun update
# Check project health
health:
@@ -264,3 +277,37 @@ logs:
docs:
@echo "📚 Generating documentation..."
cargo doc --open 2>/dev/null || cargo doc
# =============================================================================
# API Client Generation Commands
# =============================================================================
# Generate OpenAPI spec from backend (requires backend to be running)
gen-openapi:
@echo "📋 Generating OpenAPI spec from backend..."
@curl -s http://localhost:8080/api/openapi.json > /tmp/openapi.json
@echo "✅ OpenAPI spec saved to /tmp/openapi.json"
# Generate TypeScript API client from OpenAPI spec
gen-api-client:
@echo "⚡ Generating TypeScript API client..."
@if [ ! -f /tmp/openapi.json ]; then \
echo "❌ OpenAPI spec not found. Run 'just gen-openapi' first (backend must be running)."; \
exit 1; \
fi
cd apps/nxmesh-frontend && bunx openapi-typescript /tmp/openapi.json -o src/api/schema.ts
@echo "✅ API client generated at apps/nxmesh-frontend/src/api/schema.ts"
# Full API generation workflow (start backend, generate spec, generate client, stop backend)
gen-api: start-backend-temp
@just gen-openapi
@just gen-api-client
@echo "✅ API client generation complete!"
# Internal: Start backend temporarily for API generation
start-backend-temp:
@echo "🔧 Starting backend temporarily..."
@cargo build --package nxmesh-master
@cargo run --package nxmesh-master &
@sleep 5
@echo "✅ Backend ready"