File size: 4,023 Bytes
c5292d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Quick Start Guide

## Installation

1. **Install dependencies with uv**
```bash
uv sync
```

2. **Install Playwright browsers**
```bash
uv run playwright install chromium
```

3. **Set up environment variables**
```bash
cp .env.example .env
```

Edit `.env` and configure at minimum:
- `STUDENT_SECRET` - Your secret key
- `STUDENT_EMAIL` - Your email
- `GITHUB_TOKEN` - GitHub personal access token
- `GITHUB_USERNAME` - Your GitHub username
- `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` - LLM API key

## Running the System

### Option 1: Using main.py CLI

**Start Student API:**
```bash
uv run python main.py student-api
```

**Start Instructor API:**
```bash
uv run python main.py instructor-api
```

**Initialize Database:**
```bash
uv run python main.py init-db
```

**Run Round 1:**
```bash
uv run python main.py round1
```

**Run Evaluation:**
```bash
uv run python main.py evaluate
```

**Run Round 2:**
```bash
uv run python main.py round2
```

### Option 2: Direct module execution

**Start Student API:**
```bash
uv run python -m student.api
```

**Start Instructor API:**
```bash
uv run python -m instructor.api
```

## Testing the System

### 1. Test Student API

Start the student API:
```bash
uv run python main.py student-api
```

In another terminal, send a test request:
```bash
curl -X POST http://localhost:8000/api/build \
  -H "Content-Type: application/json" \
  -d '{
    "email": "your-email@example.com",
    "secret": "your-secret",
    "task": "test-task-abc",
    "round": 1,
    "nonce": "unique-nonce-123",
    "brief": "Create a simple Hello World page with Bootstrap",
    "checks": ["Page displays Hello World", "Bootstrap is loaded"],
    "evaluation_url": "http://localhost:8001/api/evaluate",
    "attachments": []
  }'
```

Check status:
```bash
curl http://localhost:8000/api/status/test-task-abc
```

### 2. Test Instructor Workflow

**Start Instructor API:**
```bash
uv run python main.py instructor-api
```

**Initialize Database:**
```bash
uv run python main.py init-db
```

**Create submissions.csv:**
```csv
timestamp,email,endpoint,secret
2025-01-15T10:00:00,student@example.com,http://localhost:8000/api/build,your-secret
```

**Run Round 1:**
```bash
uv run python main.py round1
```

**Run Evaluation:**
```bash
uv run python main.py evaluate
```

**Check Results:**
```bash
curl http://localhost:8001/api/results/student@example.com
```

## Project Structure Overview

```
student/              # Student side (receives tasks, generates code)
β”œβ”€β”€ api.py           # API endpoint
β”œβ”€β”€ code_generator.py # LLM code generation
β”œβ”€β”€ github_manager.py # GitHub operations
└── notification_client.py # Notify evaluation

instructor/          # Instructor side (generates tasks, evaluates)
β”œβ”€β”€ api.py          # Evaluation endpoint
β”œβ”€β”€ database.py     # Database operations
β”œβ”€β”€ task_templates.py # Template management
β”œβ”€β”€ round1.py       # Generate round 1 tasks
β”œβ”€β”€ round2.py       # Generate round 2 tasks
β”œβ”€β”€ evaluate.py     # Run evaluations
└── checks/         # Evaluation checks
    β”œβ”€β”€ static_checks.py
    β”œβ”€β”€ dynamic_checks.py
    └── llm_checks.py

shared/             # Shared utilities
β”œβ”€β”€ config.py       # Configuration
β”œβ”€β”€ models.py       # Data models
β”œβ”€β”€ logger.py       # Logging
└── utils.py        # Utilities

templates/          # Task templates (YAML)
```

## Next Steps

1. Configure your `.env` file with actual credentials
2. Set up a PostgreSQL database (if using instructor features)
3. Review the task templates in `templates/`
4. Test the student API with a simple request
5. Set up the instructor system for evaluation

## Common Issues

**Import errors**: Make sure you run commands with `uv run` prefix

**GitHub auth errors**: Verify GITHUB_TOKEN in .env has proper permissions

**Database errors**: Make sure PostgreSQL is running and DATABASE_URL is correct

**LLM errors**: Check your API key and quota

For more details, see README.md