
Summary
Developed a comprehensive Next.js-based prompt management application with full CRUD operations, import/export capabilities, variable templating, and modern UI components for managing AI prompts with advanced features.
Why Care
This application provides a complete solution for teams working with AI prompts, enabling efficient creation, organization, and iteration of prompt templates. The modular architecture and export/import functionality make it suitable for collaborative workflows and prompt versioning, while the variable templating system supports dynamic prompt generation for different use cases.
Implementation
Changes Made
Project Structure
prompt-manager/
├── src/
│ ├── app/
│ │ ├── layout.js (17 lines) - Root layout with metadata
│ │ ├── page.js (21 lines) - Main page with splash screen integration
│ │ ├── globals.css (144 lines) - Tailwind CSS styling
│ │ └── favicon.ico (31KB) - Application icon
│ └── components/
│ ├── PromptManager.js (265 lines) - Main application component
│ ├── CreatePromptModal.js (249 lines) - Prompt creation interface
│ ├── EditPromptModal.js (265 lines) - Prompt editing interface
│ ├── PromptCard.js (169 lines) - Individual prompt display
│ ├── CustomPropertiesSection.js (138 lines) - Advanced properties management
│ ├── ExportModal.js (580 lines) - Multi-format export functionality
│ ├── ImportModal.js (386 lines) - Markdown file import system
│ ├── DeleteConfirmModal.js (55 lines) - Confirmation dialogs
│ ├── SearchBar.js (20 lines) - Search functionality
│ ├── StatisticsSection.js (59 lines) - Usage analytics display
│ ├── ActionHeader.js (40 lines) - Action buttons and controls
│ ├── Navigation.js (18 lines) - Navigation component
│ └── SplashScreen.js (144 lines) - Welcome screen with animations
├── package.json (27 lines) - Dependencies and scripts
├── next.config.mjs (5 lines) - Next.js configuration
├── postcss.config.mjs (6 lines) - PostCSS configuration
├── eslint.config.mjs (15 lines) - ESLint configuration
├── jsconfig.json (8 lines) - JavaScript configuration
└── .gitignore (42 lines) - Git ignore patterns
Dependencies Added
- Core Framework: Next.js 15.4.4, React 19.1.0, React-DOM 19.1.0
- UI Components: Lucide React 0.525.0 (icon library)
- Markdown Editor: @uiw/react-md-editor 4.0.8 (rich text editing)
- File Processing: jszip 3.10.1 (ZIP file creation for exports)
- Styling: Tailwind CSS 4 (utility-first CSS framework)
- Development: ESLint 9, PostCSS 4
Configuration Files
- next.config.mjs: Next.js configuration with default settings
- postcss.config.mjs: PostCSS configuration for Tailwind CSS
- eslint.config.mjs: ESLint configuration with Next.js rules
- jsconfig.json: JavaScript path mapping and module resolution
- .gitignore: Comprehensive ignore patterns for Next.js projects
Technical Details
Core Application Architecture
The application follows a component-based architecture with the main PromptManager
component orchestrating all functionality:
// src/components/PromptManager.js - Main state management
const [prompts, setPrompts] = useState([]);
const [searchTerm, setSearchTerm] = useState('');
const [selectedPrompt, setSelectedPrompt] = useState(null);
Variable Templating System
Implemented automatic variable extraction from prompt content using regex patterns:
// Variable extraction from content
const extractVariables = (content) => {
const variableRegex = /\{\{([^}]+)\}\}/g;
const matches = [...content.matchAll(variableRegex)];
return [...new Set(matches.map(match => match[1]))];
};
Advanced Export Functionality
Multi-format export system supporting JSON, Markdown, and CSV with ZIP bundling:
// src/components/ExportModal.js - Export format handling
const exportToJSON = (prompt) => {
const exportData = {
name: prompt.name,
description: prompt.description,
content: prompt.content,
variables: prompt.variables,
category: prompt.category,
...(includeMetadata && {
createdAt: prompt.createdAt,
lastUsed: prompt.lastUsed,
usageCount: prompt.usageCount
})
};
return JSON.stringify(exportData, null, 2);
};
Markdown Import System
Intelligent markdown file parsing with automatic metadata extraction:
// src/components/ImportModal.js - Markdown parsing
const parseMarkdownFile = (content, filename) => {
const titleMatch = content.match(/^#\s+(.+)$/m);
const title = titleMatch ? titleMatch[1].trim() : filename.replace(/\.(md|markdown)$/i, '');
const variableRegex = /\{\{([^}]+)\}\}/g;
const matches = [...content.matchAll(variableRegex)];
const variables = [...new Set(matches.map(match => match[1].trim()))];
return {
name: title,
description: description,
content: content,
variables: variables,
category: 'Custom'
};
};
Custom Properties System
Advanced feature for generating structured data from prompts:
// src/components/CustomPropertiesSection.js - Custom properties
const generateCustomPropertiesPrompt = (properties) => {
if (!properties || properties.length === 0) {
return '';
}
const propertiesList = properties.map(prop => `"${prop}": "value"`).join(', ');
return `\n\nPlease return the following information as a JSON object at the end of your response:\n{\n ${propertiesList}\n}`;
};
Responsive UI Design
Modern, responsive interface using Tailwind CSS with consistent design patterns:
/* src/app/globals.css - Global styling */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* Custom animations and transitions */
.animate-fadeOut {
animation: fadeOut 1s ease-in-out forwards;
}
.animate-slideInDown {
animation: slideInDown 0.6s ease-out;
}
Integration Points
Component Communication
- State Management: Centralized state in PromptManager with prop drilling to child components
- Event Handling: Consistent event handling patterns across all modal components
- Data Flow: Unidirectional data flow from parent to child components with callback functions
File System Integration
- Import System: File API integration for markdown file processing
- Export System: Blob API and JSZip for multi-format file generation
- Download Handling: Browser-native download functionality with proper MIME types
External Dependencies
- Markdown Editor: @uiw/react-md-editor integration for rich text editing
- Icon System: Lucide React icons for consistent visual language
- ZIP Creation: JSZip library for bundling multiple export files
Documentation
Component API Reference
- PromptManager: Main application component with full CRUD operations
- CreatePromptModal: Form-based prompt creation with validation
- EditPromptModal: In-place prompt editing with variable management
- ExportModal: Multi-format export with metadata options
- ImportModal: Markdown file import with automatic parsing
- CustomPropertiesSection: Advanced properties for structured output
Usage Examples
// Creating a new prompt
const newPrompt = {
name: 'Customer Analysis',
description: 'Analyze customer data for insights',
content: 'Analyze {{customer_data}} for {{customer_name}}',
variables: ['customer_data', 'customer_name'],
category: 'Analysis'
};
// Exporting prompts
const exportData = prompts.map(prompt => exportToJSON(prompt));
const zip = await createZipArchive(exportData);
Configuration Options
- Export Formats: JSON, Markdown, CSV with optional metadata
- Import Formats: Markdown files with automatic variable detection
- Custom Properties: Structured data generation for LLM responses
- Search Functionality: Real-time filtering across name, description, and category
Performance Considerations
- Lazy Loading: Modal components loaded on-demand
- Efficient Rendering: React.memo for performance optimization
- File Processing: Asynchronous file operations with progress indicators
- Memory Management: Proper cleanup of file handles and event listeners

