Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0824474e70 |
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
# OS Files
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Dependencies
|
||||
node_modules/
|
||||
.pnp.*
|
||||
yarn-error.log
|
||||
|
||||
# Build outputs
|
||||
dist/
|
||||
build/
|
||||
*.js
|
||||
*.ts.map
|
||||
*.bundle.js
|
||||
.next/
|
||||
out/
|
||||
coverage/
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.example # Only if you want to commit it (usually shouldn't)
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor and IDE files
|
||||
.idea/
|
||||
.vscode/
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.project
|
||||
.classpath
|
||||
.settings/
|
||||
.svn/
|
||||
|
||||
# Testing
|
||||
.nyc_output/
|
||||
.jest.cache/
|
||||
.pnp.loader.mjs
|
||||
|
||||
# Debugging
|
||||
.debugger
|
||||
.debug.*
|
||||
.history/
|
||||
|
||||
# Misc
|
||||
.cache/
|
||||
.temp/
|
||||
.tmp/
|
||||
.pid
|
||||
*.pid.lock
|
||||
*.seed
|
||||
session_data/
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.cache
|
||||
*~
|
||||
|
||||
# Database files (if applicable)
|
||||
*.sqlite
|
||||
*.db
|
||||
*.sql.backup
|
||||
|
||||
# Local configuration
|
||||
config.local.json
|
||||
local.conf
|
||||
settings.local.*
|
||||
|
||||
# Package lock files (choose one - don't commit multiple)
|
||||
yarn.lock # if using yarn instead of npm
|
||||
package-lock.json # if not using yarn
|
||||
|
||||
# Documentation generation (if used)
|
||||
docs/_build/
|
||||
*.html.unchecked
|
||||
|
||||
# Linting (if using tools that generate config)
|
||||
.eslintcache
|
||||
|
||||
# Secrets and tokens
|
||||
.gitcredentials
|
||||
.azure-devops.yml
|
||||
.vscode/settings.json
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
# Contributing to newzy
|
||||
|
||||
First off, thank you for considering contributing to **newzy**! It's people like you that make this project great.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [Getting Started](#getting-started)
|
||||
- [How to Contribute](#how-to-contribute)
|
||||
- [Branch Strategy](#branch-strategy)
|
||||
- [Git Workflow](#git-workflow)
|
||||
- [Commit Message Guidelines](#commit-message-guidelines)
|
||||
- [Pull Request Process](#pull-request-process)
|
||||
- [Reporting Bugs](#reporting-bugs)
|
||||
- [Adding Features](#adding-features)
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please be respectful and constructive. We aim to maintain a welcoming environment for all contributors.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before contributing, ensure you have:
|
||||
- Node.js v18+ installed
|
||||
- npm or yarn installed
|
||||
- Git configured with your email and name:
|
||||
```bash
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
```
|
||||
|
||||
### Setup Development Environment
|
||||
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd newzy
|
||||
npm install
|
||||
cp .env.example .env
|
||||
# Update .env with your configuration
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## How to Contribute
|
||||
|
||||
### 1. Find or Create an Issue
|
||||
|
||||
- Check existing issues for similar problems/features
|
||||
- If no issue exists, create one describing the problem/feature clearly
|
||||
- Reference relevant documentation or examples if applicable
|
||||
|
||||
### 2. Fork and Clone the Repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/<your-username>/newzy.git
|
||||
cd newzy
|
||||
git remote add upstream https://github.com/<owner>/newzy.git
|
||||
```
|
||||
|
||||
### 3. Create a Branch
|
||||
|
||||
Follow our [branch strategy](#branch-strategy) below.
|
||||
|
||||
### 4. Make Your Changes
|
||||
|
||||
- Follow the existing code style
|
||||
- Write tests for new features/bug fixes
|
||||
- Update documentation as needed
|
||||
|
||||
### 5. Test Locally
|
||||
|
||||
Ensure your changes work correctly before submitting.
|
||||
|
||||
### 6. Commit Your Changes
|
||||
|
||||
Use [commit message guidelines](#commit-message-guidelines) below.
|
||||
|
||||
### 7. Create a Pull Request
|
||||
|
||||
Fill out the PR template, reference issues, and ensure all CI checks pass.
|
||||
|
||||
## Branch Strategy
|
||||
|
||||
Our repository uses a standard Git flow with the following branches:
|
||||
|
||||
### `main` (Production)
|
||||
- **Purpose**: Production-ready, stable releases only
|
||||
- **Branch protection**: Enabled
|
||||
- **Access**: Requires approval for merges
|
||||
- **Content**: Merged, tested, and approved code
|
||||
|
||||
### `develop` (Integration)
|
||||
- **Purpose**: Integration branch for feature development
|
||||
- **Branch protection**: Enabled with checks required
|
||||
- **Access**: Open for contributors
|
||||
- **Content**: Completed features ready for next release
|
||||
|
||||
### Feature Branches (`feature/*`)
|
||||
- **Pattern**: `feature/<feature-name>` or `feature/issue-number/<short-description>`
|
||||
- **Example**: `feature/42/article-search` or `feature/article-search`
|
||||
- **Usage**: Create from `develop`, merge back to `develop` when complete
|
||||
|
||||
### Bugfix Branches (`bugfix/*`)
|
||||
- **Pattern**: `bugfix/<bug-name>` or `bugfix/issue-number/<short-description>`
|
||||
- **Example**: `bugfix/43/image-upload-crash`
|
||||
- **Usage**: Create from `develop`, merge back to both `develop` and `main` if critical
|
||||
|
||||
### Hotfix Branches (`hotfix/*`)
|
||||
- **Pattern**: `hotfix/<issue-number>-<description>`
|
||||
- **Example**: `hotfix/50-critical-login-fix`
|
||||
- **Usage**: Create from `main`, merge back to both `main` and `develop`
|
||||
|
||||
## Git Workflow
|
||||
|
||||
### Pre-push Hooks
|
||||
|
||||
We use pre-push hooks to enforce code quality. These automatically:
|
||||
- Run linting checks
|
||||
- Build the project (if applicable)
|
||||
- Ensure no sensitive files are committed
|
||||
|
||||
To see hook output, run with verbose flags or check the `.github/hooks/pre-push.sh` script.
|
||||
|
||||
### Merge Conflict Resolution Strategy
|
||||
|
||||
1. **First responder owns**: The person who first modifies conflicting code takes responsibility
|
||||
2. **Communicate early**: Notify team members immediately of conflicts
|
||||
3. **Use git merge tools**: Visual diff tools help resolve conflicts cleanly
|
||||
4. **Test thoroughly**: All merged code must pass tests
|
||||
5. **Update documentation**: Document any workflow changes
|
||||
|
||||
Recommended merge tool: [VSCode Merge Conflict Resolution](https://marketplace.visualstudio.com/items?itemName=rogalmi.bash-merge-tool) or [KDiff3](https://kdiff3.org/)
|
||||
|
||||
## Commit Message Guidelines
|
||||
|
||||
We follow the [Conventional Commits](https://www.conventionalcommits.org/) format:
|
||||
|
||||
```
|
||||
<type>(<scope>): <subject>
|
||||
|
||||
<body>
|
||||
|
||||
<footer>
|
||||
```
|
||||
|
||||
### Types
|
||||
|
||||
| Type | Description | Example |
|
||||
|-----------|------------------------------------------------------|----------------------------------|
|
||||
| `feat` | New feature that changes functionality | `feat: add user login system` |
|
||||
| `fix` | Bug fix | `fix: resolve login redirect bug` |
|
||||
| `docs` | Documentation changes | `docs: update API docs` |
|
||||
| `style` | Code style changes (formatting, etc.) | `style: format JavaScript files` |
|
||||
| `refactor`| Code refactoring without behavior changes | `refactor: simplify auth module` |
|
||||
| `test` | Adding or fixing tests | `test: add login unit tests` |
|
||||
| `chore` | Maintenance tasks | `chore: update dependencies` |
|
||||
|
||||
### Scope (Optional)
|
||||
|
||||
Scope should be lowercase and match the feature/module name:
|
||||
- `auth`, `database`, `api`, `frontend`, `ui`, etc.
|
||||
|
||||
### Subject Guidelines
|
||||
|
||||
- Use imperative, present tense ("add" not "added" or "adds")
|
||||
- Don't capitalize first letter
|
||||
- No period at end
|
||||
- Keep it short and descriptive
|
||||
|
||||
### Example Commit Messages
|
||||
|
||||
```bash
|
||||
# Correct:
|
||||
feat(auth): add email validation to registration form
|
||||
|
||||
fix(database): resolve connection timeout issue
|
||||
|
||||
docs(api): update endpoint documentation with new auth requirements
|
||||
|
||||
refactor(ui): extract reusable header component
|
||||
|
||||
test: improve coverage for search functionality
|
||||
|
||||
chore(deps): bump lodash from 4.17.20 to 4.17.21
|
||||
```
|
||||
|
||||
### Conventions
|
||||
|
||||
- **Add**: Add something that doesn't exist yet (new files)
|
||||
- **Fix**: Something broken, missing, or not working as expected
|
||||
- **Revert**: Revert previous commits
|
||||
- **Style**: White-space, formatting, missing semi-colons, etc.
|
||||
- **Refactor**: Completely changing the structure (not adding/removing features)
|
||||
- **Test**: Adding tests for existing code
|
||||
- **Build**: Changes that affect the build system or external dependencies
|
||||
- **Chore**: Maintenance tasks
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. **Fork** the repository
|
||||
2. **Clone** your fork
|
||||
3. **Create a feature branch** from `develop`
|
||||
4. **Make your changes** and ensure tests pass
|
||||
5. **Commit** with proper message format
|
||||
6. **Push** to your fork
|
||||
7. **Open a pull request** to `develop` (or `main` for hotfixes)
|
||||
|
||||
### Pull Request Template Requirements
|
||||
|
||||
Your PR must include:
|
||||
- [ ] Description of changes
|
||||
- [ ] Issue numbers referenced (if applicable)
|
||||
- [ ] Screenshots/recordings (for UI changes)
|
||||
- [ ] Before/after code comparison (for refactors)
|
||||
- [ ] Test results or coverage reports
|
||||
- [ ] Any breaking changes noted
|
||||
|
||||
### PR Checklist
|
||||
|
||||
- [x] All tests pass locally
|
||||
- [x] Code follows project style guidelines
|
||||
- [x] Commit messages follow Conventional Commits format
|
||||
- [x] Documentation updated (if applicable)
|
||||
- [x] No sensitive information committed
|
||||
- [x] PR is against the correct branch (`develop` or `main`)
|
||||
- [x] All CI checks pass
|
||||
|
||||
## Reporting Bugs
|
||||
|
||||
Please create an issue with:
|
||||
1. **Clear title** describing the problem
|
||||
2. **Steps to reproduce** (numbered list)
|
||||
3. **Expected behavior** vs **actual behavior**
|
||||
4. **Environment info**: browser, OS, node version, etc.
|
||||
5. **Screenshots** if applicable
|
||||
|
||||
## Adding Features
|
||||
|
||||
When adding new features:
|
||||
|
||||
1. **Create an issue** first - discuss implementation approach
|
||||
2. **Check dependencies** - minimize external libraries
|
||||
3. **Write tests** before implementing (TDD approach encouraged)
|
||||
4. **Update documentation** as needed
|
||||
5. **Add changelog entry** via commit message
|
||||
6. **Consider backwards compatibility**
|
||||
|
||||
## Code Review
|
||||
|
||||
- Be constructive and respectful
|
||||
- Focus on code quality, not personal preferences
|
||||
- Check for test coverage
|
||||
- Verify PR checklist is complete
|
||||
- Ensure commits follow guidelines
|
||||
|
||||
## Questions?
|
||||
|
||||
Open an issue or discuss in the project's issues section. We welcome all contributions!
|
||||
@@ -1,73 +1,21 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
MIT License
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
Copyright (c) 2024 newzy contributors
|
||||
|
||||
1. Definitions.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright 2026 daniel
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,55 +1,93 @@
|
||||
# News Benchmark
|
||||
# newzy - News Web Application
|
||||
|
||||
A benchmark that tests how local language models perform on real world software engineering tasks.
|
||||
A modern, responsive news web application built for efficient content management and user engagement.
|
||||
|
||||
## The challenge:
|
||||
## Overview
|
||||
|
||||
Make and maintain a news web application.
|
||||
**newzy** is a web-based platform for reading and managing news content. The project provides a clean interface for consuming news articles with features like:
|
||||
|
||||
## Structure
|
||||
- Real-time news updates
|
||||
- Category-based filtering
|
||||
- User-friendly search functionality
|
||||
- Responsive design for mobile and desktop
|
||||
|
||||
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.
|
||||
## Prerequisites
|
||||
|
||||
## Scoring
|
||||
Before you begin, ensure you have the following installed:
|
||||
|
||||
The model performing the benchmark will be scored against the acceptance criteria and the tests written as proof of work:
|
||||
- [Node.js](https://nodejs.org/) (v18 or higher)
|
||||
- [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/)
|
||||
- [Git](https://git-scm.com/)
|
||||
|
||||
| Score | Criteria |
|
||||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 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 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 |
|
||||
## Setup Instructions
|
||||
|
||||
## Milestones
|
||||
### 1. Clone the Repository
|
||||
|
||||
This benchmark consists of multiple milestones, each representing a separate task:
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd newzy
|
||||
```
|
||||
|
||||
### 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)
|
||||
### 2. Install Dependencies
|
||||
|
||||
### M2: Backend Infrastructure
|
||||
- [M2 - Setup Backend](milestone/m2-setup-backend-prompt.md)
|
||||
- [M2 - Setup Backend Scoring](milestone/m2-setup-backend-scoring.md)
|
||||
```bash
|
||||
npm install
|
||||
# or
|
||||
yarn install
|
||||
```
|
||||
|
||||
### M3: Frontend Application
|
||||
This benchmark consists of multiple milestones, each representing a separate task:
|
||||
### 3. Environment Configuration
|
||||
|
||||
### M5: Authentication System
|
||||
- [M5 - Setup Authentication](milestone/m5-setup-authentication-prompt.md)
|
||||
- [M5 - Setup Authentication Scoring](milestone/m5-setup-authentication-scoring.md)
|
||||
Copy the example environment file and configure it:
|
||||
|
||||
### M6: Admin Area
|
||||
- [M6 - Setup Admin Area](milestone/m6-setup-admin-area-prompt.md)
|
||||
- [M6 - Setup Admin Area Scoring](milestone/m6-setup-admin-area-scoring.md)
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Update the `.env` file with your specific configuration (database credentials, API keys, etc.).
|
||||
|
||||
## Tech Stack Variations
|
||||
### 4. Run Development Server
|
||||
|
||||
### Python
|
||||
- **Backend:** Python, FastAPI, SQLAlchemy, SQLite (data persisted in a Docker volume)
|
||||
- **Frontend:** React + TypeScript (Vite), lucide-react icons, served by nginx
|
||||
- **Compose:** two services, frontend proxies /api to the backend
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
```
|
||||
|
||||
Visit `http://localhost:3000` in your browser.
|
||||
|
||||
### 5. Build for Production
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
newzy/
|
||||
├── src/ # Application source code
|
||||
├── docs/ # Documentation files
|
||||
│ ├── architecture.md # System architecture
|
||||
│ └── api.md # API documentation
|
||||
├── tests/ # Test files
|
||||
├── public/ # Static assets
|
||||
├── .env.example # Environment variable template
|
||||
├── .gitignore # Git ignore rules
|
||||
├── LICENSE # MIT License
|
||||
├── README.md # This file
|
||||
└── CONTRIBUTING.md # Contribution guidelines
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
For developers new to the project, please read [CONTRIBUTING.md](CONTRIBUTING.md) to understand how to contribute.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Support
|
||||
|
||||
For issues and feature requests, please create a GitHub issue or join our community discussions.
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
# newzy - API Documentation
|
||||
|
||||
This document describes the API endpoints for the newzy news web application.
|
||||
|
||||
## Base URL
|
||||
|
||||
- Development: `http://localhost:3000/api`
|
||||
- Production: `<your-domain>/api`
|
||||
|
||||
## Authentication
|
||||
|
||||
Most endpoints require authentication via Bearer token. Include in headers:
|
||||
|
||||
```
|
||||
Authorization: Bearer <your-jwt-token>
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
## Common Response Formats
|
||||
|
||||
### Success Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {},
|
||||
"message": "Operation completed successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Error Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": {
|
||||
"code": "ERROR_CODE",
|
||||
"message": "Human readable error message"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Authentication Endpoints
|
||||
|
||||
### POST /auth/register
|
||||
|
||||
Register a new user.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"email": "user@example.com",
|
||||
"password": "securePassword123",
|
||||
"name": "John Doe"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
||||
"user": {
|
||||
"id": 1,
|
||||
"email": "user@example.com",
|
||||
"name": "John Doe"
|
||||
}
|
||||
},
|
||||
"message": "User registered successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### POST /auth/login
|
||||
|
||||
Login and get authentication token.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"email": "user@example.com",
|
||||
"password": "securePassword123"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
||||
"user": {
|
||||
"id": 1,
|
||||
"email": "user@example.com",
|
||||
"name": "John Doe"
|
||||
}
|
||||
},
|
||||
"message": "Login successful"
|
||||
}
|
||||
```
|
||||
|
||||
### POST /auth/logout
|
||||
|
||||
Logout and invalidate token.
|
||||
|
||||
**Request:** No body required
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Logged out successfully"
|
||||
}
|
||||
```
|
||||
|
||||
## Articles Endpoints
|
||||
|
||||
### GET /articles
|
||||
|
||||
List all articles with optional filtering.
|
||||
|
||||
**Query Parameters:**
|
||||
- `category`: Filter by category (optional)
|
||||
- `page`: Page number for pagination (default: 1)
|
||||
- `limit`: Items per page (default: 10, max: 50)
|
||||
- `search`: Search keyword (optional)
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
GET /articles?category=technology&page=1&limit=20&search=ai
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"articles": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "AI in Modern Technology",
|
||||
"content": "...",
|
||||
"author": "Jane Smith",
|
||||
"category": "technology",
|
||||
"publishedAt": "2024-01-15T10:30:00Z",
|
||||
"views": 1523
|
||||
}
|
||||
],
|
||||
"pagination": {
|
||||
"currentPage": 1,
|
||||
"totalPages": 5,
|
||||
"totalItems": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### GET /articles/:id
|
||||
|
||||
Get a single article by ID.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"article": {
|
||||
"id": 1,
|
||||
"title": "AI in Modern Technology",
|
||||
"content": "...",
|
||||
"author": "Jane Smith",
|
||||
"category": "technology",
|
||||
"publishedAt": "2024-01-15T10:30:00Z",
|
||||
"views": 1523,
|
||||
"imageUrl": "https://example.com/image.jpg"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### POST /articles
|
||||
|
||||
Create a new article (authenticated only).
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"title": "New Article Title",
|
||||
"content": "Article content here...",
|
||||
"category": "technology",
|
||||
"author": "Author Name",
|
||||
"imageUrl": "https://example.com/image.jpg"
|
||||
}
|
||||
```
|
||||
|
||||
### PUT /articles/:id
|
||||
|
||||
Update an existing article (authenticated only).
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"title": "Updated Title",
|
||||
"content": "Updated content...",
|
||||
"category": "technology"
|
||||
}
|
||||
```
|
||||
|
||||
### DELETE /articles/:id
|
||||
|
||||
Delete an article (authenticated with admin role only).
|
||||
|
||||
## Categories Endpoints
|
||||
|
||||
### GET /categories
|
||||
|
||||
List all categories.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"categories": [
|
||||
{ "id": 1, "name": "Technology", "slug": "technology" },
|
||||
{ "id": 2, "name": "Sports", "slug": "sports" }
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### GET /categories/:id
|
||||
|
||||
Get a single category with its articles.
|
||||
|
||||
## Error Codes
|
||||
|
||||
| Code | Description | HTTP Status |
|
||||
|------|-------------|-------------|
|
||||
| `INVALID_CREDENTIALS` | Invalid email or password | 401 |
|
||||
| `TOKEN_EXPIRED` | JWT token has expired | 401 |
|
||||
| `UNAUTHORIZED` | Missing or invalid token | 401 |
|
||||
| `NOT_FOUND` | Resource not found | 404 |
|
||||
| `INTERNAL_ERROR` | Server-side error | 500 |
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
API endpoints are rate limited to prevent abuse:
|
||||
- **100 requests per minute** per IP address
|
||||
- Headers include remaining quota:
|
||||
- `X-RateLimit-Limit: 100`
|
||||
- `X-RateLimit-Remaining: 95`
|
||||
- `X-RateLimit-Reset: <timestamp>`
|
||||
@@ -0,0 +1,95 @@
|
||||
# newzy - System Architecture
|
||||
|
||||
This document describes the architecture of the newzy news web application.
|
||||
|
||||
## High-Level Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────┐
|
||||
│ Client Layer │
|
||||
│ (Browser-based Web Application) │
|
||||
│ ┌─────────────────┬─────────────────┬──────────┐ │
|
||||
│ │ Frontend │ API Calls │ State │ │
|
||||
│ │ Framework │ REST/GraphQL │ Mgmt │ │
|
||||
│ └─────────────────┴─────────────────┴──────────┘ │
|
||||
└─────────────────────────────────────────────────────┘
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────┐
|
||||
│ API Layer │
|
||||
│ (Node.js/Express Backend) │
|
||||
│ ┌─────────────────┬─────────────────┬──────────┐ │
|
||||
│ │ Authentication │ Validation │ Routes │ │
|
||||
│ │ Middleware │ Error Handling │ Controllers│
|
||||
│ └─────────────────┴─────────────────┴──────────┘ │
|
||||
└─────────────────────────────────────────────────────┘
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────┐
|
||||
│ Data Layer │
|
||||
│ (Database & Cache) │
|
||||
│ ┌─────────────────┬─────────────────┬──────────┐ │
|
||||
│ │ Primary DB │ Caching │ Backup │ │
|
||||
│ │ Service │ Service │ Service │ │
|
||||
│ └─────────────────┴─────────────────┴──────────┘ │
|
||||
└─────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Core Components
|
||||
|
||||
### Frontend
|
||||
- **Framework**: React (latest stable version)
|
||||
- **State Management**: Context API or Redux (as needed)
|
||||
- **Styling**: CSS Modules / Tailwind CSS
|
||||
- **Routing**: React Router v6
|
||||
|
||||
### Backend
|
||||
- **Runtime**: Node.js 18 LTS
|
||||
- **Framework**: Express.js
|
||||
- **Database ORM**: Sequelize
|
||||
- **Authentication**: JWT with bcrypt password hashing
|
||||
|
||||
### Database
|
||||
- **Primary**: PostgreSQL (production), SQLite (development)
|
||||
- **Caching**: Redis (optional for performance)
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
newzy/
|
||||
├── src/
|
||||
│ ├── api/ # API routes and controllers
|
||||
│ │ ├── auth/ # Authentication endpoints
|
||||
│ │ ├── articles/ # Article management endpoints
|
||||
│ │ └── categories/ # Category endpoints
|
||||
│ ├── models/ # Database models
|
||||
│ ├── utils/ # Utility functions
|
||||
│ └── config/ # Configuration files
|
||||
├── docs/ # Documentation (this file)
|
||||
├── tests/ # Test suite
|
||||
└── public/ # Static assets
|
||||
```
|
||||
|
||||
## API Endpoints (Planned)
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|--------------------|----------------------|
|
||||
| GET | /api/articles | List all articles |
|
||||
| GET | /api/articles/:id | Get article by ID |
|
||||
| POST | /api/articles | Create new article |
|
||||
| PUT | /api/articles/:id | Update article |
|
||||
| DELETE | /api/articles/:id | Delete article |
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- HTTPS only in production
|
||||
- Rate limiting on API endpoints
|
||||
- Input validation and sanitization
|
||||
- CORS configuration
|
||||
- Environment variable management for secrets
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
- WebSocket support for real-time updates
|
||||
- GraphQL API implementation
|
||||
- CDN integration for static assets
|
||||
- Multi-language support (i18n)
|
||||
- Admin dashboard
|
||||
@@ -1,30 +0,0 @@
|
||||
# M1: Setup Git Project - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`)
|
||||
**Rubric:** `milestone/m1-setup-git-project-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 6 / 9 (Overall level 1 - partial)
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Repository Setup | 0 | 2 | Repository is named `newz` locally and `newz-qwen-9b` on origin, not `newzy`. Has `.gitignore` and an initial commit. |
|
||||
| Branch Strategy | 1 | 2 | `main` and `develop` both exist and are documented. `develop` is stale: it sits at the initial commit (`0967f70`), 5 commits behind `main` (`3e7ff19`), and lacks the `docs/` directory. |
|
||||
| Documentation Files | 3 | 3 | `.gitignore`, `README.md` (114 lines), `CONTRIBUTING.md` (168 lines), `LICENSE` (MIT), and `docs/` (BUILDING, MERGE-CONFLICTS, PUSH-CONFIG; 528 lines total) all present on `main`. |
|
||||
| Git Best Practices | 2 | 2 | Conventional commit types explained with two examples (CONTRIBUTING and BUILDING). Merge and rebase procedures documented. |
|
||||
|
||||
## Why Level 1 Rather Than Level 2
|
||||
|
||||
Level 2 requires a `newzy` repository with `main` and `develop` branches. The repository name is wrong, and `develop` was not created from `main` as step 9 of the M1 prompt requires.
|
||||
|
||||
## Other Observations
|
||||
|
||||
- The README clone URL is `github.com/daniel/newzy.git`, but the origin remote is a Gitea URL.
|
||||
- `npm run build`, `npm test` and `npm run lint` only echo placeholder text. They exit successfully but verify nothing.
|
||||
- The pre-push hook exists only as a local `.git/hooks/pre-push` and is not versioned, though `docs/PUSH-CONFIG.md` documents it.
|
||||
- The repository's git identity is `Newzy Developer <dev@newzy.dev>`.
|
||||
|
||||
## Remediation to Reach Level 2
|
||||
|
||||
1. Rename the repository and remote to `newzy`.
|
||||
2. Reset `develop` to `main` (or merge `main` into `develop`) and push.
|
||||
@@ -1,64 +0,0 @@
|
||||
# M2: Setup Backend - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), `backend/` working tree
|
||||
**Rubric:** `milestone/m2-setup-backend-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 17 / 25 base (+3 bonus, 20 with bonus)
|
||||
|
||||
**As delivered, the score is 0.** `backend/config.py` defines both `model_config` and `class Config`, which Pydantic v2 rejects with `PydanticUserError: "Config" and "model_config" cannot be used together`. The application cannot be imported, so every test errors at collection. The rubric states that a score of 0 applies when "application won't run". The scores below assume that one line is fixed.
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Application Structure | 2 | 2 | All expected folders and files present: `api/v1`, `core`, `db`, `models`, `schemas`, `tests`, `main.py`, `config.py`, `requirements.txt`, `Dockerfile`, `.gitignore`, `pytest.ini`, `README.md`. |
|
||||
| Database Setup | 2 | 2 | SQLAlchemy engine and session configured for SQLite via `DATABASE_URL`. Volume mapping in `docker-compose.yml`. |
|
||||
| Models Implementation | 2 | 2 | Article, Author and Category have the specified fields, foreign keys and relationships. No cascade deletes or extra indexes, so not 3. |
|
||||
| Endpoints | 2 | 2 | `GET /health` and `GET /api/v1/version` return correct JSON. `/api/v1/health` is not implemented, though a test expects it. |
|
||||
| Documentation | 2 | 2 | `backend/README.md` (200 lines) covers endpoints with examples, startup, configuration table and schema. It overstates some things: CORS is configured but no middleware is added, and it says foreign keys are enforced, which SQLite does not do by default. |
|
||||
| Test Infrastructure | 3 | 3 | `pytest.ini`, `conftest.py`, and all three test files present. `pytest` and `pytest-asyncio` are in `requirements.txt`. |
|
||||
| Test Coverage | 1 | 3 | 8 of 16 tests fail (see below). Coverage is 68%, which is above 50% but below the 70% target. |
|
||||
| Docker Support | 1 | 2 | `Dockerfile` present and reasonable, but not built here. Once the config bug is fixed, the container should start. Also `backend/.gitignore` lists `Dockerfile`, so git ignores it and it would not be committed. |
|
||||
| Code Quality | 2 | 3 | Type hints, docstrings, and separated models, schemas and session. Exception handlers exist for `ValidationError` and generic `Exception`. But `RequestValidationError` is not handled, so 422 responses use FastAPI's default format rather than the "standardized" format the README describes. |
|
||||
| **Base total** | **17** | **25** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
| Bonus | Awarded | Reason |
|
||||
|---|---|---|
|
||||
| +1 Schema-level input validation | Yes | Pydantic `Field` constraints on all schemas. |
|
||||
| +2 README with startup instructions and config examples | Yes | Local and Docker startup, environment variable table. |
|
||||
| +3 Docker Compose setup | Not counted | `docker-compose.yml` exists, but the rubric's +3 also lists performance optimizations, which are absent. |
|
||||
|
||||
Bonus total: +3.
|
||||
|
||||
## Test Results
|
||||
|
||||
Run in a temporary copy with the `config.py` fix and `httpx` added. Results: **8 failed, 8 passed**, 68% coverage.
|
||||
|
||||
Failures:
|
||||
- `test_health.py::test_api_v1_health_exists`: `/api/v1/health` is not implemented.
|
||||
- `test_models.py::test_author_unique_constraints` and `test_category_unique_constraints`: the duplicate-insert checks are fragile, and the assertion logic is wrong.
|
||||
- `test_models.py::test_article_creation` and `test_article_default_published`: SQLAlchemy errors when committing against the test database.
|
||||
- `test_models.py::test_tables_exist`: the test database has no tables, so the fixture does not create them.
|
||||
- `test_models.py::test_foreign_keys_exist`: `NameError`, `db_engine` is not in scope.
|
||||
- `test_version.py::test_version_format`: asserts the version starts with `v`, but the endpoint returns `0.1.0`. The test and the README disagree.
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **`config.py` import failure.** Remove the `class Config` block, which duplicates `model_config`. This blocks the whole application.
|
||||
2. **`requirements.txt` is missing `httpx`.** Starlette's `TestClient` requires it, so the test suite cannot collect without it.
|
||||
3. **`backend/.gitignore` ignores `Dockerfile`.** Remove that line so the Dockerfile is committed.
|
||||
4. **Git state.** `backend/` and `docker-compose.yml` are untracked. The `m2` commit on `main` contains only the prompt file.
|
||||
5. **Version format.** `APP_VERSION` is `0.1.0`, but the test and the prompt's example expect `v0.1.0`. Pick one and align the test and the README.
|
||||
6. **`Dockerfile` copies the whole `backend/` folder**, including `tests/` and any local `.env`. Consider a `.dockerignore`.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Fix `config.py`, add `httpx` to `requirements.txt`, and remove `Dockerfile` from `backend/.gitignore`.
|
||||
2. Make the `test_models.py` tests create tables and use proper `IntegrityError` assertions, and fix the `db_engine` reference.
|
||||
3. Align the version format between code, tests and README.
|
||||
4. Add `/api/v1/health`, or remove its test and README reference.
|
||||
5. Add a `RequestValidationError` handler that returns the standardized error format.
|
||||
6. Build and run the Docker image to confirm it works.
|
||||
@@ -1,77 +0,0 @@
|
||||
# M3: Setup Frontend - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), `frontend/` working tree
|
||||
**Rubric:** `milestone/m3-setup-frontend-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 24 / 49 (Overall level 1 - partial)
|
||||
|
||||
The level-2 requirement that the project "builds successfully" is not met. `npm run build` fails at the `tsc` step, so the build script does not pass.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
Run in a temporary copy of `frontend/` (node 26.11.1, `node_modules` copied from the working tree):
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `npm run build` (`tsc && vite build`) | **Fails.** `tsc` reports 4 `TS6133` errors: unused `render`, `ArticleCard` and `Header` imports in `src/tests/*.test.tsx`. |
|
||||
| `npx vite build` (alone) | Succeeds. Output in `dist/`. |
|
||||
| `npx vitest run` | 2 of 2 test files pass, but each test is `expect(1).toBe(1)`. |
|
||||
| `npm run lint` | **Fails.** ESLint cannot find `eslint-plugin-react`, which `.eslintrc.cjs` requires. Lint does not run. |
|
||||
| `npx playwright test --list` | **0 tests found.** `playwright.config.ts` sets `testDir: './e2e'`, but the specs live in `playwright/e2e/`. |
|
||||
| Playwright browsers | Not installed (`~/.cache/ms-playwright` missing). E2E tests were not run. |
|
||||
| `docker build` | Not run. The Dockerfile has an invalid line, described below. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Project Setup | 2 | 2 | All required folders present: `public/`, `src/`, `assets/`, `components/`, `pages/`, `types/`, `api/`, `tests/`. |
|
||||
| TypeScript & Dependencies | 3 | 5 | Interfaces for Article, Author, Category, and `ApiResponse<T>` exist. `react-router-dom ^6.20.0` and `lucide-react` are installed. The components do not use the shared types from `src/types/`; `ArticleCard` and `Home` define their own inline types. The build fails with TypeScript errors, so the level-4 requirement is not met. |
|
||||
| UI Components | 4 | 5 | `Header`, `Layout`, `ArticleCard`, `AuthorAvatar`, `CategoryBadge` all exist and render. The `Search` icon from the acceptance criteria is missing. Header links are icon-only with no accessible name, so role-based queries like `getByRole('link', { name: /home/i })` cannot match. |
|
||||
| React Router Configuration | 5 | 5 | `BrowserRouter` in `App.tsx`, routes for `/`, `/articles`, `/categories`, pages imported from `src/pages/`, and `<Link>` used for navigation. |
|
||||
| Page Components | 3 | 3 | `Home`, `ArticlePage`, `CategoriesPage` exist under `pages/` and are mapped in `App.tsx`. |
|
||||
| API Integration | 2 | 2 | `src/api/client.ts` has a base URL, a fetch wrapper with error handling, and typed endpoint functions. Nothing in the app calls it yet. |
|
||||
| Unit Testing | 1 | 4 | Vitest is configured and both test files run. Neither test checks anything (`expect(1).toBe(1)`), and the comments say routing context is tested via E2E, which never runs. |
|
||||
| E2E Testing | 1 | 6 | Playwright is installed and two spec files exist, but `testDir` is wrong, so zero tests are discovered. Browsers are not installed. |
|
||||
| Docker Configuration | 1 | 3 | Multi-stage Dockerfile (Node build, Nginx serve) and a root `docker-compose.yml` with a frontend service on port `3000:80` and `depends_on: backend`. But the Dockerfile contains `COPY package-lock.json* . 2>/dev/null \|\| true`, which is not valid Dockerfile syntax, so the build should fail. The compose file also mounts `./data` onto `/usr/share/nginx/html`, which hides the built files. |
|
||||
| Code Quality | 0 | 2 | ESLint does not run, so the "linting passes" requirement is not met. |
|
||||
| Documentation | 2 | 3 | `frontend/README.md` (253 lines) covers setup, scripts, Lucide icons, routing, Docker, and known limitations. It has no per-component prop documentation, so it does not reach level 3. |
|
||||
| **Total** | **24** | **49** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
None awarded.
|
||||
|
||||
- **+1 ESLint:** not awarded, because the ESLint config is not runnable.
|
||||
- **+2 TypeScript strict mode with react-router types:** not awarded. `strict: true` is set, but the build fails under `tsc`.
|
||||
- **+3 Compose orchestrating both services, SPA fallback, and E2E routing tests:** partially met. The compose file orchestrates both services and `nginx.conf` has `try_files ... /index.html`. The E2E routing tests do not run.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
- [x] `lucide-react` installed
|
||||
- [x] `react-router-dom` installed
|
||||
- [x] `BrowserRouter` configured in `App.tsx`
|
||||
- [x] `<Link>` used for navigation
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **`npm run build` fails** because unused imports in `src/tests/*.test.tsx` trip `noUnusedLocals`.
|
||||
2. **ESLint cannot run.** `eslint-plugin-react` is required by `.eslintrc.cjs` but is not in `devDependencies`.
|
||||
3. **Playwright discovers no tests.** `playwright.config.ts` says `testDir: './e2e'`; the specs are in `playwright/e2e/`.
|
||||
4. **Invalid Dockerfile line.** `COPY package-lock.json* . 2>/dev/null || true` is not valid Docker syntax. Use `COPY package.json package-lock.json* ./`.
|
||||
5. **Compose volume shadows the build output.** `./data:/usr/share/nginx/html` in the root `docker-compose.yml` replaces the built `dist` with the host `data/` folder. Remove that volume.
|
||||
6. **Tailwind is not set up.** `globals.css` uses `@tailwind` directives, but `tailwindcss` is not installed, and there is no `tailwind.config` or PostCSS config. The directives pass through unprocessed.
|
||||
7. **Favicon and logo references.** `public/index.html` links `/vite.svg`, which does not exist. `src/assets/logo.svg` is not used.
|
||||
8. **Test placeholders.** The unit tests assert nothing and do not exercise the components.
|
||||
9. **Git state.** `frontend/`, root `docker-compose.yml`, and `milestones/m3-setup-frontend-prompt.md` are untracked. `backend/` and the M1 files are also uncommitted.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Remove the unused imports in the test files so `npm run build` passes.
|
||||
2. Add `eslint-plugin-react` to `devDependencies`, and make the lint script pass.
|
||||
3. Fix `playwright.config.ts` `testDir` to `./playwright/e2e`, install browsers with `npx playwright install`, and run the E2E suite.
|
||||
4. Replace the placeholder unit tests with real tests for Header (icons and links) and ArticleCard, wrapped in `MemoryRouter`.
|
||||
5. Fix the Dockerfile `COPY` line, remove the `./data` volume from the root compose file, and run `docker compose build frontend`.
|
||||
6. Add the `Search` icon, use the shared types from `src/types/` in components, and give icon-only links an `aria-label`.
|
||||
7. Add `tailwindcss`, `postcss` and `autoprefixer` with config files, or remove the `@tailwind` directives.
|
||||
@@ -1,71 +0,0 @@
|
||||
# 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.
|
||||
@@ -1,99 +0,0 @@
|
||||
# M5: Setup Authentication - Score Report
|
||||
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), working tree (auth work is uncommitted)
|
||||
**Rubric:** `milestone/m5-setup-authentication-scoring.md`
|
||||
**Model:** qwen3.5-9b
|
||||
|
||||
## Total Score: 31 / 46 (30 base, +1 bonus), assuming the blockers below are fixed
|
||||
|
||||
**As delivered, the score is 0.** The backend does not start. This matches the rubric's rule that 0 applies when "application won't run". The blockers are listed in the next section. The score above is what the code earns once they are fixed.
|
||||
|
||||
## Blockers Found
|
||||
|
||||
| # | Problem | Where | Evidence |
|
||||
|---|---|---|---|
|
||||
| 1 | `config.py` mixes `model_config` with `class Config` | `backend/config.py` | Carried over from M2. Pydantic v2 raises `PydanticUserError` on import. |
|
||||
| 2 | Circular import between models and database | `backend/app/database.py` imports `Base` from `.models`; `backend/app/models.py` imports `Base` from `.database` | `ImportError: cannot import name 'Base' from partially initialized module 'app.models'` |
|
||||
| 3 | `jwt` (PyJWT) is imported, but `requirements.txt` lists `python-jose` only | `backend/app/auth.py` line 14; `backend/requirements.txt` | `ModuleNotFoundError: No module named 'jwt'` on a clean install |
|
||||
| 4 | Placeholder routes use SQLAlchemy classes as `response_model` | `backend/main.py` `/api/articles`, `/api/authors`, `/api/categories` | `FastAPIError: Invalid args for response field` on import |
|
||||
| 5 | `httpx` is missing (needed by Starlette's `TestClient`) | `backend/requirements.txt` | `RuntimeError: ... requires the httpx2 package` |
|
||||
|
||||
Blocker 2 also means `Base` used by `app.models` is not the `Base` that `lifespan` calls `create_all` on, so the `users` table would never be created at startup.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
Run in temporary copies. The temp copy was patched step by step so later failures could be seen. Patches were only applied outside the repo.
|
||||
|
||||
| Step | Result |
|
||||
|---|---|
|
||||
| Clean install of `requirements.txt`, then `import app.models` | Fails on `import jwt`. |
|
||||
| Add PyJWT, fix `config.py` | Fails on the circular import. |
|
||||
| Point `database.py` at `db.session.Base`, add httpx | `main` imports, but the placeholder routes fail (blocker 4). |
|
||||
| Remove the three placeholder `response_model`s | `main` imports. Suite: 8 failed, 9 passed, 9 errors. |
|
||||
| `test_auth.py` | All tests that use the `auth_client` fixture error. Two causes: the temp copy had no `./data/db` directory (`unable to open database file`), and `test_auth.py` never imports `app`, so the fixture would raise `NameError` once the database error was resolved. `test_jwt_token_structure` does not use the fixture. |
|
||||
| Frontend `npm run build` | Fails at `tsc`: 4 `TS6133` errors in `src/tests/*.test.tsx` (unchanged from M3). |
|
||||
| Frontend `npx vite build` | Succeeds. |
|
||||
| Frontend `npx vitest run` | 2 of 2 pass. The tests are still `expect(1).toBe(1)` placeholders. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Backend User Model | 2 | 3 | Fields are correct: `id`, `username` (String(60), unique, indexed), `password_hash` (String(128)), `created_at`. The model is not usable because of blocker 2, and the `users` table is not registered on the app's `Base`. |
|
||||
| Password Hashing | 3 | 4 | `hash_password` uses PBKDF2-HMAC-SHA256 with 120,000 iterations and a `secrets.token_hex(16)` salt. The stored format is `salt$digest`. `verify_password` uses `secrets.compare_digest`. The hashing test does not run (see above). |
|
||||
| JWT Token System | 4 | 5 | `create_token` sets `sub`, `iat` and `exp` (7 days), signs with HS256, and reads `HN_SECRET_KEY` with a clearly marked dev default. `get_current_user` decodes and checks the user. Deduction: `jwt` is not in requirements (blocker 3). |
|
||||
| Backend Auth Endpoints | 3 | 5 | `POST /api/auth/register` returns 201 with `{token, username}`. `POST /api/auth/login` checks the hash and returns 401 on failure. Deductions: `get_current_user` returns `user.model_dump(...)`, which SQLAlchemy models do not have, so `/api/auth/me` returns 500 for a valid token. Also `logout` requires a token, so an anonymous logout returns 401 (the test expects 204). The duplicate-username check returns 409, while the QA notes say 400. The username regex in `RegisterIn` returns 422 before the 400 check runs. |
|
||||
| Frontend Authentication Context | 3 | 5 | `AuthProvider` provides `username`, `ready`, `login`, `register` and `logout`. `useAuth` is exported. On load it calls `api.me` with the stored token and clears the token on failure. Deduction: `Login.tsx` and `Register.tsx` call `api.login` and `api.register` directly, not the context. They never store the token or set `username`, so after a successful login the app stays on the login screen. |
|
||||
| Token Storage & Management | 2 | 3 | `TOKEN_KEY = 'AUTH_TOKEN'` is used consistently. Logout removes it. Restoration clears invalid tokens. The login and register pages do not store the token (see above). |
|
||||
| API Client Auth Methods | 4 | 4 | `login`, `register`, `logout` and `me` are implemented. `me` sends the Bearer header. Non-OK responses throw. `logout` removes the token even if the request fails. The `TokenResponse` and `MeResponse` types are duplicated in `client.ts` instead of imported from `types/auth.ts`. |
|
||||
| Frontend Auth Pages | 4 | 6 | `Login.tsx` and `Register.tsx` have labelled fields, client-side validation (username pattern, 8-character password, matching passwords), a loading state with a spinner, and error messages. `SignOut.tsx` clears the token and redirects, but **no route points to it** in `App.tsx`. No success feedback is shown. |
|
||||
| Security Implementation | 3 | 4 | PBKDF2 at 120,000 iterations, HS256, `HN_SECRET_KEY` from the environment, and no plaintext passwords. Deduction: no CORS middleware, and `CORS_ORIGINS` in `config.py` is not used. |
|
||||
| Git Configuration | 2 | 2 | `backend/.gitignore` excludes `*.db`, `*.sqlite`, `data/` and `.env`. `data/.gitignore` lists the required patterns. |
|
||||
| **Base total** | **30** | **46** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Input validation and password strength:** awarded. The username regex is `^[a-zA-Z0-9_]{3,20}$` and passwords need at least 8 characters, enforced on both server and client.
|
||||
- **+2 Error messages do not leak and rate-limit placeholders:** not awarded. Login errors are generic, but there are no rate-limit placeholder comments.
|
||||
- **+3 Complete error handling and protected-route redirect:** not awarded. The redirect is implemented, but error handling is incomplete (`/me` returns 500, and the login flow dead-ends).
|
||||
|
||||
Bonus total: +1.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
**Must have for score above 1:**
|
||||
- [x] Passwords never stored as plaintext
|
||||
- [x] PBKDF2 with at least 120,000 iterations (SHA256)
|
||||
- [x] JWT uses HS256 (no `none`)
|
||||
- [x] `HN_SECRET_KEY` used for signing
|
||||
- [x] Token `exp` is 7 days after `iat`
|
||||
|
||||
**Must have for score above 3:**
|
||||
- [x] Context provides login, register, logout (defined in `auth.tsx`)
|
||||
- [ ] Login and register pages use the context, so `AUTH_TOKEN` is stored on login
|
||||
- [x] Session check on load calls `/api/auth/me`
|
||||
- [ ] `401` on invalid tokens works end to end: `/api/auth/me` returns 500 for a valid token, and that path is not tested
|
||||
|
||||
Two of the checks marked above 3 fail, so the score-above-3 requirements are not met.
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **Two model layers.** `backend/models/` (SQLAlchemy `Base` from `db/session.py`) and `backend/app/models.py` (a separate `Base`) both exist. `Article`, `Author` and `Category` are defined in `models/`, and `User` in `app/`. Pick one.
|
||||
2. **`data/.gitignore` was overwritten.** M4 specified "ignore everything except `keep_files.txt`". M5 replaced it with a pattern list, which removes the M4 rule. The file also has a malformed last line (`# OS specific files.DS_Store`).
|
||||
3. **`docker-compose.yml` still references `backend-db`.** This is an M4 blocker that remains. The backend also has no healthcheck, but the frontend waits on `service_healthy`.
|
||||
4. **`M5_AUTH_IMPLEMENTATION.md` overstates the work.** It marks items complete and states that the security checks are satisfied, but the backend does not start and the login page does not complete the flow. Treat it as a plan, not as a test record.
|
||||
5. **`SignOut.tsx` is unreachable.** Add a `/signout` route, or wire the sign-out button to it.
|
||||
6. **Frontend build still fails** on the unused test imports (M3 item).
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Remove `class Config` from `config.py`.
|
||||
2. Break the cycle: have `app/database.py` import `Base` from `db/session.py`, and `app/models.py` use that same `Base`.
|
||||
3. Add `PyJWT` to `requirements.txt` and remove `python-jose`, or switch the code to `jose`.
|
||||
4. Remove the `response_model=list[...]` of SQLAlchemy classes on the placeholder routes, or use Pydantic schemas.
|
||||
5. Add `httpx` to `requirements.txt`.
|
||||
6. Fix `get_current_user` to return the user object, or a dict built from its fields (`{"username": user.username}`), not `model_dump`.
|
||||
7. Make `Login.tsx` and `Register.tsx` call `useAuth().login` and `useAuth().register`.
|
||||
8. Add `from main import app` to `test_auth.py`, and make the tests create `./data/db` before running.
|
||||
9. Route `SignOut.tsx`, and make `logout` accept anonymous calls (return 204 without a token).
|
||||
10. Fix the frontend `tsc` errors so `npm run build` passes.
|
||||
@@ -1,98 +0,0 @@
|
||||
# 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:**
|
||||
- [x] `is_admin` field exists in the database model (blocked by the missing `Boolean` import)
|
||||
- [x] Backend validates both the JWT and the `is_admin` flag
|
||||
- [x] Non-admin users receive 403 Forbidden
|
||||
- [x] Error message is "Admin access required"
|
||||
|
||||
**Must have for score above 4:**
|
||||
- [x] All admin CRUD endpoints are protected server-side
|
||||
- [x] Search is filtered on the backend (title OR url), in code
|
||||
- [ ] Sort parameters change the query (`created_at` ignores `sort_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
|
||||
|
||||
1. **Admin UI is mostly placeholder.** The dashboard does not list items. Stubs in `adminApi.listItems` and `adminApi.getItem` return fake data, so the UI looks like it works but never talks to the backend.
|
||||
2. **Lexical packages installed but unused.** `@lexical/react` and `lexical` are in `package.json` and not imported. The M6 spec requires a working Lexical editor with formatting.
|
||||
3. **No route from the site to the admin area.** `Header.tsx` has no admin link, and the dashboard has no edit or delete actions that lead to the edit page or the confirmation modal.
|
||||
4. **Nested `AdminLayout`.** Wrapping the same layout in both the route and the page doubles the sidebar.
|
||||
5. **`seed_admin.py` prints 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 (from `db/session.py`). The message is misleading, but the seeding itself goes through the app engine.
|
||||
6. **Frontend and backend admin routes do not match the spec's file layout.** `adminApi.ts` is inside `client.ts`, and `AdminModal.tsx` is absent (optional).
|
||||
7. **Docs overstate the work.** `docs/admin-area.md` (242 lines) describes features that are placeholders or not wired up.
|
||||
8. **Unresolved earlier blockers.** `config.py` `class Config` (M2), missing `httpx` (M2/M5), placeholder `response_model=list[Article]` routes (M5), and the `jwt`/`python-jose` mismatch (M5). Also `docker-compose.yml` still references undefined `backend-db` (M4).
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Fix the import blockers: import `HTTPAuthorizationCredentials` from `fastapi.security`, import `Boolean` in `app/models.py`, remove `class Config` from `config.py`, and add `httpx` and `PyJWT` to `requirements.txt`.
|
||||
2. Add `url` (String, nullable) and `points` (Integer, default 0) columns to the `Article` model, and add a small migration or a note to recreate the table.
|
||||
3. Return the user object (or a dict built from its fields) from `get_current_admin` instead of `model_dump`.
|
||||
4. Make `sort_order` apply to `created_at` as well, and pass `sort_by`/`sort_order` from the frontend.
|
||||
5. Implement `listItems` and `getItem` with real `fetch` calls, and wire the dashboard to render a table with pagination, page size, and a debounced search.
|
||||
6. Render `DeleteConfirmation` from the dashboard row actions, with ESC and outside-click dismissal.
|
||||
7. Replace the textarea with a real Lexical editor (`LexicalComposer`, `RichTextPlugin`, `ContentEditable`) and wire the toolbar to Lexical commands.
|
||||
8. Remove the `AdminLayout` wrappers from the pages, keeping only the route-level wrapper.
|
||||
9. Add admin tests: 403 for non-admins, pagination, search, sort, and the create/update/delete flows.
|
||||
Reference in new issue
Block a user