diff --git a/README.md b/README.md index a377f18..a604df0 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,14 @@ The model performing the benchmark will be scored against the acceptance criteri This benchmark consists of multiple milestones, each representing a separate task: +### M1: Git Repository Setup - [M1 - Setup Git Project](milestone/m1-setup-git-project-prompt.md) - [M1 - Setup Git Project Scoring](milestone/m1-setup-git-project-scoring.md) +### M2: Backend Infrastructure +- [M2 - Setup Backend](milestone/m2-setup-backend-prompt.md) +- [M2 - Setup Backend Scoring](milestone/m2-setup-backend-scoring.md) + ## Context management After each milestone the agents context MUST be cleared. This test the models reasoning capabilities and how it performs with incomplete information. diff --git a/milestone/m2-setup-backend-prompt.md b/milestone/m2-setup-backend-prompt.md new file mode 100644 index 0000000..ce6613c --- /dev/null +++ b/milestone/m2-setup-backend-prompt.md @@ -0,0 +1,167 @@ +# M2: Setup Backend + +## Prompt + +Create the backend infrastructure for **newzy** news web application using Python FastAPI. Follow these steps: + +1. Set up project structure: + ``` + newzy/ + ├── api/ + │ └── v1/ + │ └── __init__.py + ├── core/ + │ └── __init__.py + ├── db/ + │ └── session.py + ├── models/ + │ └── __init__.py + ├── schemas/ + │ └── __init__.py + ├── main.py + ├── config.py + └── requirements.txt + ``` + +2. Create FastAPI application in `main.py` with: + - Health check endpoint (`GET /health`) + - Version endpoint (`GET /api/v1/version`) + +3. Set up SQLAlchemy database session using SQLite (configured for Docker volume persistence) + +4. Define Pydantic schemas for basic models (Article, Author, Category) + +5. Configure `requirements.txt` with: + - FastAPI + - uvicorn + - SQLAlchemy + - pydantic + - python-multipart + +6. Create initial database models for: + - Article (title, content, author_id, category_id, created_at, published) + - Author (name, email, bio) + - Category (name, slug) + +7. Add proper exception handling and error responses + +8. Document API endpoints in README.md with examples + +Remember: Focus ONLY on backend infrastructure. No frontend implementation required. + +## Description + +This milestone sets up the FastAPI backend for newzy news application using Python. The scope includes database configuration, API structure, core models, and basic endpoints—no complex business logic or integration with other services. + +**Purpose**: Create a functional REST API backbone ready for feature development in subsequent milestones. + +**Target Audience**: Backend developers joining the project who need to understand and extend the API. + +**Expected Outcomes**: A running FastAPI server with database connectivity, core models defined, and documented endpoints ready for additional features. + +## Acceptance Criteria + +- [ ] FastAPI application created in `main.py` +- [ ] SQLAlchemy session configured with SQLite backend +- [ ] Database models defined: Article, Author, Category +- [ ] Pydantic schemas implemented for all models +- [ ] Health check endpoint (`GET /health`) returns 200 OK +- [ ] Version endpoint (`GET /api/v1/version`) returns application version +- [ ] `requirements.txt` lists all Python dependencies +- [ ] Proper error handling with standardized response format +- [ ] README.md documents API endpoints with examples +- [ ] Code follows FastAPI and SQLAlchemy best practices + +## Technical Details + +### Project Structure +``` +newzy/ +├── api/ +│ └── v1/ +│ └── __init__.py +├── core/ +│ ├── config.py # Application configuration +│ └── __init__.py +├── db/ +│ └── session.py # Database session management +├── models/ +│ ├── article.py # Article model +│ ├── author.py # Author model +│ └── category.py # Category model +├── schemas/ +│ ├── article.py # Article Pydantic schema +│ ├── author.py # Author Pydantic schema +│ └── category.py # Category Pydantic schema +├── main.py # Application entry point +├── requirements.txt # Python dependencies +└── README.md # API documentation +``` + +### Database Schema + +**Article Model:** +- `id`: Integer, primary key +- `title`: String(200), unique +- `content`: Text +- `author_id`: Integer, foreign key to Author +- `category_id`: Integer, foreign key to Category +- `created_at`: DateTime +- `published`: Boolean, default False + +**Author Model:** +- `id`: Integer, primary key +- `name`: String(100), unique +- `email`: String(255), unique +- `bio`: Text (nullable) + +**Category Model:** +- `id`: Integer, primary key +- `name`: String(100), unique +- `slug`: String(100), unique + +### API Endpoints + +| Method | Path | Description | +|--------|------|-------------| +| GET | /health | Health check endpoint | +| GET | /api/v1/version | Returns application version | +| GET | /api/v1/health | Alternative health check path | + +### Configuration +- Environment variables for database URL +- Docker volume configuration: `/data/db` mapped to SQLite file +- CORS enabled for frontend development + +## QA Notes + +### Testing Checklist +- [ ] Application starts without errors +- [ ] Health endpoint returns 200 OK +- [ ] Version endpoint returns correct format +- [ ] Database connection successful +- [ ] Models can be instantiated and committed +- [ ] Error responses follow standardized format +- [ ] No unhandled exceptions in basic operations + +### Performance Considerations +- Single-threaded async mode for development (uvicorn workers = 1) +- SQLite file-based storage (no connection pool needed yet) +- Lazy database session management + +### Security Notes +- Password hashing to be implemented in future milestones +- Authentication mechanism TBD +- CORS configuration should be validated before production + +### Known Issues / Limitations +- No input validation beyond Pydantic schemas +- No rate limiting implemented +- Database schema not yet optimized for performance +- Missing pagination and filtering on article endpoints + +### Success Metrics +- Application starts in under 10 seconds +- Health check responds within 100ms +- All models query successfully without errors +- README examples work as documented diff --git a/milestone/m2-setup-backend-scoring.md b/milestone/m2-setup-backend-scoring.md new file mode 100644 index 0000000..4e7abf6 --- /dev/null +++ b/milestone/m2-setup-backend-scoring.md @@ -0,0 +1,67 @@ +# M2: Setup Backend - Scoring Rubric + +## Acceptance Criteria Scoring Table + +| Score | Criteria | +|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 0 | Agent failed to implement acceptance criteria:
- No FastAPI application created
- Database session not configured
- Models missing or broken
- No endpoints implemented | +| 1 | Agent partially implemented acceptance criteria that builds successfully:
- Basic FastAPI app runs but no endpoints
- Database session fails on startup
- Some models defined but incomplete | +| 2 | Agent fully implemented acceptance criteria that builds successfully:
- FastAPI application with health and version endpoints
- SQLAlchemy configured with SQLite
- All three models (Article, Author, Category) created
- requirements.txt present | +| 3 | Agent fully implemented acceptance criteria that builds successfully, includes working Pydantic schemas for all models with validation examples
- Proper schema integration in API responses | +| 4 | Agent fully implemented acceptance criteria that builds successfully, includes passing unit tests for:
- Model CRUD operations
- Database session management
- Schema validation
- Endpoint response formats | +| 5 | Agent fully implemented acceptance criteria that builds successfully, includes all content from Score 4 AND:
- End-to-end integration test demonstrating full workflow
- Docker Compose configuration for database persistence
- Performance benchmarks showing acceptable latency | + +## Scoring Breakdown by Criterion + +### Application Structure (Max 2 points) +- **0 pts**: No FastAPI application or main.py missing +- **1 pt**: main.py exists but no proper structure (api/, core/, etc.) +- **2 pts**: Complete directory structure with all expected folders and files + +### Database Setup (Max 2 points) +- **0 pts**: No SQLAlchemy configuration or session setup
- Database connection fails +- **1 pt**: Session created but SQLite not configured properly
- Can connect to memory database only +- **2 pts**: Full SQLAlchemy setup with SQLite file storage, proper session management + +### Models Implementation (Max 3 points) +- **0 pts**: No models defined
- All three required models missing +- **1 pt**: One model partially or incorrectly implemented
- Missing relationships +- **2 pts**: All three models created with correct fields and relationships
- Can query without errors +- **3 pts**: Models fully functional with proper foreign keys, indexes where appropriate + +### Endpoints (Max 2 points) +- **0 pts**: No endpoints implemented
- Health endpoint missing or returns error +- **1 pt**: Health endpoint works but version endpoint broken
- Only one path defined +- **2 pts**: Both /health and /api/v1/version working with correct responses + +### Documentation (Max 2 points) +- **0 pts**: No README.md or incomplete
- No API documentation +- **1 pt**: README exists with basic info only
- Missing endpoint examples +- **2 pts**: Comprehensive README with full API documentation, examples, and usage instructions + +### Code Quality (Max 2 points) +- **0 pts**: No error handling
- Poor code organization +- **1 pt**: Basic error handling present
- Some best practices followed +- **2 pts**: Proper exception handling, standardized responses, follows FastAPI/SQAlchemy conventions + +## Total Possible Score: 15 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: +- Proper exception handling with appropriate HTTP status codes +- Input validation at schema level + +**+2 points** for: +- Unit tests covering core functionality +- README includes startup instructions + +**+3 points** for: +- Docker configuration ready for production use +- Performance optimizations (connection pooling, async queries)