-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
apiREST API relatedREST API relatedbackendBackend API implementationBackend API implementationenhancementNew feature or requestNew feature or request
Description
Implement REST API Backend for ACP Mobile App
Overview
The ACP Mobile companion app requires a REST API backend with real-time updates via Server-Sent Events (SSE). This issue tracks the implementation of the backend services needed to support the mobile application.
Documentation
- Requirements Document:
docs/BACKEND_REQUIREMENTS.md - OpenAPI Specification:
specs/001-acp-mobile/contracts/acp-api.yaml - Base URL (staging):
https://ambient-code.apps.rosa.vteam-stage.7fpc.p3.openshiftapps.com/api/v1
Implementation Plan
Phase 1: Authentication (Week 1)
- Implement OAuth 2.0 + PKCE flow
- Integrate with Red Hat SSO
- Implement token refresh endpoint with automatic rotation
- Test token expiration and refresh mechanisms
Endpoints:
POST /auth/login- Initiate OAuth flow, return authorization URLPOST /auth/token- Exchange authorization code for JWT tokensPOST /auth/refresh- Refresh access token using refresh token
Requirements:
- PKCE support for mobile security
- JWT tokens with configurable expiration (default: 1 hour)
- Automatic token rotation on refresh
- Red Hat SSO integration
Phase 2: Core APIs (Week 2)
- Implement Sessions CRUD operations
- Implement Repositories API
- Implement User Profile & Preferences
- Add comprehensive error handling and validation
Endpoints:
GET/POST /sessions- List and create AI coding sessionsGET/PATCH /sessions/{id}- Get and update session detailsGET /sessions/{id}/logs- Get session execution logsGET/POST/DELETE /repos- Manage connected repositoriesGET/PATCH /user/profile- User profile managementGET/PATCH /user/preferences- User preferences (theme, notifications, quiet hours)
Data Models:
- Sessions: Track AI workflow execution with status, progress, and task history
- Repositories: User's connected GitHub repositories
- User preferences: Theme, notification settings, quiet hours configuration
Phase 3: Real-time Updates (Week 3)
- Implement SSE endpoint (
GET /sse/sessions) - Send session progress events (
session.progress) - Send session status transitions (
session.status) - Send session updates (
session.updated) - Test reconnection logic with exponential backoff
SSE Event Types:
session.progress- Incremental progress updates (don't trigger cache invalidation)session.updated- Partial session changes (client merges into cache)session.status- Status transitions (trigger notifications ifawaiting_review)notification.new- New GitHub notification (invalidates cache)notification.read- Notification marked as read (invalidates cache)
Requirements:
- Persistent SSE connection with automatic reconnection
- Events update client cache without full API refetch
- Exponential backoff on reconnection (1s → 30s max)
- Connection management for mobile (disconnect on background, reconnect on foreground)
Phase 4: GitHub Integration (Week 4)
- Integrate GitHub API for notifications
- Implement Notifications API
- Add workflow suggestion logic (analyze notification type → suggest appropriate workflow)
- Test notification flow end-to-end
Endpoints:
GET /notifications- List GitHub notifications with suggested workflowsPATCH /notifications/{id}- Mark notification as readPOST /notifications/{id}/mute- Mute notification thread
Workflow Suggestion Logic:
- Pull requests →
reviewworkflow - Issues with "bug" label →
bugfixworkflow - Feature requests →
planworkflow - General issues →
researchworkflow
Phase 5: Polish & Production Readiness (Week 5)
- Implement push token registration (
POST /user/push-token) - Integrate Expo push notification service
- Add comprehensive request/response validation (Zod/similar)
- Security audit (SQL injection, XSS, auth bypass)
- Performance testing (response times, SSE scalability)
- Load testing with realistic mobile usage patterns
Technical Requirements
Security
- All endpoints require authentication (except
/auth/*) - OAuth 2.0 with PKCE for mobile security
- JWT tokens with Bearer authentication
- HTTPS only in production
- Input validation on all endpoints
- SQL injection and XSS prevention
Performance
- Response time: <2 seconds for most endpoints
- SSE: Streaming, indefinite connection support
- Efficient database queries with proper indexing
- Rate limiting on authenticated endpoints
Error Handling
- Standard error response format:
{ "error": "ErrorType", "message": "Human-readable message", "details": {} } - Status codes: 200 (success), 201 (created), 204 (no content), 400 (bad request), 401 (unauthorized), 404 (not found), 500 (server error)
- 401 responses trigger automatic client token refresh (max 1 retry)
Third-party Integrations
- Red Hat SSO - OAuth authentication provider
- GitHub API - Fetch notifications, repository metadata
- Expo Push Service - Send push notifications to mobile devices
- Claude API - Chat feature (future implementation)
Development Support
Client Mock Data
The mobile client includes comprehensive mocks for development:
- Mock authentication (bypass OAuth)
- Mock sessions with realistic data and SSE events
- Mock GitHub notifications
- Environment variable toggles for selective mocking
Environment Variables
EXPO_PUBLIC_API_BASE_URL=https://ambient-code.apps.rosa.vteam-stage.7fpc.p3.openshiftapps.com/api/v1
EXPO_PUBLIC_OAUTH_DOMAIN=sso.redhat.com
EXPO_PUBLIC_OAUTH_CLIENT_ID=acp-mobileReference Implementation
- Client code:
services/api/(TypeScript API client) - Type definitions:
types/(data models) - Mock services:
services/mock/(expected behavior)
Acceptance Criteria
- All endpoints from OpenAPI spec implemented and tested
- OAuth 2.0 + PKCE authentication working with Red Hat SSO
- SSE connection stable with automatic reconnection
- GitHub notifications integration functional
- Push notifications working via Expo Push Service
- All endpoints validated with request/response schemas
- Security audit completed and issues addressed
- Performance testing shows <2s response times
- Production deployment successful on staging environment
Contact
For questions or clarification: Jeremy Eder (jeder@redhat.com)
Related: This backend will power the ACP Mobile companion app for AI-assisted development workflows. The client is built with React Native + Expo and uses React Query for data management.
Metadata
Metadata
Assignees
Labels
apiREST API relatedREST API relatedbackendBackend API implementationBackend API implementationenhancementNew feature or requestNew feature or request