Summary
Implemented an ultra-cool splash screen with modern CSS animations and enhanced the PerplexityConfig component with custom properties generation capabilities for AI-powered record augmentation.
Why Care
The splash screen creates a professional first impression with engaging animations that showcase the app's core workflow. The custom properties feature significantly expands the AI augmentation capabilities, allowing users to define specific data points they want generated for each record, making the tool much more flexible and powerful for business intelligence workflows.
Implementation
Changes Made
New Files Created:
src/components/SplashScreen.js
- Complete splash screen component with staggered animationschangelog/2025-01-27_03.md
- This changelog entry
Files Modified:
src/app/page.js
- Added splash screen integration with state managementsrc/app/globals.css
- Added custom CSS animations for splash screen effectssrc/components/PerplexityConfig.js
- Enhanced with custom properties management
Tree Structure:
src/
├── app/
│ ├── page.js (modified)
│ └── globals.css (modified - added animations)
├── components/
│ ├── SplashScreen.js (new)
│ └── PerplexityConfig.js (enhanced)
└── changelog/
└── 2025-07-23_03.md (new)
Technical Details
Splash Screen Implementation (src/components/SplashScreen.js
)
Animation System:
- Phase-based animation control with 4 distinct phases (0-3)
- 1-second intervals between phases for optimal visual rhythm
- 6-second total duration with smooth fade-out transition
Key Features:
- Gradient background:
bg-gradient-to-br from-blue-900 via-purple-900 to-indigo-900
- Floating animated orbs with staggered pulse delays
- Staggered text animations: Welcome text slides down, tagline slides up
- Icon animations: Bounce-in effects for Import/Augment/Export, spin-in for Repeat
- Loading indicator with bouncing dots
- Floating database icon with continuous float animation
Animation Classes Added:
.animate-slideInDown, .animate-slideInUp, .animate-slideOutUp
.animate-fadeOut, .animate-fadeIn, .animate-bounceIn
.animate-spinIn, .animate-float
Custom Properties Feature (src/components/PerplexityConfig.js
)
New Functionality:
- Dynamic custom properties management with add/remove capabilities
- Real-time placeholder preview in prompt editor
- Integration with existing Perplexity AI configuration
- Visual distinction between CSV fields and custom properties
Key Components:
- Custom properties input with Enter key support
- Property list with individual remove buttons
- Purple-themed styling for custom properties
- Instructions panel explaining the workflow
State Management:
newProperty
state for input field- Integration with existing
perplexityConfig.customProperties
array - Validation to prevent duplicate properties
CSS Animations (src/app/globals.css
)
Custom Keyframes:
@keyframes slideInDown, slideInUp, slideOutUp
@keyframes fadeOut, fadeIn, bounceIn, spinIn, float
Animation Classes:
- Smooth transitions with
ease-out
timing - Configurable durations (0.8s - 3s)
- Transform-based animations for performance
- Opacity and scale effects for visual impact
Page Integration (src/app/page.js
)
State Management:
showSplash
state controls splash screen visibilityhandleSplashComplete
callback manages transition- Conditional rendering with React Fragment
Integration Points
Splash Screen Integration:
- Seamlessly integrates with existing RecordCollector component
- No impact on existing functionality
- Maintains app state during splash display
- Smooth transition to main application
Custom Properties Integration:
- Extends existing PerplexityConfig store functionality
- Integrates with
availableFields
from record store - Maintains backward compatibility with existing prompts
- Enhances AI augmentation workflow
Animation System:
- Custom CSS animations work alongside Tailwind utilities
- No conflicts with existing styling
- Performance-optimized with transform-based animations
- Responsive design maintained across screen sizes
Documentation
Splash Screen Usage:
The splash screen automatically displays on page load for 6 seconds, then transitions to the main application. No user interaction required.
Custom Properties Usage:
- Navigate to PerplexityConfig component
- Add custom properties in the "Custom Properties to Generate" section
- Properties appear as placeholders in the prompt editor
- AI will research and generate these properties for each record
Animation Customization:
All animations are defined in src/app/globals.css
and can be modified by adjusting:
- Keyframe definitions for animation behavior
- Animation class durations and timing functions
- Phase timing in SplashScreen component
API Integration:
Custom properties integrate with Perplexity AI API through the existing prompt system, allowing dynamic property generation based on user-defined requirements.

