Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a43a9f1cd | ||
|
|
0a51f7d60f | ||
|
|
e64b72454f | ||
|
|
7f0c49ff6c | ||
|
|
f371d15c18 | ||
|
|
5168b13044 | ||
|
|
10da55b377 | ||
|
|
b27ef3ae19 | ||
|
|
b49cdc7f01 |
No files matched your search
-259
@@ -1,259 +0,0 @@
|
||||
# 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,93 +0,0 @@
|
||||
# newzy - News Web Application
|
||||
|
||||
A modern, responsive news web application built for efficient content management and user engagement.
|
||||
|
||||
## Overview
|
||||
|
||||
**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:
|
||||
|
||||
- Real-time news updates
|
||||
- Category-based filtering
|
||||
- User-friendly search functionality
|
||||
- Responsive design for mobile and desktop
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, ensure you have the following installed:
|
||||
|
||||
- [Node.js](https://nodejs.org/) (v18 or higher)
|
||||
- [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/)
|
||||
- [Git](https://git-scm.com/)
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
### 1. Clone the Repository
|
||||
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd newzy
|
||||
```
|
||||
|
||||
### 2. Install Dependencies
|
||||
|
||||
```bash
|
||||
npm install
|
||||
# or
|
||||
yarn install
|
||||
```
|
||||
|
||||
### 3. Environment Configuration
|
||||
|
||||
Copy the example environment file and configure it:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Update the `.env` file with your specific configuration (database credentials, API keys, etc.).
|
||||
|
||||
### 4. Run Development Server
|
||||
|
||||
```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
@@ -1,253 +0,0 @@
|
||||
# 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>`
|
||||
@@ -1,95 +0,0 @@
|
||||
# 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
|
||||
@@ -0,0 +1,30 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,64 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,77 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,71 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,99 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,98 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,44 @@
|
||||
# M1: Setup Git Project - Score Report
|
||||
|
||||
**Model:** qwen3.8-27b
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), recreated repo
|
||||
**Origin:** `https://gitea.samson.media/daniel/newz-qwen-27b.git`
|
||||
**Rubric:** `milestone/m1-setup-git-project-scoring.md`
|
||||
|
||||
## Total Score: 7 / 9 (Overall level 1 - partial)
|
||||
|
||||
The only deduction is the repository name. The project is "newzy" and the README title says so, but the repo is `newz` locally and `newz-qwen-27b` on origin. This is the same judgment used for the qwen3.5-9b run, so the two scores are comparable. If the name is accepted as-is, the score is 9 / 9.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `git ls-remote origin` | `main` and `develop` both point to `357a721`, matching local. |
|
||||
| `main` vs `develop` | Identical (single commit `357a721 chore: initial project setup for newzy`). |
|
||||
| Tracked files | 9 files, all committed in the initial commit. |
|
||||
| `.gitignore` | Present. Excludes `node_modules`, `.env*` (with `!.env.example` exception), logs, build output, IDE files, OS files, `data/`, and DB files. |
|
||||
| `.env.example` | Not ignored (the `!.env.example` rule takes effect). |
|
||||
| `hooks/pre-push` | Present and executable in the repo, but **inactive**: `core.hooksPath` is not set. CONTRIBUTING says to run `git config core.hooksPath hooks` per clone. |
|
||||
| Prompt parity | `milestones/m1-setup-git-project-prompt.md` is byte-identical to the copy in the benchmark repo. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Repository Setup | 0 | 2 | Repo is named `newz` / `newz-qwen-27b`, not `newzy`. `.gitignore` and an initial commit are present, so the only failing check is the name. |
|
||||
| Branch Strategy | 2 | 2 | `main` and `develop` both exist on local and origin, at the same commit. `docs/branching.md` documents the model, feature/bugfix/hotfix flows, and merge and rebase procedures. |
|
||||
| Documentation Files | 3 | 3 | `.gitignore`, `README.md` (52 lines, quick start and status table), `CONTRIBUTING.md` (104 lines, workflow, review, releasing), and `LICENSE` (MIT, 2026). Plus `docs/` with `branching.md` (89 lines), `commits.md` (81 lines), and `conventions.md` (57 lines). |
|
||||
| Git Best Practices | 2 | 2 | `docs/commits.md` explains Conventional Commits with an allowed-types table, six sample messages (including a breaking change), and rules of thumb. Merge and rebase workflows are in `docs/branching.md`. |
|
||||
| **Total** | **7** | **9** | |
|
||||
|
||||
## Other Observations
|
||||
|
||||
- The README quick start clones `newz-qwen-27b.git` into a directory named `newzy`. That is internally consistent, but it does not match the repo name, so new contributors will see two names.
|
||||
- The pre-push hook is versioned but does nothing until each clone runs `git config core.hooksPath hooks`. The rubric lists "pre-push hooks for code quality checks" as a git configuration requirement, so enabling it by default (for example, a setup script or `make` target) would close that gap.
|
||||
- The `hooks/pre-push` script is a no-op because there is no `package.json` yet, which matches the documented behaviour.
|
||||
- Commit identity is `Daniel Samson <daniel@samson.media>`, correctly configured.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Rename the repository and the origin remote to `newzy`, so the directory, remote, and README agree.
|
||||
2. Document how to activate the hooks in one step, or add a setup target that runs `git config core.hooksPath hooks`.
|
||||
@@ -0,0 +1,56 @@
|
||||
# M2: Setup Backend - Score Report
|
||||
|
||||
**Model:** qwen3.8-27b
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), committed HEAD `9a6f75e` on `feature/setup-backend`
|
||||
**Rubric:** `milestone/m2-setup-backend-scoring.md`
|
||||
|
||||
## Total Score: 24 (21 / 25 base + 3 bonus) - Overall level 2
|
||||
|
||||
The committed backend is complete and runs. The points lost are a missing cascade configuration on the relationships and a few endpoints the M2 prompt does not require.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `git archive HEAD backend` → clean venv from `requirements.txt` → `pytest` | **19 passed**, 1 warning, **95% coverage** (400 statements, 21 missed). |
|
||||
| `uvicorn main:app` on the committed tree | `GET /health` 200 `{"status":"ok","version":"0.1.0"}`; `GET /api/v1/health` 200; `GET /api/v1/version` 200 `{"app":"newzy","version":"0.1.0"}`; unknown route 404 with `{"detail":"Not Found","code":"not_found"}`. |
|
||||
| `docker build` of `backend/Dockerfile` | **Succeeds.** |
|
||||
| `docker run` of the built image | `/health` and `/api/v1/version` both return 200. |
|
||||
| Prompt parity | `milestones/m2-setup-backend-prompt.md` is byte-identical to the benchmark copy. |
|
||||
| Remote | `origin/main` and `origin/develop` are still at the M1 commit. **The M2 commit exists only on the local `feature/setup-backend` branch and is not pushed.** |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Application Structure | 2 | 2 | `core/`, `api/v1/`, `db/`, `models/`, `schemas/`, `tests/` (conftest, test_health, test_version, test_models), `main.py`, `config.py`, `requirements.txt`, `Dockerfile`, `.gitignore`, `pytest.ini`, `README.md`. |
|
||||
| Database Setup | 2 | 2 | SQLAlchemy 2.0 engine from `DATABASE_URL`, parent directory auto-created, `PRAGMA foreign_keys=ON` on every SQLite connection, `./data/db` bind-mounted in compose, and `VOLUME /app/data/db` in the Dockerfile. |
|
||||
| Models Implementation | 2 | 3 | Article, Author, and Category have the specified fields, unique constraints (title, name, email, slug), foreign keys with indexes, and relationships. **No cascade delete is configured** on the relationships, so this is not level 3. |
|
||||
| Endpoints | 2 | 2 | `GET /health`, `GET /api/v1/health`, and `GET /api/v1/version` return correct JSON with 200. |
|
||||
| Documentation | 2 | 2 | `backend/README.md` (199 lines): project structure, local and Docker startup, test commands, configuration table, endpoint examples, error format, data model, Docker notes, and limitations. |
|
||||
| Test Infrastructure | 3 | 3 | `pytest.ini` (discovery, coverage, `pythonpath`), `conftest.py` with per-test temporary SQLite databases, and all three test files present. |
|
||||
| Test Coverage | 3 | 3 | All 19 tests pass. Coverage is 95%, above the 70% target. |
|
||||
| Docker Support | 2 | 2 | The image builds, starts under uvicorn on port 8000, and serves the endpoints. |
|
||||
| Code Quality | 3 | 3 | Standardized `{detail, code, errors?}` envelope for HTTP, validation (422), and unhandled (500) errors. Type hints and docstrings throughout. Clear separation of config, session, models, schemas, and routes. |
|
||||
| **Base total** | **21** | **25** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Exception handling with status codes and schema-level validation:** awarded. Errors map to codes such as `not_found` and `validation_error`, and the schemas use `Field` constraints.
|
||||
- **+2 Unit tests for core functionality and README with startup and configuration examples:** awarded. Models and endpoints are tested, and the README has startup steps and a configuration table.
|
||||
- **+3 Docker Compose plus performance optimizations:** Compose is present, but there are no connection pooling or async query optimizations, so this is **not awarded**.
|
||||
|
||||
Bonus total: +3.
|
||||
|
||||
## Other Observations
|
||||
|
||||
- The M2 commit is on `feature/setup-backend`, which is checked out locally and has not been pushed. It is based on the M1 commit, so `develop` does not yet contain the backend.
|
||||
- The commit message says "19 tests, ~95% coverage", which matches the verified result.
|
||||
- The Article, Author and Category models have no cascade rules. Deleting an author who has articles will fail when foreign keys are enforced (the FK pragma is on), which is safe, but the behaviour is not documented.
|
||||
- The Docker healthcheck in `docker-compose.yml` uses `python -c urllib...` against `localhost:8000`. This works inside the container, which is the correct place for it.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Add `cascade="all, delete-orphan"` (or an explicit `ondelete` policy) to the Author and Category relationships, and document the chosen behaviour in the README.
|
||||
2. Push `feature/setup-backend` and merge it into `develop` through a pull request, so the backend is on the integration branch.
|
||||
3. For the +3 bonus, add a connection-pool setting for the non-SQLite case or an async session option, if the project will need them.
|
||||
@@ -0,0 +1,73 @@
|
||||
# M3: Setup Frontend - Score Report
|
||||
|
||||
**Model:** qwen3.8-27b
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), committed `frontend/` on `develop` (merge `253052c`, PR #3)
|
||||
**Rubric:** `milestone/m3-setup-frontend-scoring.md`
|
||||
|
||||
## Total Score: 41 (35 base + 6 bonus) - Overall level 1 as delivered
|
||||
|
||||
**Overall level 1 as delivered.** A clean checkout of `develop` does not build: `src/pages/Home.tsx` and `src/pages/CategoriesPage.tsx` import `../data/sample`, which is not committed. The root `.gitignore` excludes `data/`, which also matches `frontend/src/data/`. The file exists in the working tree only. With that file restored, the build, lint, unit tests, E2E tests and Docker image all pass, and the overall level would be 3.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
All checks ran on a clean `git archive` export of `develop`, except where noted.
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `npm ci` | Installs. Warnings about esbuild install scripts only. |
|
||||
| `npm run build` (clean export) | **Fails.** `TS2307: Cannot find module '../data/sample'` in `Home.tsx` and `CategoriesPage.tsx`, followed by implicit-any errors. |
|
||||
| `npm run build` (with `src/data/sample.ts` copied in) | **Passes.** `tsc` reports 0 errors; `vite build` produces `dist/`. |
|
||||
| `npm run lint` | Exit 0. |
|
||||
| `npx vitest run` | **5 files, 23 tests, all pass.** |
|
||||
| Unit coverage (`src/components`, `src/pages`, `src/api`) | Components: 100% statements, 93.9% branches, 100% lines. Pages and API client are not exercised by unit tests. |
|
||||
| `npx playwright test --project=chromium` (with sample file) | **9 passed.** Covers the shell and branding, featured article and grid, router-link navigation without a full reload, article card to placeholder, console errors, and four API-client tests. |
|
||||
| `docker build` (clean export) | **Fails** with the same missing-module error (`npm run build` exit 2). |
|
||||
| `docker build` (with sample file) and `docker run` | Builds. SPA routes `/`, `/articles`, `/categories`, `/articles/1` and unknown paths return 200 (the unknown path renders the 404 component). `/api/v1/version` returns 502 because the backend is not running in this test. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Project Setup | 2 | 2 | `frontend/` contains `public/`, `src/` (`assets/`, `components/`, `pages/`, `types/`, `api/`, `tests/`, `lib/`), and `playwright/`. |
|
||||
| TypeScript & Dependencies | 4 | 5 | `strict: true`. `react-router-dom ^6.20.0`, `lucide-react` and typed API client are used by components. `tsc` passes with the sample file present. Not level 5 because the build fails from a clean checkout. |
|
||||
| UI Components | 5 | 5 | `Header` uses `NavLink` with Home, FileText and Settings icons, a mobile menu with `aria-expanded` and `aria-controls`, and labelled navigation. `Layout`, `ArticleCard`, `AuthorAvatar` and `CategoryBadge` exist and are tested. |
|
||||
| React Router Configuration | 5 | 5 | `BrowserRouter` wraps the app in `App.tsx`. Routes: `/`, `/articles`, `/articles/:id`, `/categories`, and a `*` 404 route. Navigation uses `NavLink`/`Link`. The E2E test checks that navigation does not trigger a full page load. |
|
||||
| Page Components | 3 | 3 | `Home`, `ArticlePage` and `CategoriesPage` live in `pages/` and are mapped in `App.tsx`. |
|
||||
| API Integration | 2 | 2 | `api/client.ts` has a configurable base URL, a fetch wrapper that converts failures to `ApiError`, and typed endpoint functions. |
|
||||
| Unit Testing | 3 | 4 | 23 tests across Header, Layout, ArticleCard, AuthorAvatar and CategoryBadge, using React Testing Library. No unit tests for the API client's error handling (level 4 requires them). |
|
||||
| E2E Testing | 5 | 6 | 9 Playwright tests (chromium) pass, covering layout, navigation without reload, and the article card flow. No accessibility-scanner checks, so level 6 is not met. |
|
||||
| Docker Configuration | 2 | 3 | Multi-stage Dockerfile (`node:20-alpine` build, `nginx:1.27-alpine` serve). The compose file has `frontend` on port 3000:80 with `depends_on: backend: service_healthy`. But the build fails from a clean checkout, so level 3 is not met. |
|
||||
| Code Quality | 2 | 2 | ESLint runs and passes. TypeScript strict mode. Consistent React and hooks rules. |
|
||||
| Documentation | 2 | 3 | `frontend/README.md` (240 lines) covers scripts, structure, routing, API client, testing, Docker, environment variables, lucide icons and troubleshooting. No per-component prop documentation, so level 3 is not met. |
|
||||
| **Base total** | **35** | **49** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 ESLint rules configured:** awarded. `.eslintrc.cjs` enables TypeScript, React and hooks rules, and lint passes.
|
||||
- **+2 TypeScript strict mode and typed components:** awarded. `strict: true`, and components have typed props and interfaces.
|
||||
- **+3 Root compose orchestration, SPA `try_files` fallback, and E2E routing checks without reloads:** awarded. All three are present.
|
||||
|
||||
Bonus total: +6.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
- [x] `lucide-react` installed and used
|
||||
- [x] `react-router-dom` installed and used
|
||||
- [x] `BrowserRouter` configured in `App.tsx`
|
||||
- [x] `<Link>`/`<NavLink>` used for navigation (no plain anchors in the app)
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **Missing `src/data/sample.ts` in git.** The root `.gitignore` line `data/` excludes `frontend/src/data/`. Narrow the rule (for example, `/data/` anchored at the repo root), or move the sample module to `src/lib/` or `src/mocks/`, and commit it. This is the single blocker for the build and the Docker image.
|
||||
2. **API proxy only tested without a backend.** Nginx returns 502 for `/api` when the backend is down. This is correct behaviour, but the frontend renders a fallback. A full stack run has not been tested in this scoring pass.
|
||||
3. **No unit tests for `api/client.ts`.** The fetch wrapper, `ApiError` mapping, and network-error path are untested.
|
||||
4. **Pages and API client have no coverage in the unit run.** Only components are exercised.
|
||||
5. **No "Search" icon** in the Header, although the M3 acceptance criteria list `Search` among the lucide icons. The search bar is also absent.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Commit `src/data/sample.ts` (fix the `.gitignore` rule), then confirm `npm run build` and `docker build` pass from a fresh clone. This moves the overall level to 3.
|
||||
2. Add unit tests for `api/client.ts`: success, non-2xx error envelope, and network failure.
|
||||
3. Add an accessibility check to the E2E suite (for example, `@axe-core/playwright`).
|
||||
4. Add prop documentation for the shared components (`Header`, `Layout`, `ArticleCard`, `AuthorAvatar`, `CategoryBadge`) to the README.
|
||||
5. Add the `Search` icon to the header or to the planned search bar.
|
||||
@@ -0,0 +1,72 @@
|
||||
# M4: Setup Developer Environment - Score Report
|
||||
|
||||
**Model:** qwen3.8-27b
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), committed `origin/develop` at `ed7b304` (M4 commit, after `9144411` sample-data fix)
|
||||
**Rubric:** `milestone/m4-setup-developer-environment-scoring.md`
|
||||
|
||||
## Total Score: 20 (17 / 29 base + 3 bonus) - Overall level 1 as delivered
|
||||
|
||||
**Overall level 1 as delivered.** On this machine, `make dev` (`docker compose up -d --build`) fails in the repo's own directory. The compose file hardcodes subnet `172.28.0.0/16` for `newzy-network`, and that range is already used by the running `newz_newzy-network` network from your working copy. Docker reports `Pool overlaps with other one on this address space`, so the stack does not start. The stack does work once the subnet line is removed (tested in a temp copy, see below). The rubric's level 2 also asks for a `.env` file with defaults, and the repo has only `.env.example`.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
All checks ran on a clean `git archive` export of `origin/develop` in a temp directory. I did not touch the running `newz` stack.
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| `docker compose config -q` | Passes. |
|
||||
| `make help` and `make -n` for dev, stop, restart, backend-start, frontend-start, clean | Targets expand as documented. |
|
||||
| `docker compose up -d --build` (as committed) | **Fails:** `Pool overlaps with other one on this address space` for `172.28.0.0/16`. |
|
||||
| Existing host state | A `newz` compose project is already running from `/home/daniel/Gitea/daniel/newz`, holding ports 3000 and 8000. I did not stop it. |
|
||||
| Same stack with the `ipam` block removed and host ports 13000/18000 (temp copy only) | **Starts.** Backend healthy. Via the frontend proxy: `/` and `/articles` return the SPA (200); `/api/v1/version` and `/api/v1/health` return 200 through nginx. |
|
||||
| Frontend container healthcheck | **Fails** with exit code 1 on every run. `wget http://localhost/` tries `[::1]:80`, but nginx listens on IPv4 only. The container reports `unhealthy`. (Confirmed on the running `newz-frontend-1` container as well.) |
|
||||
| Backend `pytest` (temp export) | 19 passed, 95% coverage. |
|
||||
| Frontend `npm run test` (temp export) | 23 passed in 5 files. |
|
||||
| Frontend `npm run e2e -- --project=chromium` (temp export) | 9 passed. |
|
||||
| Data directory after compose run | `./data/db` and `newzy.db` are created **owned by root**, so a non-root `rm -rf data/` (`make clean`) fails with `Permission denied`. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| docker-compose Configuration | 3 | 4 | Both services with the right build contexts, ports 3000 and 8000, a bridge network, the `./data/db` volume, `depends_on` with `service_healthy`, and restart policies. Backend has a working healthcheck. Frontend healthcheck is broken (see above). The hardcoded subnet stops the stack from starting on hosts where that range is taken. |
|
||||
| Environment Configuration | 2 | 3 | `.env.example` documents each variable with comments and defaults. `.env` is not in the repo; the README asks users to copy the template. `.env*` is git-ignored, with `!.env.example`. |
|
||||
| Development Commands | 3 | 4 | `dev`, `stop`, `restart`, `backend-start`, `frontend-start`, `build`, `logs`, `status`, shells, and `help` are present. `make test` runs frontend unit and backend tests, but E2E is a separate `make e2e` target, so `test` does not cover both. `clean` runs `rm -rf data/`, which fails on the root-owned database directory. `docker image prune -f` removes only dangling images. |
|
||||
| Security & Best Practices | 2 | 3 | `.env`, `.env.*`, and `data/` are git-ignored. `data/.gitignore` keeps the directory structure while excluding the database. `.dockerignore` files exist for both services. Deduction: the backend image runs as root (no `USER`). |
|
||||
| Documentation | 3 | 3 | README section covers prerequisites, quick start, services, ports, networking and storage, environment variables, Makefile reference, troubleshooting (including the `data/` ownership fix), and running without Docker. Subnet conflicts are not documented. |
|
||||
| Service Communication | 1 | 2 | Bridge network with frontend → backend proxying verified through nginx. Deduction: the fixed subnet prevents startup on hosts with an overlapping network, and the frontend healthcheck fails, so services are reported as not healthy. |
|
||||
| Build Optimization | 3 | 3 | Backend uses `python:3.11-slim`, `pip --no-cache-dir`, `PYTHONDONTWRITEBYTECODE`, and `PYTHONUNBUFFERED`. Frontend is multi-stage (`node:20-alpine` build, `nginx:1.27-alpine` serve) with `npm ci`. Both services have `.dockerignore`. |
|
||||
| **Base total** | **17** | **29** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Logs command and restart policies:** awarded. `make logs` and `restart: unless-stopped` on both services.
|
||||
- **+2 README Docker troubleshooting and `.dockerignore` files:** awarded. Troubleshooting section present, and both `.dockerignore` files exclude build artifacts.
|
||||
- **+3 Full test automation and clean that removes images:** not awarded. `make test` skips E2E, and `clean` does not remove all images.
|
||||
|
||||
Bonus total: +3.
|
||||
|
||||
### 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 (but its fixed subnet clashes on this host)
|
||||
- [x] `.env.example` present (`.env` not committed)
|
||||
|
||||
## Other Issues Found
|
||||
|
||||
1. **Hardcoded subnet `172.28.0.0/16`.** Remove the `ipam` block (let Docker pick a range), or make the subnet configurable. Currently `make dev` fails on any host where that range is taken, including this one.
|
||||
2. **Frontend healthcheck fails.** Change the Dockerfile `HEALTHCHECK` to `wget -qO- http://127.0.0.1/` (or make nginx listen on `[::]:80` as well). The container otherwise serves correctly.
|
||||
3. **Root-owned `data/` after first run.** The backend container creates `./data/db` as root. Use a non-root `user:` in compose, or pre-create the directory in the Makefile. Otherwise `make clean` fails for ordinary users.
|
||||
4. **`make test` does not include E2E.** Either add `e2e` to the `test` target, or document that `make test` is unit-only.
|
||||
5. **No `.env` default file.** The M4 prompt asks for one. A committed `.env` with dev defaults, or a `make env` target that copies the template, would satisfy it.
|
||||
6. **Backend runs as root.** Add a non-root `USER` to `backend/Dockerfile`.
|
||||
7. **Running stack from your working copy** is still up on ports 3000 and 8000, and its frontend container is `unhealthy` (see item 2).
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Remove the fixed subnet from `docker-compose.yml`.
|
||||
2. Fix the frontend `HEALTHCHECK` target to `127.0.0.1`.
|
||||
3. Make the database directory writable by the host user, and confirm `make clean` works from a non-root shell.
|
||||
4. Add `e2e` to `make test` and add a `.env` default or a copy target.
|
||||
5. Run the backend container as a non-root user.
|
||||
@@ -0,0 +1,78 @@
|
||||
# M5: Setup Authentication - Score Report
|
||||
|
||||
**Model:** qwen3.8-27b
|
||||
**Repository scored:** `../newz` (`/home/daniel/Gitea/daniel/newz`), local `develop` at `b186d0f` (M5 commit, **not yet pushed**; `origin/develop` is at `ed7b304`)
|
||||
**Rubric:** `milestone/m5-setup-authentication-scoring.md`
|
||||
|
||||
## Total Score: 44 (40 base + 4 bonus) - Overall level 5
|
||||
|
||||
Overall level 5: all level 2 to 4 criteria are met, all three auth pages exist, and the forms validate input with loading states and status-coded errors. The backend, frontend build and tests all pass on the committed tree.
|
||||
|
||||
## Verification Performed
|
||||
|
||||
All checks ran on a clean `git archive b186d0f` export in a temp directory.
|
||||
|
||||
| Check | Result |
|
||||
|---|---|
|
||||
| Prompt parity | `milestones/m5-setup-authentication-prompt.md` in the commit is identical to the benchmark copy. |
|
||||
| Backend `pytest` | **51 passed**, 97% coverage (649 statements, 18 missed). |
|
||||
| Live backend (uvicorn) | `register` 201 with JWT; `me` 200 with a valid token; `me` 401 with no token and with a tampered token; `login` 200 on correct password and 401 on wrong password; duplicate register 400; invalid username 422; `logout` 204. The token's `exp - iat` is 604800 seconds (7 days). |
|
||||
| Password storage | No plaintext password appears in any database file. |
|
||||
| Frontend `npm ci` and `npm run build` | Pass (`tsc` and `vite build`, no errors). |
|
||||
| Frontend `npx vitest run` | **9 files, 53 tests, all pass.** |
|
||||
| Frontend `npm run e2e -- --project=chromium` | **19 passed**, including `auth.spec.ts`. |
|
||||
| `/api/auth/*` (path in the milestone prompt) | Returns 404. The routes live under `/api/v1/auth/*`, following the M2 prefix. The commit message records this as a deliberate choice. |
|
||||
| Docker | Not re-run in this pass. On this host, `make dev` still fails on the hardcoded subnet from M4. |
|
||||
|
||||
## Scoring by Criterion
|
||||
|
||||
| Criterion | Score | Max | Notes |
|
||||
|---|---|---|---|
|
||||
| Backend User Model | 3 | 3 | `User` has `id`, `username` (String(60), unique, indexed), `password_hash` (String(128)), and `created_at` (timezone-aware, defaulted). |
|
||||
| Password Hashing | 4 | 4 | PBKDF2-HMAC-SHA256 with 120,000 iterations. Salt from `secrets.token_hex(16)`, stored as `salt$digest`. `verify_password` uses `secrets.compare_digest`. Tests cover round-trip, unique salts, and malformed stored values. |
|
||||
| JWT Token System | 5 | 5 | `create_token` sets `sub`, `iat`, `exp` (7 days), signs with HS256 using `HN_SECRET_KEY` (dev default marked as change-me). Decoding validates the signature, expiry, and that the user still exists. Tests cover wrong key and expired tokens. |
|
||||
| Backend Auth Endpoints | 5 | 5 | `register` (201, `{token, username}`, username regex, duplicate check), `login` (hash check, 401 on failure), `logout` (204, requires a token), `me` (Bearer validation). The duplicate-username check returns 400, matching the QA notes. Deviation: `/api/v1/auth/*` instead of `/api/auth/*`. |
|
||||
| Frontend Authentication Context | 5 | 5 | `AuthProvider` exposes `username`, `ready`, `login`, `register`, and `logout`. On load it calls `GET /auth/me` with the stored token and drops the token on failure. `Login` and `Register` go through the context, so the token is stored on success. `RequireAuth` guards protected routes. |
|
||||
| Token Storage & Management | 3 | 3 | `AUTH_TOKEN` is used consistently. Login and register store the token, logout removes it, and an invalid stored token is cleared on restore. |
|
||||
| API Client Auth Methods | 4 | 4 | `login`, `register`, `logout`, and `me` are implemented. The `Authorization: Bearer` header is attached to every request when a token exists. Non-2xx responses throw `ApiError`. |
|
||||
| Frontend Auth Pages | 5 | 6 | `Login`, `Register` (with client-side username, password-length and password-match checks, a disabled submit while busy, and error messages), and `SignOut` (routed at `/sign-out`, clears the token, redirects to `/login`). Deduction: no explicit success message after login or register, only a redirect. |
|
||||
| Security Implementation | 4 | 4 | PBKDF2 at 120k iterations, HS256, secret from `HN_SECRET_KEY` with a dev-only default, no plaintext passwords, and CORS configured from M2. |
|
||||
| Git Configuration | 2 | 2 | `backend/.gitignore` excludes `*.db`, `*.sqlite`, and `data/`. Root `.gitignore` excludes `.env` and `.env.*`. `data/.gitignore` names `newzy.db` and `data.db`. |
|
||||
| **Base total** | **40** | **46** | |
|
||||
|
||||
### Bonus
|
||||
|
||||
- **+1 Input validation and password strength:** awarded. Username regex `^[a-zA-Z0-9_]{3,20}$` on the backend and frontend, and passwords need at least 8 characters.
|
||||
- **+2 Non-leaking errors and rate-limit placeholders:** not awarded. Login errors are generic ("Invalid username or password"), but there are no rate-limit placeholder comments or code.
|
||||
- **+3 Complete error handling and protected-route redirect:** awarded. Errors are shown to the user, and `RequireAuth` redirects unauthenticated users to `/login`.
|
||||
|
||||
Bonus total: +4.
|
||||
|
||||
### Critical Requirements Checklist (from rubric)
|
||||
|
||||
**Must have for score above 1:**
|
||||
- [x] Passwords never stored as plaintext
|
||||
- [x] PBKDF2 with at least 100,000 iterations (SHA256)
|
||||
- [x] JWT uses HS256
|
||||
- [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
|
||||
- [x] `AUTH_TOKEN` persistence in localStorage
|
||||
- [x] Session check on load calls `/auth/me`
|
||||
- [x] 401 responses for invalid tokens
|
||||
|
||||
## Other Observations
|
||||
|
||||
1. **M5 is not on `origin/develop`.** The commit `b186d0f` exists only on local `develop`. Push it, or open a pull request from it, before treating M5 as delivered.
|
||||
2. **Endpoint path differs from the prompt.** The prompt says `/api/auth/*`, but the implementation uses `/api/v1/auth/*`, consistent with the M2 prefix. Either update the prompt or add an alias route.
|
||||
3. **No rate limiting.** The prompt lists rate limiting as a known limitation, so this is expected, but the bonus placeholder is missing.
|
||||
4. **Docker not re-verified.** The M4 subnet conflict on this host still blocks `make dev`, so the auth changes were not run inside containers in this pass.
|
||||
|
||||
## Path to a Higher Score
|
||||
|
||||
1. Push `develop` (or open a pull request) so M5 is on the remote.
|
||||
2. Add a success notice after login and register, to reach level 6 on the auth pages.
|
||||
3. Add a rate-limit placeholder comment or middleware stub on the auth endpoints for the +2 bonus.
|
||||
4. Reconcile the endpoint path with the milestone prompt, either by updating the prompt or adding `/api/auth` aliases.
|
||||
Reference in new issue
Block a user