Full Stack Development - jvPalma/dotrun GitHub Wiki
Complete workflow guide for web development teams using React frontend, Node.js backend, and PostgreSQL database.
- 3 Frontend developers
- 2 Backend developers
- 1 Full-stack developer
- 1 DevOps engineer
Repository: company/fullstack-tools
# Initialize collection
mkdir fullstack-tools && cd fullstack-tools
dr export . fullstack-tools --git
# Create collection structure
mkdir -p bin/{frontend,backend,database,deployment}
mkdir -p docs/{frontend,backend,database,deployment}
mkdir -p helpersCollection Metadata (dotrun.collection.yml):
name: "fullstack-tools"
description: "Complete web development workflow tools"
author: "Development Team"
version: "1.0.0"
dependencies:
- node
- npm
- docker
- git
- psql
optional_dependencies:
- yarn
- docker-compose
- heroku
categories:
- frontend
- backend
- database
- deploymentbin/frontend/dev-server.sh:
#!/usr/bin/env bash
### DOC
# Start React development server with hot reload
# Includes environment setup and dependency checks
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg node npm
main() {
if [[ ! -f "package.json" ]]; then
echo "โ No package.json found. Run from React project root."
exit 1
fi
echo "๐ Starting React development server..."
# Install dependencies if node_modules missing
if [[ ! -d "node_modules" ]]; then
echo "๐ฆ Installing dependencies..."
npm install
fi
# Start development server
BROWSER=none npm start
echo "โ
Development server started at http://localhost:3000"
}
main "$@"bin/frontend/build-production.sh:
#!/usr/bin/env bash
### DOC
# Build optimized production React bundle
# Includes bundle analysis and size warnings
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg node npm
main() {
echo "๐๏ธ Building production React app..."
# Clean previous build
rm -rf build/
# Build with production optimizations
NODE_ENV=production npm run build
# Show build info
echo "๐ Build completed!"
echo "๐ Build size:"
du -sh build/
# Check for large files
echo "๐ Large files (>500KB):"
find build/ -size +500k -type f -exec ls -lh {} \; | awk '{ print $5 "\t" $9 }'
echo "โ
Production build ready in build/ directory"
}
main "$@"bin/frontend/run-tests.sh:
#!/usr/bin/env bash
### DOC
# Run comprehensive frontend test suite
# Includes unit tests, integration tests, and coverage
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg node npm
main() {
local test_type="${1:-all}"
echo "๐งช Running frontend tests: $test_type"
case "$test_type" in
unit)
npm run test:unit -- --coverage
;;
integration)
npm run test:integration
;;
e2e)
npm run test:e2e
;;
all | *)
echo "๐ฌ Running unit tests..."
npm run test:unit -- --coverage
echo "๐ Running integration tests..."
npm run test:integration
echo "๐ Running E2E tests..."
npm run test:e2e
;;
esac
echo "โ
Frontend tests completed!"
}
main "$@"bin/backend/dev-server.sh:
#!/usr/bin/env bash
### DOC
# Start Node.js backend with auto-restart
# Includes database connection check
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg node npm
main() {
if [[ ! -f "server.js" && ! -f "app.js" && ! -f "index.js" ]]; then
echo "โ No main server file found"
exit 1
fi
echo "๐ Starting Node.js development server..."
# Check database connection
if ! dr backend/check-db-connection; then
echo "โ ๏ธ Database connection failed, starting anyway..."
fi
# Install dependencies
if [[ ! -d "node_modules" ]]; then
npm install
fi
# Start with nodemon for auto-restart
if command -v nodemon >/dev/null; then
nodemon server.js
else
echo "๐ก Tip: Install nodemon for auto-restart: npm install -g nodemon"
node server.js
fi
}
main "$@"bin/backend/check-db-connection.sh:
#!/usr/bin/env bash
### DOC
# Verify database connection and schema
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg psql
main() {
local db_url="${DATABASE_URL:-postgresql://localhost:5432/myapp}"
echo "๐ Checking database connection..."
if psql "$db_url" -c "SELECT 1;" >/dev/null 2>&1; then
echo "โ
Database connection successful"
# Check if tables exist
local table_count
table_count=$(psql "$db_url" -t -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';" | xargs)
echo "๐ Found $table_count tables in database"
return 0
else
echo "โ Database connection failed"
echo "๐ก Check DATABASE_URL: $db_url"
return 1
fi
}
main "$@"bin/backend/test-api.sh:
#!/usr/bin/env bash
### DOC
# Test API endpoints with comprehensive checks
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg curl jq
main() {
local base_url="${1:-http://localhost:3001}"
echo "๐ Testing API endpoints at $base_url"
# Health check
echo "๐ฅ Checking health endpoint..."
if curl -s "$base_url/health" | jq -e '.status == "ok"' >/dev/null; then
echo "โ
Health check passed"
else
echo "โ Health check failed"
return 1
fi
# Test authentication
echo "๐ Testing authentication..."
local token
token=$(curl -s -X POST "$base_url/auth/login" \
-H "Content-Type: application/json" \
-d '{"username":"test","password":"test"}' | jq -r '.token')
if [[ "$token" != "null" && -n "$token" ]]; then
echo "โ
Authentication successful"
else
echo "โ Authentication failed"
return 1
fi
# Test protected endpoint
echo "๐ก๏ธ Testing protected endpoint..."
if curl -s "$base_url/api/user" \
-H "Authorization: Bearer $token" | jq -e '.id' >/dev/null; then
echo "โ
Protected endpoint accessible"
else
echo "โ Protected endpoint failed"
return 1
fi
echo "โ
All API tests passed!"
}
main "$@"bin/database/setup-dev.sh:
#!/usr/bin/env bash
### DOC
# Set up development database with sample data
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg psql docker
main() {
local db_name="${1:-myapp_dev}"
echo "๐๏ธ Setting up development database: $db_name"
# Start PostgreSQL with Docker if not running
if ! pgrep -x "postgres" >/dev/null; then
echo "๐ณ Starting PostgreSQL with Docker..."
docker run -d \
--name postgres-dev \
-e POSTGRES_DB="$db_name" \
-e POSTGRES_USER=dev \
-e POSTGRES_PASSWORD=password \
-p 5432:5432 \
postgres:13
echo "โณ Waiting for PostgreSQL to start..."
sleep 5
fi
# Run migrations
if [[ -f "migrations/init.sql" ]]; then
echo "๐ Running migrations..."
psql "postgresql://dev:password@localhost:5432/$db_name" <migrations/init.sql
fi
# Load sample data
if [[ -f "seeds/sample_data.sql" ]]; then
echo "๐ฑ Loading sample data..."
psql "postgresql://dev:password@localhost:5432/$db_name" <seeds/sample_data.sql
fi
echo "โ
Development database ready!"
echo "๐ Connection string: postgresql://dev:password@localhost:5432/$db_name"
}
main "$@"bin/database/migrate.sh:
#!/usr/bin/env bash
### DOC
# Run database migrations with rollback support
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg psql
main() {
local action="${1:-up}"
local db_url="${DATABASE_URL:-postgresql://dev:password@localhost:5432/myapp_dev}"
echo "๐ Running database migrations: $action"
case "$action" in
up)
echo "โฌ๏ธ Applying migrations..."
for migration in migrations/*.up.sql; do
if [[ -f "$migration" ]]; then
echo "๐ Applying $(basename "$migration")"
psql "$db_url" <"$migration"
fi
done
;;
down)
echo "โฌ๏ธ Rolling back migrations..."
for migration in migrations/*.down.sql; do
if [[ -f "$migration" ]]; then
echo "โฉ๏ธ Rolling back $(basename "$migration")"
psql "$db_url" <"$migration"
fi
done
;;
status)
echo "๐ Migration status..."
psql "$db_url" -c "SELECT * FROM schema_migrations ORDER BY version DESC LIMIT 10;"
;;
*)
echo "Usage: dr database/migrate [up|down|status]"
exit 1
;;
esac
echo "โ
Migration $action completed!"
}
main "$@"bin/deployment/deploy-staging.sh:
#!/usr/bin/env bash
### DOC
# Deploy full-stack application to staging environment
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/git.sh"
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg git docker
main() {
echo "๐ Deploying to staging environment..."
# Ensure we're on main branch
local current_branch
current_branch=$(git_current_branch)
if [[ "$current_branch" != "main" ]]; then
echo "โ Must deploy from main branch (currently on $current_branch)"
exit 1
fi
# Build frontend
echo "๐๏ธ Building frontend..."
cd frontend/
dr fullstack/build-production
cd ..
# Build backend Docker image
echo "๐ณ Building backend Docker image..."
docker build -t myapp-backend:staging backend/
# Deploy with docker-compose
echo "๐ฆ Deploying with docker-compose..."
docker-compose -f docker-compose.staging.yml up -d
# Wait for services
echo "โณ Waiting for services to start..."
sleep 30
# Health check
if dr deployment/health-check staging; then
echo "โ
Staging deployment successful!"
echo "๐ Frontend: https://staging.myapp.com"
echo "๐ API: https://api-staging.myapp.com"
else
echo "โ Health check failed"
dr deployment/rollback staging
exit 1
fi
}
main "$@"bin/deployment/health-check.sh:
#!/usr/bin/env bash
### DOC
# Comprehensive health check for deployed application
### DOC
set -euo pipefail
source "$DR_CONFIG/helpers/pkg.sh"
validatePkg curl
main() {
local environment="${1:-staging}"
case "$environment" in
staging)
local frontend_url="https://staging.myapp.com"
local api_url="https://api-staging.myapp.com"
;;
production)
local frontend_url="https://myapp.com"
local api_url="https://api.myapp.com"
;;
*)
echo "โ Unknown environment: $environment"
exit 1
;;
esac
echo "๐ฅ Running health checks for $environment..."
# Check frontend
echo "๐ Checking frontend at $frontend_url..."
if curl -s -f "$frontend_url" >/dev/null; then
echo "โ
Frontend is accessible"
else
echo "โ Frontend health check failed"
return 1
fi
# Check API health endpoint
echo "๐ Checking API at $api_url..."
if curl -s "$api_url/health" | grep -q "ok"; then
echo "โ
API is healthy"
else
echo "โ API health check failed"
return 1
fi
# Check database connectivity
echo "๐๏ธ Checking database connectivity..."
if curl -s "$api_url/health/db" | grep -q "connected"; then
echo "โ
Database is connected"
else
echo "โ Database connectivity check failed"
return 1
fi
echo "โ
All health checks passed for $environment!"
}
main "$@"# Team member imports collection
dr import [email protected]:company/fullstack-tools.git fs
# Start development environment
dr fs/database/setup-dev
dr fs/backend/dev-server &
dr fs/frontend/dev-server
# Run tests before committing
dr fs/frontend/run-tests
dr fs/backend/test-api
# Build and test
dr fs/frontend/build-production
dr fs/backend/run-tests
# Deploy to staging
dr fs/deployment/deploy-staging# Reviewer runs automated checks
dr fs/frontend/run-tests unit
dr fs/backend/test-api http://localhost:3001
dr fs/deployment/health-check staging
# Performance testing
dr fs/frontend/build-production
ls -la frontend/build/ # Check bundle sizes# Final testing
dr fs/frontend/run-tests all
dr fs/backend/test-api
# Deploy to staging for final QA
dr fs/deployment/deploy-staging
dr fs/deployment/health-check staging
# Production deployment (after approval)
dr fs/deployment/deploy-production
dr fs/deployment/health-check productionname: Full-Stack CI/CD
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install DotRun
run: curl -fsSL https://raw.githubusercontent.com/jvPalma/dotrun/master/install.sh | sh
- name: Import team tools
run: dr import . fs
- name: Run frontend tests
run: dr fs/frontend/run-tests
- name: Run backend tests
run: dr fs/backend/test-api
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Deploy to staging
run: dr fs/deployment/deploy-staging- Keep scripts focused on single responsibilities
- Use consistent naming conventions
- Document all environment dependencies
- Include comprehensive error handling
- Regular collection updates with team sync
- Code review for shared scripts
- Consistent environment setup across team
- Documentation maintenance
- Separate configurations for dev/staging/production
- Environment-specific scripts and settings
- Secure credential management
- Automated environment setup
This full-stack workflow provides a complete development pipeline that scales from individual developers to large teams while maintaining consistency and reliability across all environments.