Summary
Reorganized export functionality to centralize it on the Export page and added individual loading animations for record augmentation.
Why Care
These changes improve user experience by providing clearer separation of concerns between record management and export operations, while adding visual feedback during AI augmentation processes.
Implementation
Changes Made
- Removed Export All button from
src/components/RecordCollector.js
- Added Download Local functionality to
src/components/ExportPage.js
- Implemented individual loading animations in
src/components/AugmentPage.js
andsrc/components/RecordCard.js
- Updated icon imports across components
Technical Details
Export Functionality Reorganization
File:
src/components/RecordCollector.js
- Removed
handleExportAll
function (lines 18-47) - Removed
Download
icon import - Simplified header button layout to only show "Import CSV" and "Delete All"
- Removed
File:
src/components/ExportPage.js
- Added
Download
icon import - Implemented
handleDownloadLocal
function with CSV export logic - Added "Download Local" button between "Select All" and "Push to Remote" buttons
- Button shows selected record count and is disabled when no records selected
- Added
Individual Loading Animations
File:
src/components/AugmentPage.js
- Added
processingRecords
state (Set) to track individual record processing - Updated
handleAugment
function to add/remove record IDs from processing set - Pass
isProcessing
prop toRecordCard
based on processing status
- Added
File:
src/components/RecordCard.js
- Added
isProcessing
prop (defaults to false) - Implemented loading overlay with spinner and "Augmenting..." text
- Overlay appears when
isProcessing
is true with backdrop blur effect
- Added
Integration Points
- Export functionality now properly separated between Record Collector (management) and Export page (export operations)
- Loading animations provide real-time feedback during AI augmentation process
- Consistent visual design maintained across components
Documentation
- Export page now provides both local download and remote push options
- Loading animations clearly indicate which records are being processed
- User can select specific records for export rather than being forced to export all

