Add scoring reports for the newz repo milestones M1 through M6, with verification notes and remediation steps for each. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
11 KiB
M6: Setup Admin Area - Score Report
Repository scored: ../newz (/home/daniel/Gitea/daniel/newz), working tree (M6 work is uncommitted)
Rubric: milestone/m6-setup-admin-area-scoring.md
Model: qwen3.5-9b
Total Score: 24 / 51 (23 base, +1 bonus) - Overall level 0
Overall level 0 applies because the rubric's level-0 conditions are met: the Lexical editor is not integrated (the packages are installed but never imported), and the backend does not start. The numeric score assumes the import blockers are fixed. Most of the admin UI is placeholder or stubbed, so the numeric score is limited by that as well.
Blockers Found
| # | Problem | Where | Evidence |
|---|---|---|---|
| 1 | HTTPAuthorizationCredentials is imported from fastapi |
backend/main.py line 10 |
ImportError: cannot import name 'HTTPAuthorizationCredentials' from 'fastapi' (confirmed in a temp copy). It lives in fastapi.security. |
| 2 | Boolean used but not imported |
backend/app/models.py line 7 and line 21 |
The import line is from sqlalchemy import DateTime, ForeignKey, Integer, String, Text. This raises NameError on import. Not reached in the temp run because blocker 1 fires first. |
| 3 | config.py still has class Config alongside model_config |
backend/config.py line 29 |
Carried over from M2. Pydantic v2 rejects this. |
| 4 | Admin dependency returns user.model_dump(...) on a SQLAlchemy object |
backend/app/auth.py get_current_admin |
SQLAlchemy models have no model_dump. Admins get 500 on every admin route, and the current_user["id"] lookup in create also depends on this dict. |
| 5 | Article model has no url or points columns |
backend/models/article.py |
ArticleAdminIn/ArticleAdminOut and every admin endpoint use url and points. Search on Article.url and creating an article with url= would fail at runtime. |
Earlier blockers from M2 and M5 are still unresolved: the missing httpx in requirements.txt, the placeholder response_model=list[Article] routes, and the jwt / python-jose mismatch.
Verification Performed
| Check | Result |
|---|---|
import main in a clean venv (requirements.txt + PyJWT + httpx) |
Fails on blocker 1. |
npm run build (frontend) |
Fails at tsc with the same 4 TS6133 errors in src/tests/*.test.tsx (unchanged since M3). |
npx vite build |
Succeeds. |
npx vitest run |
2 of 2 pass. Both are still expect(1).toBe(1) placeholders. |
npm run lint |
Fails. ESLint cannot find eslint-plugin-react (unchanged since M3). |
| Admin tests | None exist. backend/tests/ has no admin test file, and frontend/src/tests/ has no admin test. |
Scoring by Criterion
| Criterion | Score | Max | Notes |
|---|---|---|---|
| Database Schema | 1 | 3 | is_admin = Mapped[bool] = mapped_column(Boolean, default=False, index=True) is the right definition, but Boolean is not imported (blocker 2). There is no migration for existing databases. seed_admin.py creates or upgrades an admin user, which covers the seed requirement. |
| Backend Admin Protection | 2 | 4 | get_current_admin validates the JWT and checks is_admin, returns 403 with "Admin access required", and every admin route depends on it. Deductions: the success path returns model_dump (blocker 4), so admins also get 500. No security headers or rate-limit placeholder. |
| Admin List Endpoint | 2 | 4 | GET /api/admin/items returns items, total, page, page_size and total_pages, so pagination works in principle. Search uses ilike on title and url, which meets the requirement in code but fails at runtime (blocker 5). Sort ignores sort_order for created_at: the code always sorts newest first, so ascending date order is not possible. |
| Create Endpoint | 2 | 3 | POST /api/admin/items is admin-only, validates the URL scheme, and enforces points >= 0 and title length. The Article(...) constructor passes url= and points=, which the model does not have (blocker 5). Author defaults to 1 if the id is not on the dict, which is not a valid author lookup. |
| Update Endpoint | 2 | 3 | PUT /api/admin/items/{id} is admin-only and maps title, url, content and points. No optimistic UI. The frontend does show an error message on failure. |
| Delete Endpoint | 2 | 3 | DELETE is admin-only and sets published = False (soft delete, which the rubric lists as optional). It does not remove the record, so the hard-delete part of level 3 is not met. The delete endpoint is not reachable from the UI (see Delete Confirmation). |
| Frontend Layout | 3 | 4 | AdminLayout renders the sidebar only when isAdmin is true and shows an "Access Denied" message otherwise. The sidebar is 250px, with a mobile toggle, an overlay, and a "Back to Site" link. Non-admins are redirected to / by the catch-all route. Deduction: App.tsx, AdminDashboard.tsx and EditItemPage.tsx each wrap their content in <AdminLayout>, so admin pages render two nested sidebars. |
| List View Components | 1 | 6 | AdminDashboard.tsx has a search box and a sort dropdown, but no list. It shows a placeholder: "Admin dashboard will be populated with items when API is ready." There is no pagination, no page-size selector, no edit or delete buttons, and no empty state. adminApi.listItems returns a hard-coded empty result without calling the API. |
| Edit View Components | 2 | 4 | EditItemPage.tsx has title, url, a content editor, points, and a Save button that calls createItem or updateItem. It shows a loading state ("Saving...") and a success message. Deductions: pre-fill is broken because adminApi.getItem is a stub that returns an empty object, so edit mode shows a blank form. Cancel navigates away and does not revert. The edit route /admin/items/:id/edit is not linked from anywhere. |
| Delete Confirmation | 4 | 5 | DeleteConfirmation.tsx has an AlertCircle warning icon, a title with the item name, the text "This action cannot be undone", Cancel and "Yes, Delete" buttons, and an overlay that calls onCancel on click. Deductions: ESC does not close it, and the component is never imported or rendered, so the delete flow cannot be reached from the dashboard. |
| Lexical Editor | 1 | 5 | @lexical/react and lexical are in package.json, but nothing in src/ imports them. LexicalEditor.tsx is a plain <textarea> with a React-controlled value. The toolbar buttons (bold, italic, underline, headings, lists, link) have onClick={() => {}} and do nothing. Content is saved as plain text. |
| Frontend API Client | 1 | 4 | adminApi lives in api/client.ts rather than the specified adminApi.ts. Create, update and delete use authenticatedClient, so the Bearer header is sent and non-OK responses throw. listItems and getItem are stubs that return fake data without making a request. Sort parameters are not part of listItems. |
| Base total | 23 | 51 |
Bonus
- +1 Soft delete (
published = False): awarded. - +1 Audit logging, +2 loading skeleton / empty-state / pagination metadata, +3 responsive and keyboard shortcuts: not awarded. Mobile sidebar behaviour exists, but there are no keyboard shortcuts, no skeleton, and no empty-state view. The backend does return
total_pages, but the frontend never shows pagination.
Bonus total: +1.
Critical Requirements Checklist (from rubric)
Must have for score above 2:
is_adminfield exists in the database model (blocked by the missingBooleanimport)- Backend validates both the JWT and the
is_adminflag - Non-admin users receive 403 Forbidden
- Error message is "Admin access required"
Must have for score above 4:
- All admin CRUD endpoints are protected server-side
- Search is filtered on the backend (title OR url), in code
- Sort parameters change the query (
created_atignoressort_order, and the frontend never sends sort parameters)
Must have for score above 6:
- Delete requires an explicit confirmation dialog in the UI (the component exists but is not used)
- Warning message explains consequences (present in the component, not reachable)
- Cancel button available and functional (present in the component, not reachable)
Other Issues Found
- Admin UI is mostly placeholder. The dashboard does not list items. Stubs in
adminApi.listItemsandadminApi.getItemreturn fake data, so the UI looks like it works but never talks to the backend. - Lexical packages installed but unused.
@lexical/reactandlexicalare inpackage.jsonand not imported. The M6 spec requires a working Lexical editor with formatting. - No route from the site to the admin area.
Header.tsxhas no admin link, and the dashboard has no edit or delete actions that lead to the edit page or the confirmation modal. - Nested
AdminLayout. Wrapping the same layout in both the route and the page doubles the sidebar. seed_admin.pyprints the admin password to stdout, and its "Connecting to database" message uses a fallback URL (sqlite:///data/db/newzy.db) that does not match the engine it actually uses (fromdb/session.py). The message is misleading, but the seeding itself goes through the app engine.- Frontend and backend admin routes do not match the spec's file layout.
adminApi.tsis insideclient.ts, andAdminModal.tsxis absent (optional). - Docs overstate the work.
docs/admin-area.md(242 lines) describes features that are placeholders or not wired up. - Unresolved earlier blockers.
config.pyclass Config(M2), missinghttpx(M2/M5), placeholderresponse_model=list[Article]routes (M5), and thejwt/python-josemismatch (M5). Alsodocker-compose.ymlstill references undefinedbackend-db(M4).
Path to a Higher Score
- Fix the import blockers: import
HTTPAuthorizationCredentialsfromfastapi.security, importBooleaninapp/models.py, removeclass Configfromconfig.py, and addhttpxandPyJWTtorequirements.txt. - Add
url(String, nullable) andpoints(Integer, default 0) columns to theArticlemodel, and add a small migration or a note to recreate the table. - Return the user object (or a dict built from its fields) from
get_current_admininstead ofmodel_dump. - Make
sort_orderapply tocreated_atas well, and passsort_by/sort_orderfrom the frontend. - Implement
listItemsandgetItemwith realfetchcalls, and wire the dashboard to render a table with pagination, page size, and a debounced search. - Render
DeleteConfirmationfrom the dashboard row actions, with ESC and outside-click dismissal. - Replace the textarea with a real Lexical editor (
LexicalComposer,RichTextPlugin,ContentEditable) and wire the toolbar to Lexical commands. - Remove the
AdminLayoutwrappers from the pages, keeping only the route-level wrapper. - Add admin tests: 403 for non-admins, pagination, search, sort, and the create/update/delete flows.