# M4: Setup Developer Environment - Score Report **Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), working tree **Rubric:** `milestone/m4-setup-developer-environment-scoring.md` **Model:** qwen3.5-9b ## Total Score: 13 / 29 base (+1 bonus, 14 with bonus) - Overall level 1 (partial) The level-2 requirement that the implementation "builds successfully" is not met. `docker compose config` rejects the root `docker-compose.yml`, so the stack cannot be brought up as written. ## Verification Performed | Check | Result | |---|---| | `docker compose config -q` (root) | **Fails.** `service "backend" depends on undefined service "backend-db": invalid compose project`. A warning also says the `version` key is obsolete. | | `make -n dev test clean restart` | Expands correctly. The Makefile is syntactically valid. | | `make test` contents | Runs `npm run test` from the **repo root**, where `package.json` has only an `echo` placeholder. It does not run the frontend tests in `frontend/`. Also `cd backend && pytest`. No E2E step. | | Tracked-file check | `backend/Dockerfile`, `backend/.dockerignore`, `frontend/.dockerignore`, and `.env.example` are **not tracked** by git. | | Ignore-rule check | Root `.gitignore` line 57 (`.dockerignore`) matches `backend/.dockerignore` and `frontend/.dockerignore`. Root `**/.env*` matches `.env.example`. `backend/.gitignore` line 14 (`Dockerfile`) matches `backend/Dockerfile`. A fresh clone would lack all of these. | | Backend CORS | `BACKEND_CORS_ORIGINS` and `FRONTEND_API_URL` are not read anywhere in `backend/`. `config.py` defines `CORS_ORIGINS` but `main.py` adds no CORS middleware. | | `docker build` | Not run. | ## Scoring by Criterion | Criterion | Score | Max | Notes | |---|---|---|---| | docker-compose Configuration | 1 | 4 | Both services are defined with the right build contexts, ports 3000 and 8000, a bridge network, a bind-mounted `./data/db` volume, and `restart: unless-stopped`. But the file fails validation: the backend depends on an undefined `backend-db` service, and the frontend waits on `service_healthy` from a backend that has no healthcheck. | | Environment Configuration | 2 | 3 | `.env` and `.env.example` both list the required variables with defaults. `.env.example` is not tracked by git, and it has no per-variable descriptions. The README has the variable table. | | Development Commands | 3 | 4 | `dev`, `stop`, `restart`, `backend-start`, `frontend-start`, `build`, `logs`, `clean`, and shell targets are all present. `test` does not run the frontend tests (it hits the root placeholder) and has no E2E step. `clean` removes volumes and images. | | Security & Best Practices | 2 | 3 | `.env`, `*.local`, and `data/` are excluded from git. The `data/.gitignore` pattern is correct. But `.env.example` and both `.dockerignore` files are excluded by the same rules, so they are not committed. | | Documentation | 3 | 3 | Root `README.md` covers prerequisites, quick start, service table, port mappings, network, volume, environment variables, Makefile commands, and a troubleshooting section. One troubleshooting command is wrong: `curl http://frontend:3000/health` targets nginx on port 80 and a `/health` route that the backend serves, not the frontend. | | Service Communication | 1 | 2 | Services share a bridge network. But inter-service communication was not verified. Backend CORS is unimplemented, and the nginx `/api` proxy is the only path between the frontend and backend. | | Build Optimization | 1 | 3 | The backend image uses `python:3.11-slim` and `pip --no-cache-dir`. The frontend Dockerfile is multi-stage with nginx. But the frontend Dockerfile still contains the invalid `COPY package-lock.json* . 2>/dev/null || true` line, so the build should fail (not verified with `docker build`). The backend Dockerfile is unchanged from M2 and copies the whole directory including tests. Neither `.dockerignore` is committed. | | **Base total** | **13** | **29** | | ### Bonus - **+1 Logs command and restart policies:** awarded. The Makefile has `logs`, and both services set `restart: unless-stopped`. - **+2 README Docker troubleshooting and `.dockerignore`:** not awarded. The README troubleshooting section exists, but the `.dockerignore` files are not committed. - **+3 Full test automation and clean removes images:** not awarded. `make test` does not run the frontend tests, and the E2E suite is not included. Bonus total: +1. ### Critical Requirements Checklist (from rubric) - [x] `docker-compose.yml` defines both backend and frontend services - [x] Ports 3000 and 8000 configured - [x] Docker network defined - [x] `.env.example` and `.env` present (but `.env.example` is not tracked) ## Other Issues Found 1. **Compose file fails validation.** Remove the `backend-db` dependency, or define that service. Also add a healthcheck to the backend if the frontend should wait on `service_healthy`. Drop the obsolete `version:` key. 2. **`.env.example` is git-ignored.** Root `.gitignore` line 10 (`**/.env*`) matches it. Add `!.env.example`. 3. **`.dockerignore` files are git-ignored.** Root `.gitignore` line 57 (`.dockerignore`) matches both files. Remove that line, or scope it to the root. 4. **`backend/Dockerfile` is git-ignored.** `backend/.gitignore` line 14 lists `Dockerfile`. A fresh clone cannot build the backend image. 5. **Frontend Dockerfile is broken.** Remove the `COPY package-lock.json* . 2>/dev/null || true` line and use `COPY package.json package-lock.json* ./`. The stage uses `node:18-alpine`, but the M4 prompt suggests `node:20-alpine`. 6. **`make test` is incomplete.** It runs the root placeholder `npm test`, not `frontend/`'s Vitest suite, and does not run Playwright. Change it to `cd frontend && npm test`, and add the E2E step once the suite is discoverable. 7. **Unused environment variables.** `BACKEND_CORS_ORIGINS` and `FRONTEND_API_URL` are not read by the backend or frontend. Wire them up or drop them from `.env`. 8. **`make clean` deletes the data `.gitignore`.** `rm -rf data/` removes `data/.gitignore` along with the database. Remove only `data/db`. 9. **Backend Dockerfile is not optimized.** It copies the whole directory including `tests/` and `pytest.ini`. Copy only the runtime code. 10. **Root `README.md` is partly out of date.** It says the database is at `/data/db/newzy.db` in the volume section, and the troubleshooting `curl` targets the wrong service. ## Path to a Higher Score 1. Fix the compose file so `docker compose config` passes. 2. Fix the `.gitignore` rules so `.env.example`, both `.dockerignore` files, and `backend/Dockerfile` are committed. 3. Fix the frontend Dockerfile `COPY` line and run `docker compose build`. 4. Make `make test` run the real frontend and backend tests. 5. Add a backend healthcheck and verify frontend-to-backend calls through the nginx proxy. 6. Change `make clean` to remove only `data/db` so it leaves `data/.gitignore` in place.