commit 24a75d4fc2a757d42f6c83b3b4d16ed96aa8ed12 Author: hzhang Date: Fri Feb 13 15:44:25 2026 +0000 init dialectic diff --git a/.env b/.env new file mode 100644 index 0000000..6f6637b --- /dev/null +++ b/.env @@ -0,0 +1,16 @@ +# Frontend +FRONTEND_PORT=3000 + +# Backend +BACKEND_PORT=8090 +BACKEND_URL=http://localhost:8090 + +# Database +DB_PORT=3306 +MYSQL_ROOT_PASSWORD=rootpassword +MYSQL_DATABASE=dialectic +MYSQL_USER=dialectic +MYSQL_PASSWORD=dialectic + +# Backend internal +ENCRYPTION_KEY=BgS9_9K2UMYxiYnP-BE63UEdi7a6PHaaZ6rQZQnSx54= diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Dialectic.iml b/.idea/Dialectic.iml new file mode 100644 index 0000000..c8c430b --- /dev/null +++ b/.idea/Dialectic.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..9b821f8 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1d3ce46 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..455a83a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..0b3d386 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Dialectic.Backend b/Dialectic.Backend new file mode 160000 index 0000000..83c4461 --- /dev/null +++ b/Dialectic.Backend @@ -0,0 +1 @@ +Subproject commit 83c4461d29f8aa3dd48ecb0b8a14bf6b399f61e8 diff --git a/Dialectic.Frontend b/Dialectic.Frontend new file mode 160000 index 0000000..16630b6 --- /dev/null +++ b/Dialectic.Frontend @@ -0,0 +1 @@ +Subproject commit 16630b6999ad3b14acdccf4889ec96b02e47a62b diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..7f1cfef --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,51 @@ +services: + frontend: + build: + context: ./Dialectic.Frontend + dockerfile: Dockerfile + ports: + - "${FRONTEND_PORT:-3000}:3000" + environment: + - NODE_ENV=development + - REACT_APP_BACKEND_HOST=${BACKEND_URL:-http://localhost:8000} + stdin_open: true + tty: true + + backend: + build: + context: ./Dialectic.Backend + dockerfile: Dockerfile + ports: + - "${BACKEND_PORT:-8000}:8000" + volumes: + - dialectic_config:/app/config + environment: + - ENV_MODE=prod + - ENCRYPTION_KEY=${ENCRYPTION_KEY:-BgS9_9K2UMYxiYnP-BE63UEdi7a6PHaaZ6rQZQnSx54=} + - CONFIG_PATH=/app/config/dialectic.yaml + depends_on: + db: + condition: service_healthy + command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload + + db: + image: mysql:8.0 + restart: always + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword} + MYSQL_DATABASE: ${MYSQL_DATABASE:-dialectic} + MYSQL_USER: ${MYSQL_USER:-dialectic} + MYSQL_PASSWORD: ${MYSQL_PASSWORD:-dialectic} + ports: + - "${DB_PORT:-3306}:3306" + volumes: + - mysql_data:/var/lib/mysql + - ./init.sql:/docker-entrypoint-initdb.d/init.sql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 20s + retries: 10 + +volumes: + mysql_data: + dialectic_config: \ No newline at end of file diff --git a/init.sql b/init.sql new file mode 100644 index 0000000..b32d503 --- /dev/null +++ b/init.sql @@ -0,0 +1,47 @@ +-- MySQL initialization script for Dialectic + +CREATE DATABASE IF NOT EXISTS dialectic; +USE dialectic; + +-- Table for storing API keys for different providers +CREATE TABLE IF NOT EXISTS api_keys ( + id INT AUTO_INCREMENT PRIMARY KEY, + provider VARCHAR(50) NOT NULL UNIQUE, + api_key_encrypted TEXT NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +-- Table for storing model configurations +CREATE TABLE IF NOT EXISTS model_configs ( + id INT AUTO_INCREMENT PRIMARY KEY, + provider VARCHAR(50) NOT NULL, + model_name VARCHAR(100) NOT NULL, + display_name VARCHAR(100), + is_active BOOLEAN DEFAULT TRUE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNIQUE KEY unique_provider_model (provider, model_name) +); + +-- Insert default API key records (encrypted field will be empty initially) +INSERT IGNORE INTO api_keys (provider, api_key_encrypted) VALUES +('openai', ''), +('claude', ''), +('qwen', ''), +('deepseek', ''); + +-- Insert default model configurations +INSERT IGNORE INTO model_configs (provider, model_name, display_name) VALUES +('openai', 'gpt-4', 'GPT-4'), +('openai', 'gpt-3.5-turbo', 'GPT-3.5 Turbo'), +('claude', 'claude-3-opus', 'Claude 3 Opus'), +('claude', 'claude-3-sonnet', 'Claude 3 Sonnet'), +('claude', 'claude-3-haiku', 'Claude 3 Haiku'), +('qwen', 'qwen-max', 'Qwen Max'), +('qwen', 'qwen-plus', 'Qwen Plus'), +('deepseek', 'deepseek-chat', 'DeepSeek Chat'), +('deepseek', 'deepseek-coder', 'DeepSeek Coder'); + +-- Add evidence_library column to debate_sessions (migration for existing databases) +ALTER TABLE debate_sessions ADD COLUMN IF NOT EXISTS evidence_library TEXT NULL; \ No newline at end of file