[Backend] Bot CRUD - Bot Management with Max 3 Limit #16

Merged
shoko merged 1 commits from fix/issue-5 into main 2026-04-08 08:16:19 +02:00
Owner

Summary

Implement bot CRUD operations with the 3-bot limit per user constraint as described in issue #5.

Changes Made

Modified file: src/backend/app/api/bots.py

Implemented the following endpoints:

  • GET /api/bots - List user's bots (max 3) with JWT auth
  • POST /api/bots - Create new bot with 3-bot limit enforcement and unique name per user
  • GET /api/bots/{id} - Get bot details with ownership validation
  • PUT /api/bots/{id} - Update bot with ownership validation and unique name check
  • DELETE /api/bots/{id} - Delete bot with ownership validation
  • POST /api/bots/{id}/chat - Send message to bot (stores conversation)
  • GET /api/bots/{id}/history - Get chat history with ownership validation

Features Implemented

  • JWT authentication required for all endpoints (using existing get_current_user dependency)
  • Maximum 3 bots per user enforcement with clear error message
  • Bot name must be unique per user
  • Bot ownership validation (users can only access their own bots)
  • Proper HTTP status codes (201 for create, 204 for delete, 403 for unauthorized, 404 for not found)

Dependencies

  • Depends on issue #4 (Auth System - JWT Authentication) which was already merged in PR #15

Fixes #5

## Summary Implement bot CRUD operations with the 3-bot limit per user constraint as described in issue #5. ### Changes Made **Modified file:** `src/backend/app/api/bots.py` Implemented the following endpoints: - `GET /api/bots` - List user's bots (max 3) with JWT auth - `POST /api/bots` - Create new bot with 3-bot limit enforcement and unique name per user - `GET /api/bots/{id}` - Get bot details with ownership validation - `PUT /api/bots/{id}` - Update bot with ownership validation and unique name check - `DELETE /api/bots/{id}` - Delete bot with ownership validation - `POST /api/bots/{id}/chat` - Send message to bot (stores conversation) - `GET /api/bots/{id}/history` - Get chat history with ownership validation ### Features Implemented - JWT authentication required for all endpoints (using existing `get_current_user` dependency) - Maximum 3 bots per user enforcement with clear error message - Bot name must be unique per user - Bot ownership validation (users can only access their own bots) - Proper HTTP status codes (201 for create, 204 for delete, 403 for unauthorized, 404 for not found) ### Dependencies - Depends on issue #4 (Auth System - JWT Authentication) which was already merged in PR #15 ## Related Issue Fixes #5
shoko added 1 commit 2026-04-08 08:06:22 +02:00
han approved these changes 2026-04-08 08:15:32 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit 0cc3327991 into main 2026-04-08 08:16:19 +02:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/randebu#16