refactor: flatten monorepo structure to backend/ frontend/ devops/
Rename subdirectories for a cleaner single-repo layout: - website-monitoring-backend/ → backend/ - website-monitoring-frontend/ → frontend/ - website-monitoring-devops/ → devops/ Update all references in package.json scripts, CI workflows, docker-compose, pre-commit hooks, and documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@@ -4,16 +4,16 @@ on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
paths:
|
||||
- "website-monitoring-backend/**"
|
||||
- "backend/**"
|
||||
- ".github/workflows/backend.yml"
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "website-monitoring-backend/**"
|
||||
- "backend/**"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: website-monitoring-backend
|
||||
working-directory: backend
|
||||
|
||||
jobs:
|
||||
lint-test-build:
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
cache-dependency-path: website-monitoring-backend/package-lock.json
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
@@ -52,5 +52,5 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: backend-coverage
|
||||
path: website-monitoring-backend/coverage/
|
||||
path: backend/coverage/
|
||||
retention-days: 7
|
||||
|
||||
@@ -15,17 +15,17 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build all services
|
||||
run: docker compose -f website-monitoring-devops/docker-compose.yml build
|
||||
run: docker compose -f devops/docker-compose.yml build
|
||||
|
||||
- name: Start services
|
||||
run: |
|
||||
docker compose -f website-monitoring-devops/docker-compose.yml up -d db backend
|
||||
docker compose -f devops/docker-compose.yml up -d db backend
|
||||
sleep 15
|
||||
|
||||
- name: Verify backend health
|
||||
run: |
|
||||
docker compose -f website-monitoring-devops/docker-compose.yml exec -T backend curl -f http://localhost:5000/health || exit 1
|
||||
docker compose -f devops/docker-compose.yml exec -T backend curl -f http://localhost:5000/health || exit 1
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: docker compose -f website-monitoring-devops/docker-compose.yml down -v
|
||||
run: docker compose -f devops/docker-compose.yml down -v
|
||||
|
||||
@@ -4,16 +4,16 @@ on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
paths:
|
||||
- "website-monitoring-frontend/**"
|
||||
- "frontend/**"
|
||||
- ".github/workflows/frontend.yml"
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "website-monitoring-frontend/**"
|
||||
- "frontend/**"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: website-monitoring-frontend
|
||||
working-directory: frontend
|
||||
|
||||
jobs:
|
||||
lint-test-build:
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
cache-dependency-path: website-monitoring-frontend/package-lock.json
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check if backend files changed
|
||||
if git diff --cached --name-only | grep -q "^website-monitoring-backend/"; then
|
||||
if git diff --cached --name-only | grep -q "^backend/"; then
|
||||
echo "🔍 Linting backend..."
|
||||
cd website-monitoring-backend && npx eslint src/ || exit 1
|
||||
cd backend && npx eslint src/ || exit 1
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Check if frontend files changed
|
||||
if git diff --cached --name-only | grep -q "^website-monitoring-frontend/"; then
|
||||
if git diff --cached --name-only | grep -q "^frontend/"; then
|
||||
echo "🔍 Linting frontend..."
|
||||
cd website-monitoring-frontend && npx next lint || exit 1
|
||||
cd frontend && npx next lint || exit 1
|
||||
cd ..
|
||||
fi
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ cd website-monitoring
|
||||
npm install
|
||||
|
||||
# Install project dependencies
|
||||
cd website-monitoring-backend && npm install && cd ..
|
||||
cd website-monitoring-frontend && npm install && cd ..
|
||||
cd backend && npm install && cd ..
|
||||
cd frontend && npm install && cd ..
|
||||
|
||||
# Start everything
|
||||
npm run dev
|
||||
@@ -71,8 +71,8 @@ npm run dev
|
||||
|
||||
## Testing
|
||||
|
||||
- **Backend**: Jest + Supertest — `cd website-monitoring-backend && npm test`
|
||||
- **Frontend**: Jest + Testing Library — `cd website-monitoring-frontend && npm test`
|
||||
- **Backend**: Jest + Supertest — `cd backend && npm test`
|
||||
- **Frontend**: Jest + Testing Library — `cd frontend && npm test`
|
||||
- Aim for tests on all API endpoints and critical business logic
|
||||
- Use meaningful test names: `it("should return 400 when URL is missing")`
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ cd website-monitoring
|
||||
npm install
|
||||
|
||||
# Setup backend
|
||||
cd website-monitoring-backend
|
||||
cd backend
|
||||
cp .env.example .env
|
||||
npm install
|
||||
npm run build
|
||||
cd ..
|
||||
|
||||
# Setup frontend
|
||||
cd website-monitoring-frontend
|
||||
cd frontend
|
||||
cp .env.example .env # Fill in your Supabase keys
|
||||
npm install
|
||||
cd ..
|
||||
@@ -109,7 +109,7 @@ npm run docker:up
|
||||
|
||||
```
|
||||
website-monitoring/
|
||||
├── website-monitoring-backend/ # Express.js API + Lighthouse engine
|
||||
├── backend/ # Express.js API + Lighthouse engine
|
||||
│ ├── src/
|
||||
│ │ ├── index.ts # Server entry, health check, routing
|
||||
│ │ └── routes/
|
||||
@@ -117,7 +117,7 @@ website-monitoring/
|
||||
│ ├── Dockerfile
|
||||
│ └── package.json
|
||||
│
|
||||
├── website-monitoring-frontend/ # Next.js 15 dashboard
|
||||
├── frontend/ # Next.js 15 dashboard
|
||||
│ ├── src/
|
||||
│ │ ├── app/ # Pages & API routes (20+ endpoints)
|
||||
│ │ ├── components/ # React components (dashboard, UI, auth)
|
||||
@@ -126,7 +126,7 @@ website-monitoring/
|
||||
│ ├── Dockerfile
|
||||
│ └── package.json
|
||||
│
|
||||
├── website-monitoring-devops/ # Infrastructure
|
||||
├── devops/ # Infrastructure
|
||||
│ ├── docker-compose.yml # Full stack orchestration
|
||||
│ └── .devcontainer/ # VS Code Dev Container config
|
||||
│
|
||||
|
||||
@@ -21,7 +21,7 @@ echo " ✅ Node $(node --version), Docker, Supabase CLI found"
|
||||
# 2. Start Supabase (if not already running)
|
||||
echo ""
|
||||
echo -e "${YELLOW}[2/6] Starting local Supabase...${NC}"
|
||||
cd website-monitoring-frontend
|
||||
cd frontend
|
||||
if supabase status 2>&1 | grep -q "API URL"; then
|
||||
echo " ✅ Supabase already running"
|
||||
else
|
||||
@@ -50,32 +50,32 @@ SUPABASE_SERVICE_ROLE_KEY=${SERVICE_KEY}
|
||||
LIGHTHOUSE_SERVICE_URL=http://localhost:5000
|
||||
CRON_SECRET=local-dev-secret
|
||||
EOF
|
||||
echo " ✅ Created website-monitoring-frontend/.env.local"
|
||||
echo " ✅ Created frontend/.env.local"
|
||||
cd ..
|
||||
|
||||
# 4. Create backend .env
|
||||
echo ""
|
||||
echo -e "${YELLOW}[4/6] Configuring backend environment...${NC}"
|
||||
cat > website-monitoring-backend/.env << EOF
|
||||
cat > backend/.env << EOF
|
||||
PORT=5000
|
||||
CORS_ORIGIN=http://localhost:3000
|
||||
NODE_ENV=development
|
||||
EOF
|
||||
echo " ✅ Created website-monitoring-backend/.env"
|
||||
echo " ✅ Created backend/.env"
|
||||
|
||||
# 5. Install dependencies
|
||||
echo ""
|
||||
echo -e "${YELLOW}[5/6] Installing dependencies...${NC}"
|
||||
npm install --silent 2>/dev/null
|
||||
cd website-monitoring-backend && npm install --silent 2>/dev/null && cd ..
|
||||
cd website-monitoring-frontend && npm install --silent 2>/dev/null && cd ..
|
||||
cd backend && npm install --silent 2>/dev/null && cd ..
|
||||
cd frontend && npm install --silent 2>/dev/null && cd ..
|
||||
echo " ✅ Dependencies installed"
|
||||
|
||||
# 6. Run database migrations
|
||||
echo ""
|
||||
echo -e "${YELLOW}[6/6] Applying database migrations...${NC}"
|
||||
cd website-monitoring-frontend
|
||||
supabase db reset --no-seed 2>/dev/null || echo " ⚠️ Migrations may need manual review (run: cd website-monitoring-frontend && supabase db reset)"
|
||||
cd frontend
|
||||
supabase db reset --no-seed 2>/dev/null || echo " ⚠️ Migrations may need manual review (run: cd frontend && supabase db reset)"
|
||||
cd ..
|
||||
|
||||
echo ""
|
||||
@@ -92,7 +92,7 @@ echo -e "${YELLOW}📋 Quick commands:${NC}"
|
||||
echo " npm test — run all tests"
|
||||
echo " npm run build — build everything"
|
||||
echo " npm run lint — lint everything"
|
||||
echo " supabase stop — stop local DB (in website-monitoring-frontend/)"
|
||||
echo " supabase stop — stop local DB (in frontend/)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}🔑 Test cron endpoints locally:${NC}"
|
||||
echo " curl -H 'Authorization: Bearer local-dev-secret' http://localhost:3000/api/cron/uptime"
|
||||
|
||||
@@ -18,7 +18,7 @@ services:
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ../website-monitoring-backend
|
||||
context: ../backend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
@@ -41,7 +41,7 @@ services:
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ../website-monitoring-frontend
|
||||
context: ../frontend
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
@@ -25,7 +25,7 @@ This project is a modern website monitoring platform built with Next.js (App Rou
|
||||
### 1. Install Dependencies
|
||||
|
||||
```bash
|
||||
cd website-monitoring-frontend
|
||||
cd frontend
|
||||
npm install
|
||||
```
|
||||
|
||||
@@ -47,6 +47,6 @@ This will:
|
||||
In a separate terminal:
|
||||
|
||||
```bash
|
||||
cd website-monitoring-frontend
|
||||
cd frontend
|
||||
npm run dev
|
||||
```
|
||||
|
Before Width: | Height: | Size: 391 B After Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 425 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 128 B |
|
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |