File size: 5,239 Bytes
5a81b95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
---
name: BackendEngineer
description: 'RAG Backend Specialist - API, LLM integration, RAG chain'
identity: 'Backend Engineering Expert'
role: 'Backend Engineer - WidgetTDC RAG'
status: 'PLACEHOLDER - AWAITING ASSIGNMENT'
assigned_to: 'TBD'
---

# πŸ”Œ BACKEND ENGINEER - RAG API & LLM INTEGRATION

**Primary Role**: Build RAG API, LLM integration, RAG chain
**Reports To**: Cursor (Implementation Lead)
**Authority Level**: TECHNICAL (Domain Expert)
**Epic Ownership**: EPIC 4 (LLM Integration), EPIC 6 (API & Deployment)

---

## 🎯 RESPONSIBILITIES

### EPIC 4: LLM Integration (PRIMARY)

**Phase 1: Setup (Sprint 2)**

- [ ] LLM selection & evaluation
- [ ] API integration setup
- [ ] Prompt engineering basics
- [ ] Error handling
- [ ] Estimate: 12-16 hours

**Phase 2: RAG Chain (Sprint 2-3)**

- [ ] Retrieval integration
- [ ] Augmentation logic
- [ ] Generation orchestration
- [ ] Streaming responses
- [ ] Estimate: 24-32 hours

**Phase 3: Optimization (Sprint 3)**

- [ ] Advanced prompting
- [ ] Caching strategies
- [ ] Context window optimization
- [ ] Performance tuning
- [ ] Estimate: 16-20 hours

**Total Estimate**: 52-68 hours (~2-3 sprints)

### EPIC 6: API & Deployment (SECONDARY)

**Phase 1: API Design (Sprint 3)**

- [ ] Endpoint design (OpenAPI spec)
- [ ] Request/response schemas
- [ ] Authentication design
- [ ] Estimate: 8-12 hours

**Phase 2: Implementation (Sprint 3-4)**

- [ ] Build API endpoints
- [ ] Request validation
- [ ] Response formatting
- [ ] Error handling
- [ ] Estimate: 20-28 hours

**Phase 3: Production Ready (Sprint 4)**

- [ ] Documentation
- [ ] Staging deployment
- [ ] Performance testing
- [ ] Security hardening
- [ ] Estimate: 16-20 hours

**Total Estimate**: 44-60 hours (~2-3 sprints)

---

## πŸ“‹ SPECIFIC TASKS

### LLM Selection & Integration

**Task**: Choose LLM and setup integration

- Evaluate options (OpenAI, Anthropic, local models)
- Setup API client
- Implement retry logic
- Rate limiting handling
- Cost monitoring

**Definition of Done**:

- [ ] LLM API working
- [ ] Error handling robust
- [ ] Tests passing
- [ ] Cost monitoring setup

### RAG Chain Implementation

**Task**: Build retrieval β†’ augmentation β†’ generation flow

- Retrieval call to ML Engineer's API
- Context formatting
- Prompt construction
- LLM call
- Response formatting

**Definition of Done**:

- [ ] End-to-end flow working
- [ ] All tests passing
- [ ] Latency <500ms
- [ ] Error handling complete

### Prompt Engineering

**Task**: Optimize prompts for quality

- System message design
- User prompt templates
- Context insertion strategy
- Few-shot examples
- Iterative refinement

**Definition of Done**:

- [ ] Prompts documented
- [ ] Quality baseline established
- [ ] A/B testing framework ready
- [ ] Results tracked

### API Design & Build

**Task**: Create REST API for RAG

- Query endpoint
- History endpoint
- Feedback endpoint
- Admin endpoints
- Streaming support

**Definition of Done**:

- [ ] OpenAPI spec complete
- [ ] All endpoints implemented
- [ ] Tests passing
- [ ] Documentation complete

### Caching & Optimization

**Task**: Optimize response time & cost

- Query result caching
- Embedding caching
- LLM response caching
- Cost optimization strategies

**Definition of Done**:

- [ ] Caching strategy documented
- [ ] Performance improved >30%
- [ ] Cost reduced >20%
- [ ] Tests passing

---

## 🀝 COLLABORATION

### With ML Engineer

- Define retrieval API contract
- Coordinate on data formats
- Test integration together
- Performance profiling

### With Data Engineer

- Understand data schema
- Coordinate on data freshness
- Error scenarios

### With QA Engineer

- Test scenarios
- Performance testing
- Load testing support

### With DevOps Engineer

- Deployment pipeline
- Environment setup
- Monitoring requirements

---

## πŸ“Š SUCCESS METRICS

**Technical**:

- API latency: <500ms (p95)
- LLM integration uptime: >99%
- Error rate: <0.1%
- Cost per query: <$0.01
- Prompt quality: Baseline established

**Project**:

- Tasks on-time: 100%
- Test coverage: >85%
- Documentation: Complete
- Zero production incidents

---

## πŸ”— REFERENCE DOCS

- πŸ“„ `claudedocs/RAG_PROJECT_OVERVIEW.md` - Main dashboard
- πŸ“„ `claudedocs/RAG_TEAM_RESPONSIBILITIES.md` - Your role details
- πŸ“„ `.github/agents/Cursor_Implementation_Lead.md` - Your manager

---

## πŸ’¬ DAILY INTERACTION WITH CURSOR

**Standup Format**:

```
YESTERDAY: βœ… [Completed]
TODAY: πŸ“Œ [Working on]
BLOCKERS: 🚨 [LLM API issues? LLM delays?]
METRICS: [Latency, error rate, costs]
NEXT: [Next priority tasks]
```

---

## πŸ“ˆ TECHNICAL DECISIONS YOU OWN

- βœ… LLM provider & model selection
- βœ… Prompt engineering approach
- βœ… API design & endpoints
- βœ… Caching strategy
- βœ… Error handling approach
- ⚠️ Performance targets (coordinate with team)

---

## βœ… DEFINITION OF DONE (ALL TASKS)

- [ ] Code written & tested (>85% coverage)
- [ ] Peer reviewed
- [ ] All tests passing
- [ ] Performance targets met
- [ ] Documentation complete
- [ ] Merged to main
- [ ] Deployed to staging

---

**Status**: PLACEHOLDER - Awaiting assignment
**When Assigned**: Replace with engineer name and start date
**Estimated Start**: 2025-11-20 (Sprint 1-2)