Add production environment configuration file with database and service URLs
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
# Database URLs for Docker / production deployment
|
||||
# If you run the services natively outside Docker, change `db:5432` to `localhost:5433`.
|
||||
|
||||
# General fallback
|
||||
|
||||
# JWT Secret
|
||||
JWT_SECRET=83be1rXtpLlRwpu77nRKCYSOqRgmO3XIv7zx7J0dfXs=
|
||||
|
||||
# Logging
|
||||
RUST_LOG=debug
|
||||
|
||||
# AI Configuration
|
||||
# Providers: 'openai' or 'local'
|
||||
AI_PROVIDER=local
|
||||
OPENAI_API_KEY=
|
||||
|
||||
# Local AI (Ollama & Whisper) - Production (HTTPS with SSH tunnel)
|
||||
LOCAL_WHISPER_URL=https://whisper.t-800.norteamericano.cl
|
||||
LOCAL_OLLAMA_URL=https://ollama.t-800.norteamericano.cl
|
||||
|
||||
# Model Configuration - Optimized for each use case
|
||||
# Chat/Tutor: llama3.2:latest - Fast, efficient for conversational AI
|
||||
LOCAL_LLM_MODEL=llama3.2:latest
|
||||
|
||||
# Complex reasoning/analysis: qwen3.5:9b - Better for complex tasks
|
||||
LOCAL_LLM_MODEL_COMPLEX=qwen3.5:9b
|
||||
|
||||
# Heavy-duty tasks: gpt-oss:latest - Most capable local model
|
||||
LOCAL_LLM_MODEL_ADVANCED=gpt-oss:latest
|
||||
|
||||
# Embeddings: nomic-embed-text - Optimized for semantic search
|
||||
EMBEDDING_MODEL=nomic-embed-text
|
||||
|
||||
# Audio transcription (Whisper)
|
||||
WHISPER_MODEL=whisper-large-v3
|
||||
|
||||
|
||||
ENVIRONMENT=prod
|
||||
LETSENCRYPT_STAGING=false
|
||||
|
||||
# Dominios de los servicios - cambiar aquí para mover a otro dominio
|
||||
DEV_OLLAMA_URL=https://ollama.t-800.norteamericano.cl
|
||||
DEV_WHISPER_URL=https://whisper.t-800.norteamericano.cl
|
||||
|
||||
# Mercado Pago Configuration
|
||||
MP_ACCESS_TOKEN=
|
||||
MP_PUBLIC_KEY=
|
||||
MP_WEBHOOK_SECRET=
|
||||
MP_BACK_URL_SUCCESS=https://${NEXT_PUBLIC_LEARNING_DOMAIN}/payments/success
|
||||
MP_BACK_URL_FAILURE=https://${NEXT_PUBLIC_LEARNING_DOMAIN}/payments/failure
|
||||
MP_NOTIFICATION_URL=
|
||||
|
||||
# External MySQL Integration
|
||||
MYSQL_DATABASE_URL=mysql://root:Smith3976!@ec2-18-222-25-254.us-east-2.compute.amazonaws.com:3306/sige_sam_v3
|
||||
SAM_DIAGNOSTICO_DATABASE_URL=mysql://root:Smith3976!@ec2-18-222-25-254.us-east-2.compute.amazonaws.com:3306/SAM_diagnostico
|
||||
EXTERNAL_TABLE_GRADES=notas
|
||||
EXTERNAL_ID_TIPO_NOTA=1
|
||||
|
||||
# Bark TTS API (Text-to-Speech for questions)
|
||||
BARK_API_URL=http://t-800:8443
|
||||
|
||||
# Bridge Database
|
||||
|
||||
# Branding Defaults
|
||||
DEFAULT_ORG_NAME="Norteamericano"
|
||||
DEFAULT_PLATFORM_NAME="Norteamericano Learning"
|
||||
DEFAULT_LOGO_URL=""
|
||||
DEFAULT_FAVICON_URL=""
|
||||
DEFAULT_PRIMARY_COLOR="#3B82F6"
|
||||
DEFAULT_SECONDARY_COLOR="#8B5CF6"
|
||||
DEV_BARK_URL=http://t-800:8000
|
||||
BRIDGE_DATABASE_URL=postgresql://user:Mj5EPIqzaKlJGuQ4-hkVg8hnZHEp3R-n@192.168.0.254:5432/openccb_cms?sslmode=disable
|
||||
LOCAL_VIDEO_BRIDGE_URL=http://t-800.norteamericano.cl:8080
|
||||
EMBEDDING_MODEL=nomic-embed-text
|
||||
PROD_OLLAMA_URL=https://ollama.t-800.norteamericano.cl
|
||||
PROD_WHISPER_URL=https://whisper.t-800.norteamericano.cl
|
||||
SAM_DATABASE_URL=ec2-18-222-25-254.us-east-2.compute.amazonaws.com
|
||||
DB_PASSWORD=Mj5EPIqzaKlJGuQ4-hkVg8hnZHEp3R-n
|
||||
|
||||
# AWS S3 Storage (assets)
|
||||
ASSETS_STORAGE=s3
|
||||
S3_BUCKET=openccb-802726101181-us-east-2-an
|
||||
AWS_REGION=us-east-2
|
||||
AWS_ACCESS_KEY_ID=CHANGE_ME
|
||||
AWS_SECRET_ACCESS_KEY=CHANGE_ME
|
||||
# Optional settings (leave empty for AWS default endpoint behavior)
|
||||
S3_ENDPOINT=
|
||||
S3_PUBLIC_BASE_URL=
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
CMS_DATABASE_URL=postgresql://user:Mj5EPIqzaKlJGuQ4-hkVg8hnZHEp3R-n@db:5432/openccb_cms
|
||||
LMS_DATABASE_URL=postgresql://user:Mj5EPIqzaKlJGuQ4-hkVg8hnZHEp3R-n@db:5432/openccb_lms
|
||||
DATABASE_URL=postgresql://user:Mj5EPIqzaKlJGuQ4-hkVg8hnZHEp3R-n@db:5432/openccb_cms
|
||||
NEXT_PUBLIC_CMS_API_URL=https://studio.norteamericano.com/cms-api
|
||||
NEXT_PUBLIC_LMS_API_URL=https://learning.norteamericano.com/lms-api
|
||||
NEXT_PUBLIC_STUDIO_DOMAIN=studio.norteamericano.com
|
||||
NEXT_PUBLIC_LEARNING_DOMAIN=learning.norteamericano.com
|
||||
@@ -18,6 +18,7 @@ build/
|
||||
# Nunca subas tus llaves secretas o credenciales
|
||||
.env
|
||||
.env*.local
|
||||
.env.production
|
||||
|
||||
# --- Archivos de Sistema y Editores ---
|
||||
.DS_Store
|
||||
|
||||
@@ -1056,12 +1056,13 @@ echo "========================================"
|
||||
echo ""
|
||||
echo "Probando conexión con Ollama (t-800.norteamericano.cl:11434)..."
|
||||
|
||||
OLLAMA_TEST=$(ssh -i "$PEM_PATH" "$REMOTE_USER@$REMOTE_HOST" "curl -s --connect-timeout 5 http://t-800.norteamericano.cl:11434/api/tags 2>&1 | head -1" 2>/dev/null)
|
||||
# Ya estamos ejecutando en el host remoto: evitar SSH anidado que puede fallar con exit 255.
|
||||
OLLAMA_TEST=$(curl -s --connect-timeout 5 http://t-800.norteamericano.cl:11434/api/tags 2>&1 | head -1 || true)
|
||||
|
||||
if [ -n "$OLLAMA_TEST" ] && echo "$OLLAMA_TEST" | grep -q "models"; then
|
||||
echo "✅ Ollama accesible desde AWS EC2"
|
||||
echo " Modelos disponibles:"
|
||||
ssh -i "$PEM_PATH" "$REMOTE_USER@$REMOTE_HOST" "curl -s http://t-800.norteamericano.cl:11434/api/tags 2>&1 | grep -o '\"name\":\"[^\"]*\"' | head -5" || true
|
||||
curl -s http://t-800.norteamericano.cl:11434/api/tags 2>&1 | grep -o '"name":"[^"]*"' | head -5 || true
|
||||
else
|
||||
echo "⚠️ Ollama NO es accesible desde AWS EC2"
|
||||
echo ""
|
||||
|
||||
@@ -371,16 +371,54 @@ pub async fn list_questions(
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
} else if filters.source.is_some() {
|
||||
sqlx::query_as::<_, QuestionBank>(
|
||||
&format!(
|
||||
"SELECT {} FROM question_bank WHERE organization_id = $1 AND is_archived = false AND source = $2 ORDER BY created_at DESC",
|
||||
QUESTION_BANK_SELECT_COLUMNS
|
||||
)
|
||||
)
|
||||
.bind(org_ctx.id)
|
||||
.bind(filters.source.as_ref().unwrap())
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
let source_filter = filters.source.as_ref().unwrap().to_lowercase();
|
||||
match source_filter.as_str() {
|
||||
"mysql" => {
|
||||
sqlx::query_as::<_, QuestionBank>(
|
||||
&format!(
|
||||
"SELECT {} FROM question_bank WHERE organization_id = $1 AND is_archived = false AND source IN ('imported-mysql', 'sam-diagnostico') ORDER BY created_at DESC",
|
||||
QUESTION_BANK_SELECT_COLUMNS
|
||||
)
|
||||
)
|
||||
.bind(org_ctx.id)
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
}
|
||||
"materials" | "materials-zip" => {
|
||||
sqlx::query_as::<_, QuestionBank>(
|
||||
&format!(
|
||||
"SELECT {} FROM question_bank WHERE organization_id = $1 AND is_archived = false AND source = 'imported-material' ORDER BY created_at DESC",
|
||||
QUESTION_BANK_SELECT_COLUMNS
|
||||
)
|
||||
)
|
||||
.bind(org_ctx.id)
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
}
|
||||
"ai" => {
|
||||
sqlx::query_as::<_, QuestionBank>(
|
||||
&format!(
|
||||
"SELECT {} FROM question_bank WHERE organization_id = $1 AND is_archived = false AND source = 'ai-generated' ORDER BY created_at DESC",
|
||||
QUESTION_BANK_SELECT_COLUMNS
|
||||
)
|
||||
)
|
||||
.bind(org_ctx.id)
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
}
|
||||
_ => {
|
||||
sqlx::query_as::<_, QuestionBank>(
|
||||
&format!(
|
||||
"SELECT {} FROM question_bank WHERE organization_id = $1 AND is_archived = false AND source = $2 ORDER BY created_at DESC",
|
||||
QUESTION_BANK_SELECT_COLUMNS
|
||||
)
|
||||
)
|
||||
.bind(org_ctx.id)
|
||||
.bind(filters.source.as_ref().unwrap())
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
}
|
||||
}
|
||||
} else if filters.has_audio == Some(true) {
|
||||
sqlx::query_as::<_, QuestionBank>(
|
||||
&format!(
|
||||
|
||||
@@ -11,6 +11,10 @@ import QuestionBankEditor from '@/components/QuestionBank/QuestionBankEditor';
|
||||
import QuestionBankCard from '@/components/QuestionBank/QuestionBankCard';
|
||||
import MySQLImportModal from '@/components/QuestionBank/MySQLImportModal';
|
||||
|
||||
const isMySqlOrigin = (source?: string) => source === 'imported-mysql' || source === 'sam-diagnostico';
|
||||
const isMaterialsOrigin = (source?: string) => source === 'imported-material';
|
||||
const isAiOrigin = (source?: string) => source === 'ai-generated';
|
||||
|
||||
export default function QuestionBankPage() {
|
||||
const [questions, setQuestions] = useState<QuestionBank[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -89,19 +93,6 @@ export default function QuestionBankPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const getSourceBadge = (source?: string) => {
|
||||
switch (source) {
|
||||
case 'imported-mysql':
|
||||
return <span className="flex items-center gap-1 text-xs text-blue-600"><Globe className="w-3 h-3" /> MySQL</span>;
|
||||
case 'ai-generated':
|
||||
return <span className="flex items-center gap-1 text-xs text-purple-600"><Sparkles className="w-3 h-3" /> IA</span>;
|
||||
case 'manual':
|
||||
return <span className="text-xs text-gray-500">Manual</span>;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 dark:bg-gray-900">
|
||||
{/* Header */}
|
||||
@@ -145,19 +136,19 @@ export default function QuestionBankPage() {
|
||||
</div>
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700">
|
||||
<div className="text-2xl font-bold text-blue-600">
|
||||
{questions.filter(q => q.source === 'imported-mysql').length}
|
||||
{questions.filter(q => isMySqlOrigin(q.source)).length}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500 dark:text-gray-400">Importadas MySQL</div>
|
||||
</div>
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700">
|
||||
<div className="text-2xl font-bold text-green-600">
|
||||
{questions.filter(q => q.audio_status === 'ready').length}
|
||||
<div className="text-2xl font-bold text-emerald-600">
|
||||
{questions.filter(q => isMaterialsOrigin(q.source)).length}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500 dark:text-gray-400">Con Audio</div>
|
||||
<div className="text-sm text-gray-500 dark:text-gray-400">Materiales ZIP</div>
|
||||
</div>
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700">
|
||||
<div className="text-2xl font-bold text-purple-600">
|
||||
{questions.filter(q => q.source === 'ai-generated').length}
|
||||
{questions.filter(q => isAiOrigin(q.source)).length}
|
||||
</div>
|
||||
<div className="text-sm text-gray-500 dark:text-gray-400">Generadas IA</div>
|
||||
</div>
|
||||
@@ -237,9 +228,10 @@ export default function QuestionBankPage() {
|
||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
<option value="manual">Manual</option>
|
||||
<option value="imported-mysql">MySQL</option>
|
||||
<option value="ai-generated">IA</option>
|
||||
<option value="mysql">Importadas MySQL</option>
|
||||
<option value="materials">Importadas desde Materiales ZIP</option>
|
||||
<option value="ai">Generadas por IA</option>
|
||||
<option value="manual">Creadas manualmente</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -40,6 +40,36 @@ export default function QuestionBankCard({ question, onEdit, onDelete }: Questio
|
||||
}
|
||||
};
|
||||
|
||||
const sourceBadge = (() => {
|
||||
switch (question.source) {
|
||||
case 'imported-mysql':
|
||||
case 'sam-diagnostico':
|
||||
return (
|
||||
<span className="flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400">
|
||||
<Globe className="w-3 h-3" /> MySQL
|
||||
</span>
|
||||
);
|
||||
case 'imported-material':
|
||||
return (
|
||||
<span className="flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400">
|
||||
<Globe className="w-3 h-3" /> Materiales ZIP
|
||||
</span>
|
||||
);
|
||||
case 'ai-generated':
|
||||
return (
|
||||
<span className="flex items-center gap-1 text-xs text-purple-600 dark:text-purple-400">
|
||||
<Sparkles className="w-3 h-3" /> IA
|
||||
</span>
|
||||
);
|
||||
case 'manual':
|
||||
return <span className="text-xs text-gray-500 dark:text-gray-400">Manual</span>;
|
||||
default:
|
||||
return question.source ? (
|
||||
<span className="text-xs text-gray-500 dark:text-gray-400">{question.source}</span>
|
||||
) : null;
|
||||
}
|
||||
})();
|
||||
|
||||
const handlePlayAudio = () => {
|
||||
if (!question.audio_url) return;
|
||||
|
||||
@@ -184,20 +214,7 @@ export default function QuestionBankCard({ question, onEdit, onDelete }: Questio
|
||||
<span className="text-xs font-medium text-gray-600 dark:text-gray-400">
|
||||
{question.points} pts
|
||||
</span>
|
||||
{question.source && (
|
||||
<div className="flex items-center gap-1">
|
||||
{question.source === 'imported-mysql' && (
|
||||
<span className="flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400">
|
||||
<Globe className="w-3 h-3" /> MySQL
|
||||
</span>
|
||||
)}
|
||||
{question.source === 'ai-generated' && (
|
||||
<span className="flex items-center gap-1 text-xs text-purple-600 dark:text-purple-400">
|
||||
<Sparkles className="w-3 h-3" /> IA
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{sourceBadge && <div className="flex items-center gap-1">{sourceBadge}</div>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user