Summary
Implemented a complete three-phase Data Augmenter application using Next.js 14, featuring CSV import/export, AI-powered data augmentation with Perplexity AI integration, and comprehensive record management with responsive design.
Why Care
This establishes a scalable foundation for AI-powered data processing workflows, demonstrating modern React/Next.js best practices with a clear three-phase architecture (Import → Augment → Export) that can be extended for enterprise data enhancement needs.
Implementation
Changes Made
Core Application Structure
- Next.js 14 Setup: Initialized with App Router and Tailwind CSS
- Project Structure: Organized components, pages, and utilities
- Dependencies: Added zustand, papaparse, lucide-react for state management, CSV parsing, and icons
Phase 1: Import & Record Management
src/app/page.js
: Main Record Collector page with comprehensive record managementsrc/components/RecordCollector.js
: Core component with CSV import, record display, search, and statisticssrc/components/ImportModal.js
: Modal for CSV file upload with drag-and-drop supportsrc/components/RecordCard.js
: Individual record display with augmentation status indicatorssrc/components/SearchBar.js
: Real-time search functionalitysrc/components/DeleteConfirmModal.js
: Confirmation dialog for record deletionsrc/lib/csvParser.js
: Robust CSV parsing with quoted field handlingsrc/lib/store.js
: Zustand store for record management and augmentation data
Phase 2: AI Augmentation
src/app/augment/page.js
: AI augmentation page with record selectionsrc/components/AugmentPage.js
: Main augmentation interface with Perplexity AI integrationsrc/components/PerplexityConfig.js
: Configuration panel for API keys, prompts, and settingssrc/components/AugmentationResults.js
: Results display with markdown rendering and export- API Integration: Real Perplexity AI API calls with simulation mode toggle
- Prompt System: Custom prompt editor with placeholder replacement
Phase 3: Export
src/app/export/page.js
: Export page for data selection and remote pushsrc/components/ExportPage.js
: Export interface with record selection and statistics- Export Functionality: CSV export with augmentation data, simulated remote push
Navigation & Layout
src/app/layout.js
: Root layout with global navigationsrc/components/Navigation.js
: Global navigation bar with three-phase routingsrc/app/globals.css
: Global styles with Tailwind CSS integration
Documentation
RecordCollector.md
: Comprehensive project documentation with three-phase architecture- Changelog System: Established changelog structure for tracking changes
Technical Details
State Management Architecture
// Zustand Store Structure
{
records: Array<Record>,
selectedRecord: Record | null,
addRecords: (records: Record[]) => void,
deleteRecord: (id: string) => void,
deleteAllRecords: () => void,
updateRecordAugmentation: (id: string, data: AugmentationData) => void
}
Record Data Model
interface Record {
id: string;
name: string;
industry: string;
size: string;
location: string;
annual_revenue: number;
website: string;
contact_email: string;
augmentationResults?: AugmentationData;
lastAugmented?: string;
}
AI Integration Features
- Perplexity AI API: Real HTTP requests with proper error handling
- Simulation Mode: Toggle between real API and simulated responses
- Prompt Templates: Customizable prompts with placeholder replacement
- Batch Processing: Multi-record augmentation with progress tracking
- Result Storage: Augmentation results stored in Zustand store
Responsive Design Implementation
- Mobile-First: Responsive breakpoints (768px, 1024px)
- Grid System: Dynamic column layouts (1-3 columns based on screen size)
- Component Patterns: Consistent card, button, and modal designs
- Accessibility: Proper ARIA labels and keyboard navigation
CSV Processing
- Robust Parsing: Handles quoted fields, embedded commas, escaped quotes
- Data Validation: Required field checking and type conversion
- Error Handling: Comprehensive error messages and validation
- Export Functionality: Full data export with augmentation results
Integration Points
Component Dependencies
- RecordCard: Displays both original and augmented data
- Navigation: Seamless routing between three phases
- Store Integration: Centralized state management across all components
- Modal System: Consistent modal patterns for import, delete, and configuration
API Integration
- Perplexity AI: REST API integration with authentication
- Error Handling: Graceful failure handling and user feedback
- Rate Limiting: Simulated delays and proper request management
- Configuration: API key management and feature toggles
Data Flow
- Import: CSV → Parse → Validate → Store
- Augment: Select → Configure → Process → Store Results
- Export: Select → Format → Export/Push
Documentation
Project Structure
src/
├── app/
│ ├── layout.js (Global navigation)
│ ├── page.js (Record Collector)
│ ├── augment/page.js (AI Augmentation)
│ └── export/page.js (Data Export)
├── components/
│ ├── RecordCollector.js (Main record management)
│ ├── AugmentPage.js (AI augmentation interface)
│ ├── ExportPage.js (Export and remote push)
│ ├── RecordCard.js (Individual record display)
│ ├── PerplexityConfig.js (AI configuration)
│ ├── AugmentationResults.js (Results display)
│ ├── ImportModal.js (CSV import dialog)
│ ├── Navigation.js (Global navigation)
│ └── [Other UI components]
└── lib/
├── store.js (Zustand store)
└── csvParser.js (CSV parsing utilities)
Key Features Implemented
- Three-Phase Workflow: Import → Augment → Export
- AI Integration: Perplexity AI with real/simulation modes
- Data Management: Complete CRUD operations for records
- Export Capabilities: CSV export with augmentation data
- Responsive Design: Mobile-first responsive layout
- State Management: Centralized Zustand store
- Error Handling: Comprehensive error management
- User Experience: Intuitive navigation and feedback
Performance Optimizations
- Lazy Loading: Components loaded on demand
- Debounced Search: Real-time search optimization
- Efficient Rendering: React optimization patterns
- Memory Management: Proper cleanup and state management
Security Considerations
- API Key Management: Secure input fields with show/hide toggle
- Data Validation: Input sanitization and validation
- Client-Side Only: No server-side data storage (current implementation)
- Error Boundaries: Graceful error handling without data exposure
Conclusion
Phase 1 of the Data Augmenter project has successfully established a solid foundation with comprehensive data import, management, and basic AI augmentation capabilities. The three-phase architecture provides a clear roadmap for future development, with each phase building upon the previous one to create a complete data enhancement platform.
The current implementation demonstrates modern React/Next.js best practices, responsive design principles, and scalable architecture patterns that will support the planned enhancements in Phases 2 and 3.

