Markdown Converter
Agent skill for markdown-converter
This document provides comprehensive documentation for all service agents (services) in the Voice Grocery List App. These agents handle different aspects of the application's functionality and work together through the Service Manager pattern.
Sign in to like and favorite skills
This document provides comprehensive documentation for all service agents (services) in the Voice Grocery List App. These agents handle different aspects of the application's functionality and work together through the Service Manager pattern.
The application uses a Service-Oriented Architecture (SOA) where different agents (services) handle specific domains of functionality. All services extend a common
BaseService class that provides shared functionality like error handling, retry logic, and network status monitoring.
ServiceManager (Orchestrator) ├── ApiService (HTTP Communication) ├── AuthService (Authentication) ├── GroceryListService (List Management) └── GroceryIntelligenceService (NLP & Categorization)
All services extend
BaseService which provides:
Location:
src/services/ServiceManager.js
The Service Manager is the central orchestrator that initializes, manages, and coordinates all service agents.
// Get a specific service serviceManager.getService('auth') // Get all service statuses serviceManager.getServiceStatus() // Health check all services await serviceManager.healthCheck() // Initialize all services await serviceManager.initialize() // Restart a service await serviceManager.restartService('api') // Clear all caches serviceManager.clearAllCaches()
Services are accessible via:
serviceManager.apiService - API communicationserviceManager.authService - AuthenticationserviceManager.groceryListService - List operationsserviceManager.groceryIntelligenceService - Intelligence featuresOr via the registry:
serviceManager.services.api serviceManager.services.auth serviceManager.services.groceryList serviceManager.services.intelligence
Location:
src/services/ApiService.jsBaseService// Make HTTP request await apiService.makeRequest('/grocery-lists', { method: 'POST', body: JSON.stringify(data) }) // Test API connectivity await apiService.testConnectivity() // Health check await apiService.healthCheck()
VITE_API_BASE_URL environment variable (default: http://localhost:3001/api)Content-Type: application/jsonLocation:
src/services/AuthService.jsBaseServiceApiService// Register new user await authService.register({ firstName: 'John', lastName: 'Doe', email: '[email protected]', password: 'securePassword' }) // Login user await authService.login('[email protected]', 'password') // Logout user authService.logout() // Get current user const user = authService.getCurrentUser() // Check if user is authenticated const isAuth = authService.isAuthenticated() // Validate session await authService.validateSession()
groceryListTokengroceryListUserLocation:
src/services/GroceryListService.jsBaseServiceApiService// Get all lists for user await groceryListService.getUserGroceryLists(userId) // Get list for specific date await groceryListService.getGroceryListByDate(userId, '2024-01-15') // Create new list await groceryListService.createGroceryList(userId, date, items) // Update list await groceryListService.updateGroceryList(listId, updates) // Delete list await groceryListService.deleteGroceryList(listId) // Add item to list await groceryListService.addItemToList(listId, item) // Update item await groceryListService.updateItem(listId, itemId, updates) // Toggle item completion await groceryListService.toggleItemCompletion(listId, itemId) // Remove item from list await groceryListService.removeItemFromList(listId, itemId)
lists_${userId}, list_${listId}Location:
src/services/groceryIntelligence.js// Categorize an item const category = GroceryIntelligenceService.categorizeItem('basmati rice') // Correct spelling const corrected = GroceryIntelligenceService.correctSpelling('basmati rce') // Parse multiple items from text const items = GroceryIntelligenceService.parseItems('onion spinach milk') // Filter filler words const cleaned = GroceryIntelligenceService.filterFillerWords('uhh you know onion')
Smart Categorization
Spell Correction
Item Parsing
Filler Word Filtering
Location:
src/services/BaseService.jsAll services inherit these capabilities:
// Standardized error responses { success: false, error: 'Error message', context: { /* additional context */ } }
await this.executeWithRetry(async () => { // Operation that may fail }, { maxAttempts: 5, delay: 2000 })
online/offline eventsisServiceAvailable() method// Success response { success: true, data: { /* result data */ }, message: 'Operation completed successfully' } // Error response { success: false, error: 'Error message', context: { /* context */ } }
All services use centralized logger:
logger.info() - General informationlogger.success() - Successful operationslogger.warn() - Warningslogger.error() - Errorslogger.debug() - Debug informationServiceManager ├── ApiService (no dependencies) ├── AuthService → ApiService ├── GroceryListService → ApiService └── GroceryIntelligenceService (standalone)
Direct Service Access
const authService = serviceManager.getService('auth') await authService.login(email, password)
Service-to-Service
// AuthService uses ApiService internally class AuthService extends BaseService { constructor() { super('Auth') this.apiService = new ApiService() } }
Orchestrated Operations
// ServiceManager coordinates multiple services const result = await serviceManager.initialize()
Operation Attempt ↓ Error Occurs ↓ BaseService.handleError() ↓ Log Error ↓ Check if Retryable ↓ Retry (if applicable) OR Return Error Response
All services return consistent error format:
{ success: false, error: 'Human-readable error message', context: { // Additional error context timestamp: '2024-01-15T10:30:00Z', serviceName: 'Auth', operation: 'login' } }
Each service tracks:
// Check all services const health = await serviceManager.healthCheck() // Check individual service const apiHealth = await apiService.healthCheck() // Get service status const status = serviceManager.getServiceStatus()
{ success: true, data: { api: true, auth: true, groceryList: true, intelligence: true }, message: 'All services healthy' }
const stats = serviceManager.getServiceStats() // Returns: { totalServices: 4, healthyServices: 4, onlineServices: 4, services: { api: { healthy: true, online: true }, auth: { healthy: true, online: true }, // ... } }
import serviceManager from './services/ServiceManager.js' // Initialize all services await serviceManager.initialize() // Check if services are ready const status = serviceManager.getServiceStatus() if (status.api && status.auth) { // Services are ready }
const authService = serviceManager.getService('auth') // Register user const registerResult = await authService.register({ firstName: 'John', lastName: 'Doe', email: '[email protected]', password: 'securePassword' }) // Login const loginResult = await authService.login('[email protected]', 'password') if (loginResult.success) { const user = loginResult.data // User is now authenticated }
const groceryListService = serviceManager.getService('groceryList') const userId = authService.getCurrentUser()._id // Get today's list const today = new Date().toISOString().split('T')[0] const listResult = await groceryListService.getGroceryListByDate(userId, today) if (listResult.success) { const list = listResult.data // Use the list }
const intelligence = serviceManager.getService('intelligence') // Categorize item const category = intelligence.categorizeItem('basmati rice') // Returns: 'Asian Pantry' // Correct spelling const corrected = intelligence.correctSpelling('basmati rce') // Returns: { original: 'basmati rce', corrected: 'basmati rice', confidence: 0.9 } // Parse multiple items const items = intelligence.parseItems('onion spinach milk') // Returns: ['onion', 'spinach', 'milk']
success property in responses// ServiceManager is available globally in development window.serviceManager // Check service status window.serviceManager.getServiceStatus() // Test API connectivity await window.serviceManager.apiService.testConnectivity() // View service statistics window.serviceManager.getServiceStats()
serviceManager.initialize() firstisServiceAvailable() before operationsauthService.validateSession()serviceManager.clearAllCaches()Potential improvements to the agent architecture: