feat(migrations): Rename indexes and update global integration settings fields for improved clarity and functionality

feat(admin): Add API monitoring, debug console, and system health templates for enhanced admin interface

docs: Add AI system cleanup summary and audit report detailing architecture, token management, and recommendations

docs: Introduce credits and tokens system guide outlining configuration, data flow, and monitoring strategies
This commit is contained in:
IGNY8 VPS (Salman)
2025-12-20 12:55:05 +00:00
parent eb6cba7920
commit 3283a83b42
51 changed files with 3578 additions and 5434 deletions

View File

@@ -119,7 +119,6 @@ export default function Integration() {
const validateIntegration = useCallback(async (
integrationId: string,
enabled: boolean,
apiKey?: string,
model?: string
) => {
const API_BASE_URL = import.meta.env.VITE_BACKEND_URL || 'https://api.igny8.com/api';
@@ -129,10 +128,8 @@ export default function Integration() {
return;
}
// Check if integration is enabled and has API key configured
const hasApiKey = apiKey && apiKey.trim() !== '';
if (!hasApiKey || !enabled) {
// Check if integration is enabled
if (!enabled) {
// Not configured or disabled - set status accordingly
setValidationStatuses(prev => ({
...prev,
@@ -147,12 +144,10 @@ export default function Integration() {
[integrationId]: 'pending',
}));
// Test connection asynchronously
// Test connection asynchronously (uses platform API key)
try {
// Build request body based on integration type
const requestBody: any = {
apiKey: apiKey,
};
const requestBody: any = {};
// OpenAI needs model in config, Runware doesn't
if (integrationId === 'openai') {
@@ -195,11 +190,10 @@ export default function Integration() {
if (!integration) return;
const enabled = integration.enabled === true;
const apiKey = integration.apiKey;
const model = integration.model;
// Validate with current state (fire and forget - don't await)
validateIntegration(id, enabled, apiKey, model);
validateIntegration(id, enabled, model);
});
// Return unchanged - we're just reading state
@@ -216,7 +210,7 @@ export default function Integration() {
useEffect(() => {
// Only validate if integrations have been loaded (not initial empty state)
const hasLoadedData = Object.values(integrations).some(integ =>
integ.apiKey !== undefined || integ.enabled !== undefined
integ.enabled !== undefined
);
if (!hasLoadedData) return;
@@ -227,7 +221,7 @@ export default function Integration() {
return () => clearTimeout(timeoutId);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [integrations.openai.enabled, integrations.runware.enabled, integrations.openai.apiKey, integrations.runware.apiKey]);
}, [integrations.openai.enabled, integrations.runware.enabled]);
const loadIntegrationSettings = async () => {
try {
@@ -294,12 +288,6 @@ export default function Integration() {
}
const config = integrations[selectedIntegration];
const apiKey = config.apiKey;
if (!apiKey) {
toast.error('Please enter an API key first');
return;
}
setIsTesting(true);
@@ -312,12 +300,12 @@ export default function Integration() {
}
try {
// Test uses platform API key (no apiKey parameter needed)
// fetchAPI extracts data from unified format {success: true, data: {...}}
// So data is the extracted response payload
const data = await fetchAPI(`/v1/system/settings/integrations/${selectedIntegration}/test/`, {
method: 'POST',
body: JSON.stringify({
apiKey,
config: config,
}),
});
@@ -477,20 +465,6 @@ export default function Integration() {
if (integrationId === 'openai') {
return [
{
key: 'apiKey',
label: 'OpenAI API Key',
type: 'password',
value: config.apiKey || '',
onChange: (value) => {
setIntegrations({
...integrations,
[integrationId]: { ...config, apiKey: value },
});
},
placeholder: 'Enter your OpenAI API key',
required: true,
},
{
key: 'model',
label: 'AI Model',
@@ -513,20 +487,7 @@ export default function Integration() {
];
} else if (integrationId === 'runware') {
return [
{
key: 'apiKey',
label: 'Runware API Key',
type: 'password',
value: config.apiKey || '',
onChange: (value) => {
setIntegrations({
...integrations,
[integrationId]: { ...config, apiKey: value },
});
},
placeholder: 'Enter your Runware API key',
required: true,
},
// Runware doesn't have model selection, just using platform API key
];
} else if (integrationId === 'image_generation') {
const service = config.service || 'openai';
@@ -912,6 +873,13 @@ export default function Integration() {
<PageMeta title="API Integration - IGNY8" description="External integrations" />
<div className="space-y-8">
{/* Platform API Keys Info */}
<Alert
variant="info"
title="Platform API Keys"
message="API keys are managed at the platform level by administrators. You can customize which AI models and parameters to use for your account. Free plan users can view settings but cannot customize them."
/>
{/* Integration Cards with Validation Cards */}
<div className="grid grid-cols-1 gap-6 sm:grid-cols-2 xl:grid-cols-3">
{/* OpenAI Integration + Validation */}
@@ -924,12 +892,10 @@ export default function Integration() {
integrationId="openai"
onToggleSuccess={(enabled, data) => {
// Refresh status circle when toggle changes
// Use API key from hook's data (most up-to-date) or fallback to integrations state
const apiKey = data?.apiKey || integrations.openai.apiKey;
const model = data?.model || integrations.openai.model;
// Validate with current enabled state and API key
validateIntegration('openai', enabled, apiKey, model);
// Validate with current enabled state and model
validateIntegration('openai', enabled, model);
}}
onSettings={() => handleSettings('openai')}
onDetails={() => handleDetails('openai')}
@@ -965,11 +931,8 @@ export default function Integration() {
}
onToggleSuccess={(enabled, data) => {
// Refresh status circle when toggle changes
// Use API key from hook's data (most up-to-date) or fallback to integrations state
const apiKey = data?.apiKey || integrations.runware.apiKey;
// Validate with current enabled state and API key
validateIntegration('runware', enabled, apiKey);
// Validate with current enabled state
validateIntegration('runware', enabled);
}}
onSettings={() => handleSettings('runware')}
onDetails={() => handleDetails('runware')}
@@ -1003,11 +966,7 @@ export default function Integration() {
<Alert
variant="info"
title="AI Integration & Image Generation Testing"
message="Configure and test your AI integrations on this page.
Set up OpenAI and Runware API keys, validate connections, and test image generation with different models and parameters.
Before you start, please read the documentation for each integration.
Make sure to use the correct API keys and models for each integration."
message="Test your AI integrations and image generation on this page. The platform provides API keys - you can customize model preferences and parameters based on your plan. Test connections to verify everything is working correctly."
/>
</div>
</div>
@@ -1093,7 +1052,7 @@ export default function Integration() {
onClick={() => {
handleTestConnection();
}}
disabled={isTesting || isSaving || !integrations[selectedIntegration]?.apiKey}
disabled={isTesting || isSaving}
className="flex items-center gap-2"
>
{isTesting ? 'Testing...' : 'Test Connection'}