feat: add M3 setup frontend milestone with scoring rubric

- Add m3-setup-frontend-prompt.md with React + TypeScript + Vite setup instructions
- Add m3-setup-frontend-scoring.md with comprehensive acceptance criteria scoring (22 points)
- Update README.md with M3 frontend milestone links
This commit is contained in:
Daniel Samson committed 2026-10-29 15:50:24 +00:00
1 parent 48fcbf16f6
commit d66fe178c3
3 files changed
+400

No files matched your search

+4
View File
@@ -35,6 +35,10 @@ This benchmark consists of multiple milestones, each representing a separate tas
- [M2 - Setup Backend](milestone/m2-setup-backend-prompt.md) - [M2 - Setup Backend](milestone/m2-setup-backend-prompt.md)
- [M2 - Setup Backend Scoring](milestone/m2-setup-backend-scoring.md) - [M2 - Setup Backend Scoring](milestone/m2-setup-backend-scoring.md)
### M3: Frontend Application
- [M3 - Setup Frontend](milestone/m3-setup-frontend-prompt.md)
- [M3 - Setup Frontend Scoring](milestone/m3-setup-frontend-scoring.md)
## Context management ## Context management
After each milestone the agents context MUST be cleared. This test the models reasoning capabilities and how it performs with incomplete information. After each milestone the agents context MUST be cleared. This test the models reasoning capabilities and how it performs with incomplete information.
+322
View File
@@ -0,0 +1,322 @@
# M3: Setup Frontend
## Prompt
Create the frontend infrastructure for **newzy** news web application using React + TypeScript with Vite. Follow these steps:
1. Set up project structure in `frontend/` folder:
```
newzy/
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ │ └── Header.tsx
│ │ ├── pages/
│ │ │ └── Home.tsx
│ │ ├── types/
│ │ │ └── index.ts
│ │ ├── api/
│ │ │ └── client.ts
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── .gitignore
│ ├── Dockerfile
│ ├── docker-compose.yml
│ ├── package.json
│ ├── tsconfig.json
│ ├── vite.config.ts
│ └── README.md
```
2. Initialize Vite project with React and TypeScript template:
- Use Node.js 18 or later
- Install dependencies: react, react-dom, typescript, @types/react, @types/react-dom, vite
3. Configure Vite with:
- Base path configuration
- Build output directory (dist/)
- Development server on port 5173
4. Create TypeScript type definitions in `src/types/`:
- Article interface (id, title, content, author, category, published, createdAt)
- Author interface (id, name, email, bio)
- Category interface (id, name, slug)
- API response types
5. Create React components:
- `Header.tsx` with logo and navigation placeholder
- `Home.tsx` page component for listing articles
- Reusable UI components (ArticleCard, AuthorAvatar, CategoryBadge)
6. Set up API client in `src/api/client.ts`:
- Base URL configuration (relative path /api)
- Fetch wrapper with error handling
- Type-safe request/response functions
7. Create `package.json` scripts:
- dev: Development server
- build: Production build
- preview: Preview production build
- lint: ESLint check
8. Create `.gitignore` to exclude node_modules, dist/, .env files, IDE configs
9. Create `Dockerfile` for React + Vite with:
- Node.js base image
- Install dependencies
- Build frontend
- Nginx layer for serving static files in production
- Multi-stage build for optimization
10. Update `docker-compose.yml` at project root with frontend service:
- Port mapping 3000:80
- Links to backend service for API calls
11. Document setup process in `frontend/README.md` with examples
12. Configure ESLint rules in .eslintrc.cjs or vite.config.ts
Remember: Focus ONLY on frontend infrastructure. No complex UI features required yet.
## Description
This milestone sets up the React + TypeScript frontend for newzy news application using Vite as the build tool. The scope includes project scaffolding, type definitions, basic components, and Docker containerization—no complex UI implementations or user interactions.
**Purpose**: Create a responsive, type-safe frontend ready to consume the backend API built in M2.
**Target Audience**: Frontend developers who need to understand the structure and extend components for features in subsequent milestones.
**Expected Outcomes**: A functioning React application that can load from browser or Docker container, with typed interfaces matching backend models and basic page layout in place.
## Acceptance Criteria
- [ ] Vite project initialized with React and TypeScript
- [ ] Project structure includes: public/, src/, components/, pages/, types/, api/ folders
- [ ] TypeScript type definitions for Article, Author, Category models
- [ ] Header component created with navigation placeholder
- [ ] Home page component rendering article listing layout
- [ ] API client configured with base URL and fetch wrapper
- [ ] package.json has dev, build, preview scripts working correctly
- [ ] .gitignore excludes node_modules, dist/, IDE configs
- [ ] Dockerfile builds production-ready static files
- [ ] docker-compose.yml includes frontend service linked to backend
- [ ] Nginx configuration in Dockerfile for serving built files
- [ ] ESLint rules configured and passing
## Technical Details
### Project Root Structure
```
newzy/
├── frontend/
│ ├── public/
│ │ └── index.html # Vite entry HTML file
│ ├── src/
│ │ ├── assets/
│ │ │ ├── styles.css # Global styles
│ │ │ └── logo.svg # Brand logo (placeholder)
│ │ ├── components/
│ │ │ └── Header.tsx # Main navigation header
│ │ ├── pages/
│ │ │ └── Home.tsx # Homepage with article feed
│ │ ├── types/
│ │ │ └── index.ts # TypeScript interfaces
│ │ ├── api/
│ │ │ └── client.ts # API request wrapper
│ │ ├── App.tsx # Root component
│ │ └── main.tsx # React entry point
│ ├── .gitignore
│ ├── Dockerfile
│ ├── docker-compose.yml # Frontend service config
│ ├── package.json
│ ├── tsconfig.json
│ ├── vite.config.ts
│ └── README.md # Setup and API documentation
├── backend/ # Backend from M2
├── LICENSE # MIT License
├── README.md # Main project docs
└── docker-compose.yml # Full application orchestration
```
### TypeScript Type Definitions
```typescript
// src/types/index.ts
export interface Article {
id: number;
title: string;
content: string;
authorId: number;
author?: Author;
categoryId: number;
category?: Category;
createdAt: string;
published: boolean;
}
export interface Author {
id: number;
name: string;
email: string;
bio?: string;
}
export interface Category {
id: number;
name: string;
slug: string;
}
export interface ApiResponse<T> {
success: boolean;
data?: T;
error?: string;
message?: string;
}
```
### API Client Configuration
```typescript
// src/api/client.ts
const API_BASE_URL = '/api';
async function fetchApi<T>(endpoint: string): Promise<ApiResponse<T>> {
try {
const response = await fetch(`${API_BASE_URL}${endpoint}`);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error('API request failed:', error);
throw error;
}
}
export const apiClient = {
getArticles: () => fetchApi<Article[]>('/articles'),
getArticle: (id: number) => fetchApi<Article>(`/articles/${id}`),
getCategories: () => fetchApi<Category[]>('/categories'),
};
```
### package.json Scripts
```json
{
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint src/"
}
}
```
### Dockerfile (Multi-stage Build)
**Stage 1 - Build:**
```dockerfile
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
```
**Stage 2 - Serve:**
```dockerfile
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
```
### Nginx Configuration
```nginx
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
```
### docker-compose.yml (project root)
```yaml
version: '3.8'
services:
backend:
build: ./backend
ports:
- "8000:8000"
volumes:
- ./data/db:/app/data/db
environment:
- DATABASE_URL=sqlite:///./data/db/newzy.db
frontend:
build: ./frontend
ports:
- "3000:80"
depends_on:
- backend
```
### ESLint Configuration Rules
- No unused variables or imports
- TypeScript strict mode enabled
- Consistent indentation (2 spaces)
- No console.log in production code
- Prefer arrow functions for callbacks
## QA Notes
### Testing Checklist
- [ ] npm install completes without errors
- [ ] npm run dev starts Vite dev server successfully
- [ ] npm run build creates dist/ folder with all assets
- [ ] TypeScript compilation passes (no errors)
- [ ] ESLint check passes on codebase
- [ ] Components render correctly in browser
- [ ] API client returns properly typed responses
- [ ] Docker image builds without warnings
- [ ] Frontend container serves index.html at root
- [ ] nginx configuration routes requests to React SPA
### Performance Considerations
- Vite uses ESBuild for fast HMR during development
- TypeScript checks on build, not incremental dev
- Nginx serves static files efficiently in production
- Multi-stage Docker builds reduce image size
### Security Notes
- No sensitive data in client-side code
- API credentials should use backend proxy (not direct fetch)
- CORS must be configured on backend to accept frontend origin
- CSRF protection TBD for future milestones
### Known Issues / Limitations
- No authentication flow implemented yet
- Static file serving requires nginx restart on rebuild
- Vite HMR doesn't work in Docker without hot-reload support
- TypeScript path aliases not configured (using relative imports)
### Success Metrics
- `npm run dev` starts within 30 seconds
- `npm run build` produces <10MB production bundle
- TypeScript compilation completes under 5 minutes
- Docker frontend image size <200MB
- All ESLint rules pass with zero warnings in critical code
- Browser console has no errors on page load
+74
View File
@@ -0,0 +1,74 @@
# M3: Setup Frontend - Scoring Rubric
## Acceptance Criteria Scoring Table
| Score | Criteria |
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0 | Agent failed to implement acceptance criteria:<br>- No Vite/React project created<br>- TypeScript not configured<br>- Project structure missing key folders<br>- Components incomplete<br>- Dockerfile or docker-compose missing |
| 1 | Agent partially implemented acceptance criteria that builds successfully:<br>- Basic React app with vite but no typescript<br>- Missing multiple required folders<br>- Components render but have errors<br>- npm scripts incomplete |
| 2 | Agent fully implemented acceptance criteria that builds successfully:<br>- Vite + React + TypeScript project in frontend/ folder<br>- All required directories (components/, pages/, types/, api/) created<br>- Article, Author, Category TypeScript interfaces defined<br>- Header and Home components created<br>- package.json scripts (dev, build, preview) working<br>- .gitignore excludes node_modules, dist/, IDE configs |
| 3 | Agent fully implemented acceptance criteria that builds successfully, includes properly configured API client with error handling<br>- Types exported for all interfaces match backend models<br>- ESLint configuration present and passing |
| 4 | Agent fully implemented acceptance criteria that builds successfully, includes comprehensive TypeScript types with validation<br>- Proper function signatures in API client<br- Components use TypeScript props with proper typing |
| 5 | Agent fully implemented acceptance criteria that builds successfully, includes all content from Score 4 AND:<br>- Full docker-compose.yml at project root with both backend and frontend services<br>- Production-ready Nginx configuration for serving React SPA<br>- Performance benchmarks showing acceptable build times |
## Scoring Breakdown by Criterion
### Project Setup (Max 2 points)
- **0 pts**: No Vite/React project or not in frontend/ folder<br>- TypeScript missing entirely
- **1 pt**: Basic React app created but structure incomplete<br>- Missing api/, types/, pages/ folders
- **2 pts**: Complete directory structure with all required folders (public/, src/, components/, pages/, types/, api/)
### TypeScript Implementation (Max 3 points)
- **0 pts**: No TypeScript or tsconfig.json<br>- Plain JavaScript only
- **1 pt**: TypeScript enabled but no type definitions<br>- Partial interfaces
- **2 pts**: Article, Author, Category interfaces properly defined<br>- Types used in components
- **3 pts**: Comprehensive types including ApiResponse<T>, function signatures, validation
### Components (Max 3 points)
- **0 pts**: No components or App.tsx missing<br>- Application doesn't render
- **1 pt**: Only Header component created<br>- Home page incomplete
- **2 pts**: Header and Home components implemented correctly<br>- Components mount without errors
- **3 pts**: Reusable UI components (ArticleCard, AuthorAvatar, CategoryBadge) created
### API Integration (Max 2 points)
- **0 pts**: No API client or fetch not configured<br>- Cannot make requests to backend
- **1 pt**: Basic fetch wrapper exists but no error handling<br>- Missing type safety
- **2 pts**: api/client.ts with base URL configuration, fetch wrapper, and error handling<br>- Type-safe request/response functions
### Docker Configuration (Max 3 points)
- **0 pts**: No Dockerfile or .dockerignore<br>- Cannot containerize frontend
- **1 pt**: Basic Dockerfile but doesn't work<br>- Missing build steps or nginx config
- **2 pts**: Multi-stage Dockerfile with Node.js build and Nginx serve stages<br>- Application serves correctly from container
- **3 pts**: Complete docker-compose.yml with backend + frontend services, port mappings, depends_on
### Code Quality (Max 2 points)
- **0 pts**: No ESLint or linting fails<br>- Poor code organization
- **1 pt**: Basic ESLint rules configured but warnings present<br>- Inconsistent formatting
- **2 pts**: ESLint passing with zero critical warnings<br>- Consistent code style, type hints on all functions
### Documentation (Max 2 points)
- **0 pts**: No README.md or incomplete<br>- No setup instructions
- **1 pt**: README exists with basic info only<br>- Missing examples
- **2 pts**: Comprehensive README with setup guide, API documentation, and usage examples |
## Total Possible Score: 22 points
## Evaluation Notes
- Partial credit given for incomplete but working implementations (Score 1)
- Full credit requires all acceptance criteria met with passing verification (Score 2 minimum)
- Higher scores require additional value-add content beyond baseline requirements
- Score 0 indicates agent did not attempt the task or application won't run
## Bonus Points Consideration
**+1 point** for:
- ESLint rules properly configured and enforcing best practices
- .eslintrc.cjs or vite.config.ts includes meaningful linting rules
**+2 points** for:
- TypeScript strict mode enabled in tsconfig.json
- Components use proper TypeScript generics and props typing
**+3 points** for:
- docker-compose.yml at project root orchestrating both services
- Nginx configuration properly routes SPA (try_files with index.html fallback)