diff --git a/README.md b/README.md index c7e79b9..c5d146b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # News Benchmark -A benchmark that tests how local language models perform on real world software engineering tasks. +A benchmark that tests how local language models perform on real world software engineering tasks. ## The challenge: @@ -8,7 +8,7 @@ Make and maintain a news web application. ## Structure -Most real applications, are not made in a single shot. This benchmark reflects this by simulating tickets as milestones. Each mile stone is a separate markdown file, containing a prompt, description, acceptance criteria, technical details, and QA notes. +Most real applications, are not made in a single shot. This benchmark reflects this by simulating tickets as milestones. Each milestone is a separate markdown file, containing prompt, description, acceptance criteria, technical details, and QA notes. ## Scoring @@ -19,30 +19,14 @@ The model performing the benchmark will be scored against the acceptance criteri | 0 | Agent failed to implement acceptance criteria | | 1 | Agent partially implemented acceptance criteria that builds successfully | | 2 | Agent fully implemented acceptance criteria that builds successfully | -| 3 | Agent fully implemented acceptance criteria that builds successfully, includes passing unit/integration tests with 50% code coverate -| 4 | Agent fully implemented acceptance criteria that builds successfully, includes passing unit/integration tests, passing end to end tests, with 80% code coverate | -| 5 | Agent fully implemented acceptance criteria that builds successfully, , includes passing unit/integration tests, and passing end to end tests with 100% code coverate | +| 3 | Agent fully implemented acceptance criteria that builds successfully, includes passing unit/integration tests with 50% code coverage | +| 4 | Agent fully implemented acceptance criteria that builds successfully, includes passing unit/integration tests, passing end-to-end tests, with 80% code coverage | +| 5 | Agent fully implemented acceptance criteria that builds successfully, includes passing unit/integration tests, and passing end-to-end tests with 100% code coverage | ## Milestones This benchmark consists of multiple milestones, each representing a separate task: -### M1: Git Repository Setup -## Milestones - -This benchmark consists of multiple milestones, each representing a separate task: - -### M1: Git Repository Setup -- [M1 - Setup Git Project](milestone/m1-setup-git-project-prompt.md) -- [M1 - Setup Git Project Scoring](milestone/m1-setup-git-project-scoring.md) - -### M2: Backend Infrastructure -- [M2 - Setup Backend](milestone/m2-setup-backend-prompt.md) -- [M2 - Setup Backend Scoring](milestone/m2-setup-backend-scoring.md) - -### M3: Frontend Application -This benchmark consists of multiple milestones, each representing a separate task: - ### M1: Git Repository Setup - [M1 - Setup Git Project](milestone/m1-setup-git-project-prompt.md) - [M1 - Setup Git Project Scoring](milestone/m1-setup-git-project-scoring.md) @@ -55,12 +39,15 @@ This benchmark consists of multiple milestones, each representing a separate tas - [M3 - Setup Frontend](milestone/m3-setup-frontend-prompt.md) - [M3 - Setup Frontend Scoring](milestone/m3-setup-frontend-scoring.md) -## Context management +### M4: Developer Environment +- [M4 - Setup Developer Environment](milestone/m4-setup-developer-environment-prompt.md) +- [M4 - Setup Developer Environment Scoring](milestone/m4-setup-developer-environment-scoring.md) -After each milestone the agents context MUST be cleared. This test the models reasoning capabilities and how it performs with incomplete information. +## Context Management +After each milestone the agents context MUST be cleared. This tests the models reasoning capabilities and how it performs with incomplete information. -## Tech stack variations +## Tech Stack Variations ### Python - **Backend:** Python, FastAPI, SQLAlchemy, SQLite (data persisted in a Docker volume) diff --git a/milestone/m4-setup-developer-environment-prompt.md b/milestone/m4-setup-developer-environment-prompt.md new file mode 100644 index 0000000..6858de1 --- /dev/null +++ b/milestone/m4-setup-developer-environment-prompt.md @@ -0,0 +1,372 @@ +# M4: Setup Developer Environment + +## Prompt + +Set up a complete developer environment for **newzy** news web application with Docker Compose orchestration. Follow these steps: + +1. Create `docker-compose.yml` at project root (`newzy/docker-compose.yml`) with all services: + ```yaml + version: '3.8' + + services: + backend: + build: ./backend + ports: + - "8000:8000" + volumes: + - ./data/db:/app/data/db + environment: + - DATABASE_URL=sqlite:///./data/db/newzy.db + - DEBUG=false + + frontend: + build: ./frontend + ports: + - "3000:80" + depends_on: + - backend + + networks: + newzy-network: + driver: bridge + + volumes: + db-data: + ``` + +2. Create `.env.example` file documenting all required environment variables: + - DATABASE_URL (SQLite path) + - DEBUG (boolean, optional) + - BACKEND_CORS_ORIGINS (comma-separated, default: http://localhost:3000) + - FRONTEND_API_URL (relative /api or absolute) + +3. Create `.env` file with default development values: + ```bash + DATABASE_URL=sqlite:///./data/db/newzy.db + DEBUG=false + BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:5173 + FRONTEND_API_URL=/api + ``` + +4. Update `backend/.gitignore` to exclude `.env` and production data: + ```python + .env + .env.* + data/ + ``` + +5. Create development scripts in project root using Makefile or shell script: + - `dev` - Start both services in background + - `stop` - Stop all services + - `restart` - Restart all services + - `backend-start` - Start backend only + - `frontend-start` - Start frontend only + - `test` - Run all tests (unit + E2E) + - `clean` - Remove containers and volumes + +6. Add `Makefile` for command shortcuts: + ```makefile + .PHONY: dev stop restart backend-start frontend-start test clean + + dev: + docker compose up -d --build + + stop: + docker compose down + + restart: + docker compose down + docker compose up -d --build + + backend-start: + docker compose up -d backend + + frontend-start: + docker compose up -d frontend + + test: + npm run test # frontend + cd backend && pytest # backend + + clean: + docker compose down -v + rm -rf data/ + docker image prune -f + ``` + +7. Create `backend/Dockerfile` with development optimizations: + - Copy only required files + - Install dependencies efficiently + - Use slim Python base image + - Expose port 8000 + +8. Update `frontend/Dockerfile` to use production Nginx: + - Multi-stage build (build stage + nginx serve stage) + - Nginx configuration for SPA routing + - Production-optimized static file serving + +9. Create `.gitignore` at project root excluding: + ``` + # Dependencies + node_modules/ + *.egg-info/ + + # Environment files + .env + .env.local + .env.*.local + + # IDE settings + .idea/ + .vscode/ + *.swp + *.swo + + # Docker artifacts (optional) + .dockerignore + docker-compose.override.yml + ``` + +10. Create `data/.gitignore` to exclude SQLite database from version control: + ``` + * + !keep_files.txt + ``` + +11. Document setup process in `README.md`: + - Prerequisites (Docker, Node.js 18+) + - Quick start commands + - Service descriptions + - Port mappings + - Network configuration + - Troubleshooting guide + +12. Create `.dockerignore` files for both backend and frontend to exclude unnecessary files during builds: + ``` + .git/ + .env + __pycache__/ + *.pyc + node_modules/ + dist/ + .pytest_cache/ + ``` + +Remember: Focus ONLY on developer environment setup. No application code changes required. + +## Description + +This milestone sets up a complete Docker Compose development environment for the newzy news web application. The scope includes orchestrating both backend and frontend services, environment variable management, and streamlined development commands—no application logic changes or business feature implementation. + +**Purpose**: Provide developers with a consistent, reproducible local development environment using Docker that matches the production setup as closely as possible. + +**Target Audience**: Developers joining the project who need quick access to running services without manual installation of Python, Node.js, databases, or Nginx. + +**Expected Outcomes**: A working docker-compose.yml at project root that can start all services with a single command, proper environment configuration, and development workflow automation via Makefile. + +## Acceptance Criteria + +- [ ] `docker-compose.yml` at project root configures both backend and frontend services +- [ ] Backend service builds from `./backend` directory +- [ ] Frontend service builds from `./frontend` directory +- [ ] Port mappings configured: 3000 for frontend, 8000 for backend +- [ ] Docker network defined for inter-service communication +- [ ] Volume mounted for persistent SQLite database at `/data/db` +- [ ] `.env.example` file documents all environment variables +- [ ] `.env` file provides default development configuration +- [ ] `backend/Dockerfile` optimized for production use +- [ ] `frontend/Dockerfile` uses multi-stage build with Nginx +- [ ] Makefile or shell scripts provide dev, stop, restart commands +- [ ] `data/.gitignore` excludes database from version control +- [ ] `.dockerignore` files exist for both frontend and backend +- [ ] Project root `.gitignore` excludes env files and build artifacts +- [ ] README.md documents docker setup with quick start guide + +## Technical Details + +### docker-compose.yml (Project Root) + +```yaml +version: '3.8' + +services: + backend: + build: + context: ./backend + dockerfile: Dockerfile + ports: + - "8000:8000" + volumes: + - ./data/db:/app/data/db + environment: + - DATABASE_URL=sqlite:///./data/db/newzy.db + - DEBUG=false + - BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:5173 + depends_on: + backend-db: + condition: service_healthy + networks: + - newzy-network + restart: unless-stopped + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + ports: + - "3000:80" + depends_on: + - backend + networks: + - newzy-network + restart: unless-stopped + +networks: + newzy-network: + driver: bridge + ipam: + config: + - subnet: 172.28.0.0/16 + +volumes: + db-data: + name: newzy-db-data +``` + +### Environment Variables (.env.example) + +| Variable | Description | Default | Required | +|----------|-------------|---------|----------| +| DATABASE_URL | SQLite database path | sqlite:///./data/db/newzy.db | Yes | +| DEBUG | Debug mode flag | false | No | +| BACKEND_CORS_ORIGINS | Allowed frontend origins | http://localhost:3000 | No | +| FRONTEND_API_URL | Backend API base URL | /api | No | + +### Development Commands (Makefile) + +```makefile +.PHONY: dev stop restart test clean build + +dev: + docker compose up -d --build backend frontend + +stop: + docker compose down + +restart: + docker compose down + docker compose up -d --build backend frontend + +test: + @echo "Running frontend tests..." + npm run test + @echo "Running backend tests..." + docker exec frontend npm run test || \ + docker exec backend pytest + +clean: + docker compose down -v + rm -rf data/ + docker images | grep -E "(newzy|python|node)" | awk '{print $$3}' | xargs docker rmi + +build: + docker compose build --no-cache + +logs: + docker compose logs -f backend frontend + +shell-backend: + docker exec -it backend bash + +shell-frontend: + docker exec -it frontend sh +``` + +### Directory Structure with Docker Setup + +``` +newzy/ +├── data/ # Local SQLite data directory +│ └── db/ +│ └── newzy.db # Persisted database (excluded from git) +├── backend/ +│ ├── Dockerfile +│ ├── requirements.txt +│ ├── .gitignore +│ └── pytest.ini +├── frontend/ +│ ├── Dockerfile +│ ├── docker-compose.yml # Frontend-specific override (optional) +│ └── package.json +├── docker-compose.yml # Main orchestration file +├── .env # Development environment variables +├── .env.example # Template for .env +├── Makefile # Development shortcuts +├── .dockerignore # Exclude files from build context +└── data/.gitignore # Exclude database from git +``` + +### Multi-stage Build Strategy + +**Backend Dockerfile:** +- Base: `python:3.11-slim` +- Install dependencies with `pip install --no-cache-dir` +- Copy only production code and requirements +- Expose port 8000 + +**Frontend Dockerfile:** +- Stage 1: `node:20-alpine` → Build frontend with Vite +- Stage 2: `nginx:alpine` → Serve built static files +- Nginx config routes all requests to index.html for SPA + +### Service Communication Flow + +``` +Browser (localhost:3000) + ↓ HTTP Request +Frontend Container (newzy-network:80) + ↓ Forwarded to /api +Backend Container (newzy-network:8000) + ↓ Connects to SQLite +Volume: data/db/newzy.db +``` + +## QA Notes + +### Testing Checklist +- [ ] `docker compose up` starts both services without errors +- [ ] Frontend accessible at http://localhost:3000 +- [ ] Backend accessible at http://localhost:8000 +- [ ] Health endpoints respond correctly +- [ ] Database persists across service restarts +- [ ] `.env.example` contains all documented variables +- [ ] Makefile commands work (dev, stop, restart, clean) +- [ ] `data/` directory excluded from git commits +- [ ] `.gitignore` excludes environment files + +### Security Considerations +- Never commit `.env` file to version control +- Use `.env.example` as template for new developers +- SQLite database stored locally, not in container (volume mounted) +- CORS configured with specific origins +- No production secrets exposed by default + +### Performance Notes +- `--build` flag only when needed (avoid rebuilds on dev) +- Docker cache leveraged for incremental builds +- SQLite file storage faster than network databases for development +- Nginx serves static files efficiently in production + +### Known Limitations +- Requires Docker Desktop or equivalent installed locally +- Mac users need sufficient disk space (~50GB recommended) +- Windows WSL2 required for best performance +- No GPU acceleration (CPU-based only) +- Production databases should use PostgreSQL, not SQLite + +### Success Metrics +- `docker compose up` completes in under 5 minutes on first run +- Services restart within 10 seconds subsequent runs +- Development environment identical to staging/production setup +- Zero manual configuration required for new developers +- Makefile shortcuts reduce repetitive Docker commands diff --git a/milestone/m4-setup-developer-environment-scoring.md b/milestone/m4-setup-developer-environment-scoring.md new file mode 100644 index 0000000..3d73a07 --- /dev/null +++ b/milestone/m4-setup-developer-environment-scoring.md @@ -0,0 +1,86 @@ +# M4: Setup Developer Environment - Scoring Rubric + +## Acceptance Criteria Scoring Table + +| Score | Criteria | +|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 0 | Agent failed to implement acceptance criteria:
- No docker-compose.yml or incomplete
- Missing both frontend and backend services
- No environment configuration
- Commands don't work at all | +| 1 | Agent partially implemented acceptance criteria that builds successfully:
- Basic docker-compose with one service only
- Missing volume configuration
- .env.example or .env missing
- Makefile incomplete | +| 2 | Agent fully implemented acceptance criteria that builds successfully:
- docker-compose.yml configures backend AND frontend services
- Port mappings for both services (3000, 8000)
- Docker network defined for inter-service communication- dev command (up -d --build)
- stop command (down)
- restart command (down then up -d)
- test command running both unit and E2E tests- Cannot build any service +- **1 pt**: docker-compose.yml exists but only defines one service
- Other service referenced but not built +- **2 pts**: Both backend and frontend services defined with correct build contexts
- Port mappings configured (3000, 8000)
- Networks section present with bridge driver +- **3 pts**: Service dependencies configured correctly (frontend depends on backend)
- Volume configuration for database persistence +- **4 pts**: Full service orchestration with restart policies and health checks + +### Environment Configuration (Max 3 points) +- **0 pts**: No .env or .env.example files
- Hardcoded credentials in source code +- **1 pt**: Only .env file exists but no documentation
- Variables not clearly explained +- **2 pts**: Both .env and .env.example present with all required variables
- Clear default values for development +- **3 pts**: Comprehensive documentation table for each environment variable- Manual docker compose required for everything +- **1 pt**: Basic stop command only
- No dev or restart automation +- **2 pts**: dev, stop, and restart commands functional
- Uses docker compose correctly +- **3 pts**: Backend-start and frontend-start individual service commands
- build command available +- **4 pts**: test command runs both frontend and backend tests- No docker security configuration +- **1 pt**: Basic .gitignore but doesn't exclude all sensitive files
- Volumes not properly configured +- **2 pts**: .gitignore excludes .env, *.local, data/ directory
- Proper volume mounting for SQLite +- **3 pts**: All security best practices followed- Missing docker setup instructions +- **1 pt**: Basic README mentions docker-compose exists
- No quick start guide +- **2 pts**: README documents all required prerequisites (Docker, Node.js)
- Port mappings and service descriptions included +- **3 pts**: Complete troubleshooting guide with common issues and solutions
- Network configuration explained + +### Service Communication (Max 2 points) +- **0 pts**: Services cannot communicate
- Different network configurations or missing networks +- **1 pt**: Basic networking but CORS or API calls fail
- Services on separate isolated networks +- **2 pts**: Docker bridge network properly configured
- Inter-service communication verified via health endpoints + +### Build Optimization (Max 3 points) +- **0 pts**: docker-compose.yml lacks build optimizations
- Dockerfiles include unnecessary files +- **1 pt**: Basic multi-stage builds missing
- Large images (>500MB for simple apps) +- **2 pts**: Backend uses slim Python image with no-cache pip install