Augment-It Version 2.0.0 with Bolt.new
Overview
This document provides a comprehensive analysis of the Augment-It codebase, which is a customer data management application with AI capabilities. The application is built using React, TypeScript, Vite, Zustand, and Supabase.
Why Care?
This application provides a complete workflow to augment data records with AI, albiet limited services available to start. The functionality make it suitable for iterating a data augmentation workflow on a long list of customer records, individually or in batches.
Architecture
The application follows a client-server architecture with the following key components:
graph TD
A[Client] --> B[Supabase Auth]
A --> C[Supabase Database]
A --> D[AI Models]
D --> D1[Anthropic Claude]
D --> D2[OpenAI GPT]
D --> D3[Perplexity]
subgraph Client
E[React Components] --> F[Zustand Store]
F --> G[Supabase Client]
F --> H[AI SDKs]
end
Core Technologies
- Frontend: React 18 with TypeScript
- Build Tool: Vite
- Styling: TailwindCSS with Typography plugin
- State Management: Zustand
- Authentication: Supabase Auth
- Database: Supabase PostgreSQL
- AI Integration:
- Anthropic Claude SDK
- OpenAI GPT
- Perplexity
- UI Components:
- CodeMirror for code editing
- Lucide React for icons
- MDX for rich text editing
Project Structure
src/
├── assets/ # Static assets (icons, images)
├── components/ # Reusable React components
├── lib/ # Utility functions and API clients
├── store/ # Zustand state management
├── types/ # TypeScript type definitions
└── App.tsx # Root component
Key Components
1. App.tsx
The root component that handles:
- Authentication flows (login, signup, password reset)
- Initial data loading
- Routing (implicit based on auth state)
2. Core UI Components
DataModelModal
- Purpose: Modal for viewing and editing data models
- Key Features:
- Form for creating/editing data models
- Field type definitions
- Validation rules
EditQueryOptions
- Purpose: Interface for configuring query parameters
- Key Features:
- Model selection
- Temperature and other AI parameters
- Prompt customization
HighlightsContextWrapper
- Purpose: Context provider for managing highlighted content
- Key Features:
- Manages highlight state
- Coordinates between different highlightable components
MDXEditor
- Purpose: Rich text editor for prompt content
- Key Features:
- Markdown support
- Code block highlighting
- Inline formatting
MainLayout
- Purpose: Main application layout component
- Key Features:
- Navigation sidebar
- Responsive design
- User menu and settings
PromptList
- Purpose: Displays list of available prompt templates
- Key Features:
- Search and filter functionality
- Template preview
- Selection handling
PromptSection
- Purpose: Individual section within a prompt template
- Key Features:
- Toggle between edit and preview modes
- Model-specific configuration
- Content validation
QueryResponse
- Purpose: Displays AI model responses
- Key Features:
- Syntax highlighting
- Response actions (copy, regenerate, etc.)
- Error handling
RecordList
- Purpose: Displays data records
- Key Features:
- Pagination
- Sorting and filtering
- Selection management
PasswordReset
- Purpose: Handles password reset flow
- Key Features:
- Email validation
- Error handling
- Success feedback
PromptSectionEdit
- Purpose: Edit interface for prompt sections
- Key Features:
- Rich text editing
- Model configuration
- Preview toggle
PromptSectionPreview
- Purpose: Read-only view of prompt sections
- Key Features:
- Rendered markdown
- Section actions (edit, delete)
- Model badge display
QueryOptionsIconSet
- Purpose: Visual indicators for query options
- Key Features:
- Model type icons
- Parameter indicators
- Interactive tooltips
QueryResponseList
- Purpose: Manages multiple query responses
- Key Features:
- Response grouping
- Version comparison
- Batch actions
RecordHighlightsWrapper
- Purpose: Context for record highlighting
- Key Features:
- Highlight management
- Cross-component synchronization
- Persistence
RequestEditor
- Purpose: Interface for crafting API requests
- Key Features:
- Parameter editing
- Request preview
- History tracking
ResponseHighlight
- Purpose: Highlights specific response sections
- Key Features:
- Custom highlight colors
- Note attachment
- Shareable links
ResponseObjectContextWrapper
- Purpose: Manages response object state
- Key Features:
- Context provider
- State persistence
- Event handling
ResponseObjectHighlighter
- Purpose: Interactive response highlighting
- Key Features:
- Text selection
- Color coding
- Annotation
ResponseObjectReviewer
- Purpose: Interface for reviewing responses
- Key Features:
- Side-by-side comparison
- Commenting
- Approval workflow
UpdatePassword
- Purpose: Password update interface
- Key Features:
- Current password verification
- New password validation
- Strength indicator
UserProfile
- Purpose: User account management
- Key Features:
- Profile editing
- API key management
- Account settings
3. State Management (store/index.ts)
The application uses Zustand for state management with the following key state:
interface AppState {
// Data
records: Record[];
selectedRecord: Record | null;
promptTemplates: PromptTemplate[];
selectedTemplate: PromptTemplate | null;
aiModels: AIModel[];
user: User | null;
profile: UserProfile | null;
computedProperties: ComputedProperty[];
aiModelConfigs: AIModelConfig[];
queryResponses: QueryResponse[];
highlights: Highlight[];
// Actions
setSelectedRecord: (record: Record | null) => void;
setSelectedTemplate: (template: PromptTemplate | null) => void;
addPromptTemplate: (template: PromptTemplate) => Promise<void>;
// ... other actions
}
3. Prompt Management
The application allows creating and managing AI prompt templates with multiple sections:
classDiagram
class PromptTemplate {
+string id
+string name
+string description
+PromptSection[] sections
+string created_at
}
class PromptSection {
+string id
+string title
+string content
+string modelId
+object options
}
PromptTemplate "1" *-- "many" PromptSection
4. AI Integration
The application integrates with multiple AI models through a unified interface:
// Example of generating AI response
const generateAIResponse = async (sectionId: string, modelId: string, prompt: string) => {
// Implementation handles different AI providers
const model = getAIModel(modelId);
const response = await model.generate(prompt);
// Process and store response
};
Data Model
Records
Customer data records that can be processed by AI models.
Prompt Templates
Reusable templates for generating AI prompts with configurable sections.
AI Models
Configuration for different AI models and providers.
Query Responses
Stores AI model responses for later reference.
Key Features
Template-Based AI Prompting
- Create and manage prompt templates with multiple sections
- Each section can use different AI models
- Preview and edit capabilities
AI Model Integration
- Support for multiple AI providers (Claude, GPT, Perplexity)
- Configurable model parameters
- Response highlighting and annotation
Data Management
- CRUD operations for customer records
- Bulk import/export functionality
- Data validation and transformation
User Management
- Authentication and authorization
- User profiles and preferences
- API key management
Code Examples
Example Component: PromptSection
interface PromptSectionProps {
section: PromptSectionType;
templateId: string;
}
export const PromptSection: React.FC<PromptSectionProps> = ({ section, templateId }) => {
const [isEditing, setIsEditing] = React.useState(false);
const selectedTemplate = useStore(state => state.selectedTemplate);
// Get the current section from the selected template
const currentSection = selectedTemplate?.sections.find(s => s.id === section.id);
const sectionToRender = currentSection || section;
return (
<div id={`section-${section.id}`}>
{isEditing ? (
<PromptSectionEdit
section={sectionToRender}
templateId={templateId}
onCancel={() => setIsEditing(false)}
onSave={() => setIsEditing(false)}
/>
) : (
<PromptSectionPreview
section={sectionToRender}
templateId={templateId}
onEdit={() => setIsEditing(true)}
/>
)}
</div>
);
};
Example Store Action: generateAIResponse
generateAIResponse: async (sectionId, modelId, prompt, sectionTitle) => {
const { user } = get();
if (!user) return;
try {
// Get model configuration
const model = get().aiModels.find(m => m.id === modelId);
if (!model) throw new Error('Model not found');
// Generate response using appropriate handler
let response;
switch (model.provider) {
case 'anthropic':
response = await generateClaudeResponse(prompt, model);
break;
case 'openai':
response = await generateGPTResponse(prompt, model);
break;
case 'perplexity':
response = await generatePerplexityResponse(prompt, model);
break;
default:
throw new Error(`Unsupported model provider: ${model.provider}`);
}
// Save response to store and database
// ...
} catch (error) {
console.error('Error generating AI response:', error);
throw error;
}
}
Next Steps
Migration to Microservices and Microfrontends Architecture
When migrating to a microservices architecture, consider the following:
Service Decomposition
- Auth Service: Handle authentication and user management
- Template Service: Manage prompt templates and sections
- AI Service: Handle AI model integration and response generation
- Data Service: Manage customer records and query results
API Gateway
- Implement an API gateway to route requests to appropriate services
- Handle authentication and rate limiting
Event-Driven Architecture
- Use message queues for async processing
- Implement event sourcing for auditability
Data Management
- Each service should have its own database
- Implement data consistency patterns (Saga, CQRS)
Conclusion
The current codebase provides a solid foundation with clear separation of concerns. The migration to microservices should focus on: