backend changes

This commit is contained in:
Chandini 2025-09-03 13:58:10 +05:30
parent 3ecaee5542
commit e4cf030bcc
4 changed files with 135 additions and 61 deletions

65
.env.backup Normal file
View File

@ -0,0 +1,65 @@
# Database Configuration
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=dev_pipeline
POSTGRES_USER=pipeline_admin
POSTGRES_PASSWORD=secure_pipeline_2024
# Redis Configuration
REDIS_PASSWORD=redis_secure_2024
# MongoDB Configuration
MONGO_INITDB_ROOT_USERNAME=pipeline_admin
MONGO_INITDB_ROOT_PASSWORD=mongo_secure_2024
# RabbitMQ Configuration
RABBITMQ_DEFAULT_USER=pipeline_admin
RABBITMQ_DEFAULT_PASS=rabbit_secure_2024
# n8n Configuration
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=admin_n8n_2024
N8N_ENCRYPTION_KEY=very_secure_encryption_key_2024
# Jenkins Configuration
JENKINS_ADMIN_ID=admin
JENKINS_ADMIN_PASSWORD=jenkins_secure_2024
# Gitea Configuration
GITEA_ADMIN_USER=admin
GITEA_ADMIN_PASSWORD=gitea_secure_2024
# API Keys (add your actual keys later)
CLAUDE_API_KEY=your_claude_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
CLOUDTOPIAA_API_KEY=your_cloudtopiaa_api_key_here
CLOUDTOPIAA_API_URL=https://api.cloudtopiaa.com
# JWT Configuration
JWT_SECRET=ultra_secure_jwt_secret_2024
# Environment
ENVIRONMENT=development
NODE_ENV=development
PYTHONPATH=/app/src
# Monitoring
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=grafana_secure_2024
RABBITMQ_PASSWORD=rabbit_secure_2024
MONGODB_PASSWORD=pipeline_password
MONGODB_PASSWORD=pipeline_password
CLAUDE_API_KEY=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
CLAUDE_API_KEY=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
# SMTP Configuration (Option 1)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=frontendtechbiz@gmail.com
SMTP_PASS=oidhhjeasgzbqptq
SMTP_FROM=frontendtechbiz@gmail.com
# Gmail Configuration (Option 2 - Alternative to SMTP)
GMAIL_USER=frontendtechbiz@gmail.com
GMAIL_APP_PASSWORD=oidhhjeasgzbqptq

View File

@ -23,22 +23,22 @@ services:
retries: 5 retries: 5
start_period: 60s start_period: 60s
# redis: redis:
# image: redis:7-alpine image: redis:7-alpine
# container_name: pipeline_redis container_name: pipeline_redis
# command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD} command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
# volumes: volumes:
# - redis_data:/data - redis_data:/data
# ports: ports:
# - "6379:6379" - "6379:6379"
# networks: networks:
# - pipeline_network - pipeline_network
# healthcheck: healthcheck:
# test: ["CMD", "redis-cli", "--raw", "incr", "ping"] test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
# interval: 30s interval: 30s
# timeout: 10s timeout: 10s
# retries: 5 retries: 5
# start_period: 30s start_period: 30s
# mongodb: # mongodb:
# image: mongo:7 # image: mongo:7
@ -366,23 +366,23 @@ services:
# networks: # networks:
# - pipeline_network # - pipeline_network
redis: # redis:
image: redis:7-alpine # image: redis:7-alpine
container_name: pipeline_redis # container_name: pipeline_redis
environment: # environment:
REDIS_PASSWORD: redis123 # REDIS_PASSWORD: redis123
REDIS_USER: redisuser # REDIS_USER: redisuser
ports: # ports:
- "6380:6379" # - "6380:6379"
volumes: # volumes:
- redis_data:/data # - redis_data:/data
command: redis-server --requirepass redis123 # command: redis-server --requirepass redis123
healthcheck: # healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"] # test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 30s # interval: 30s
timeout: 10s # timeout: 10s
retries: 3 # retries: 3
start_period: 40s # start_period: 40s
mongodb: mongodb:
image: mongo:7 image: mongo:7
@ -543,22 +543,25 @@ services:
environment: environment:
- NODE_ENV=development - NODE_ENV=development
- PORT=8000 - PORT=8000
- REDIS_HOST=redis - HOST=0.0.0.0
- REDIS_PORT=6379 # Database connections
- REDIS_PASSWORD=redis123
- POSTGRES_HOST=postgres - POSTGRES_HOST=postgres
- POSTGRES_PORT=5432 - POSTGRES_PORT=5432
- POSTGRES_DB=dev_pipeline - POSTGRES_DB=dev_pipeline
- POSTGRES_USER=pipeline_admin - POSTGRES_USER=pipeline_admin
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
# Cache and message queue
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- RABBITMQ_HOST=rabbitmq - RABBITMQ_HOST=rabbitmq
- RABBITMQ_PORT=5672 - RABBITMQ_PORT=5672
- RABBITMQ_USER=pipeline_admin - RABBITMQ_USER=pipeline_admin
- RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD} - RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD}
# JWT Configuration (must match user-auth service) # JWT configuration
- JWT_ACCESS_SECRET=access-secret-key-2024-tech4biz-${POSTGRES_PASSWORD} - JWT_ACCESS_SECRET=access-secret-key-2024-tech4biz-${POSTGRES_PASSWORD}
- JWT_REFRESH_SECRET=refresh-secret-key-2024-tech4biz-${POSTGRES_PASSWORD} - JWT_REFRESH_SECRET=refresh-secret-key-2024-tech4biz-${POSTGRES_PASSWORD}
# Internal service URLs for proxying (Docker network names) # Service URLs
- USER_AUTH_URL=http://user-auth:8011 - USER_AUTH_URL=http://user-auth:8011
- TEMPLATE_MANAGER_URL=http://template-manager:8009 - TEMPLATE_MANAGER_URL=http://template-manager:8009
- REQUIREMENT_PROCESSOR_URL=http://requirement-processor:8001 - REQUIREMENT_PROCESSOR_URL=http://requirement-processor:8001
@ -569,6 +572,9 @@ services:
- DEPLOYMENT_MANAGER_URL=http://deployment-manager:8006 - DEPLOYMENT_MANAGER_URL=http://deployment-manager:8006
- DASHBOARD_URL=http://dashboard:8008 - DASHBOARD_URL=http://dashboard:8008
- SELF_IMPROVING_GENERATOR_URL=http://self-improving-generator:8007 - SELF_IMPROVING_GENERATOR_URL=http://self-improving-generator:8007
volumes:
- api_gateway_logs:/app/logs # Add persistent volume for logs
user: "node" # Run as node user instead of root
networks: networks:
- pipeline_network - pipeline_network
depends_on: depends_on:
@ -578,6 +584,13 @@ services:
condition: service_healthy condition: service_healthy
rabbitmq: rabbitmq:
condition: service_healthy condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
requirement-processor: requirement-processor:
build: ./services/requirement-processor build: ./services/requirement-processor
@ -592,7 +605,7 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- REDIS_HOST=redis - REDIS_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=redis123 - REDIS_PASSWORD=${REDIS_PASSWORD}
- MONGODB_HOST=mongodb - MONGODB_HOST=mongodb
- MONGODB_PORT=27017 - MONGODB_PORT=27017
- NEO4J_URI=bolt://neo4j:7687 - NEO4J_URI=bolt://neo4j:7687
@ -600,7 +613,7 @@ services:
- NEO4J_PASSWORD=password - NEO4J_PASSWORD=password
- CHROMA_HOST=chromadb - CHROMA_HOST=chromadb
- CHROMA_PORT=8000 - CHROMA_PORT=8000
- REDIS_URL=redis://:redis123@redis:6379 - REDIS_URL=redis://redis:6379
networks: networks:
- pipeline_network - pipeline_network
depends_on: depends_on:
@ -624,7 +637,7 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- REDIS_HOST=redis - REDIS_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=redis123 - REDIS_PASSWORD=${REDIS_PASSWORD}
networks: networks:
- pipeline_network - pipeline_network
depends_on: depends_on:
@ -680,7 +693,7 @@ services:
- MONGODB_PORT=27017 - MONGODB_PORT=27017
- REDIS_HOST=redis - REDIS_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=redis123 - REDIS_PASSWORD=${REDIS_PASSWORD}
- CLAUDE_API_KEY=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 - CLAUDE_API_KEY=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
- OPENAI_API_KEY=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 - OPENAI_API_KEY=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
# - NEO4J_URI=bolt://neo4j:7687 # - NEO4J_URI=bolt://neo4j:7687
@ -725,7 +738,7 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- REDIS_HOST=redis - REDIS_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=redis123 - REDIS_PASSWORD=${REDIS_PASSWORD}
networks: networks:
- pipeline_network - pipeline_network
depends_on: depends_on:
@ -777,7 +790,7 @@ services:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- REDIS_HOST=redis - REDIS_HOST=redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_PASSWORD=redis123 - REDIS_PASSWORD=${REDIS_PASSWORD}
- JWT_ACCESS_SECRET=access-secret-key-2024-tech4biz-${POSTGRES_PASSWORD} - JWT_ACCESS_SECRET=access-secret-key-2024-tech4biz-${POSTGRES_PASSWORD}
- JWT_REFRESH_SECRET=refresh-secret-key-2024-tech4biz-${POSTGRES_PASSWORD} - JWT_REFRESH_SECRET=refresh-secret-key-2024-tech4biz-${POSTGRES_PASSWORD}
- JWT_ACCESS_EXPIRY=15m - JWT_ACCESS_EXPIRY=15m
@ -892,15 +905,7 @@ services:
- NODE_ENV=production - NODE_ENV=production
- PORT=8008 - PORT=8008
- DATABASE_URL=postgresql://pipeline_admin:${POSTGRES_PASSWORD}@postgres:5432/dev_pipeline - DATABASE_URL=postgresql://pipeline_admin:${POSTGRES_PASSWORD}@postgres:5432/dev_pipeline
- POSTGRES_HOST=postgres - REDIS_URL=redis://pipeline_redis:6379
- POSTGRES_PORT=5432
- POSTGRES_DB=dev_pipeline
- POSTGRES_USER=pipeline_admin
- POSTGRES_PASSWORD=secure_pipeline_2024
- REDIS_URL=redis://:redis123@redis:6379
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=redis123
- API_GATEWAY_URL=http://pipeline_api_gateway:8000 - API_GATEWAY_URL=http://pipeline_api_gateway:8000
- CODE_GENERATOR_URL=http://pipeline_code_generator:8004 - CODE_GENERATOR_URL=http://pipeline_code_generator:8004
- SELF_IMPROVING_URL=http://pipeline_self_improving_generator:8007 - SELF_IMPROVING_URL=http://pipeline_self_improving_generator:8007
@ -992,6 +997,8 @@ volumes:
driver: local driver: local
chromadb_data: chromadb_data:
driver: local driver: local
api_gateway_logs:
driver: local
# ===================================== # =====================================
# Networks # Networks
@ -1008,4 +1015,3 @@ networks:
# Self-Improving Code Generator # Self-Improving Code Generator
# ===================================== # =====================================

View File

@ -157,7 +157,8 @@ const websocketHandlers = websocketAuth(io);
// Auth Service - Fixed proxy with proper connection handling // Auth Service - Fixed proxy with proper connection handling
console.log('🔧 Registering /api/auth proxy route...'); console.log('🔧 Registering /api/auth proxy route...');
app.use('/api/auth', (req, res, next) => { app.use('/api/auth', (req, res, next) => {
console.log(`🔥 [AUTH PROXY] ${req.method} ${req.originalUrl} → http://localhost:8011${req.originalUrl}`); const authServiceUrl = serviceTargets.USER_AUTH_URL;
console.log(`🔥 [AUTH PROXY] ${req.method} ${req.originalUrl}${authServiceUrl}${req.originalUrl}`);
// Set response timeout to prevent hanging // Set response timeout to prevent hanging
res.setTimeout(15000, () => { res.setTimeout(15000, () => {
@ -169,7 +170,7 @@ app.use('/api/auth', (req, res, next) => {
const options = { const options = {
method: req.method, method: req.method,
url: `http://localhost:8011${req.originalUrl}`, url: `${authServiceUrl}${req.originalUrl}`,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'User-Agent': 'API-Gateway/1.0', 'User-Agent': 'API-Gateway/1.0',
@ -222,7 +223,8 @@ app.use('/api/templates',
authMiddleware.verifyToken, authMiddleware.verifyToken,
authMiddleware.forwardUserContext, authMiddleware.forwardUserContext,
(req, res, next) => { (req, res, next) => {
console.log(`🔥 [TEMPLATE PROXY] ${req.method} ${req.originalUrl} → http://localhost:8009${req.originalUrl}`); const templateServiceUrl = serviceTargets.TEMPLATE_MANAGER_URL;
console.log(`🔥 [TEMPLATE PROXY] ${req.method} ${req.originalUrl}${templateServiceUrl}${req.originalUrl}`);
// Set response timeout to prevent hanging // Set response timeout to prevent hanging
res.setTimeout(15000, () => { res.setTimeout(15000, () => {
@ -234,7 +236,7 @@ app.use('/api/templates',
const options = { const options = {
method: req.method, method: req.method,
url: `http://localhost:8009${req.originalUrl}`, url: `${templateServiceUrl}${req.originalUrl}`,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'User-Agent': 'API-Gateway/1.0', 'User-Agent': 'API-Gateway/1.0',

View File

@ -10,7 +10,7 @@ class Database {
password: process.env.POSTGRES_PASSWORD || 'secure_pipeline_2024', password: process.env.POSTGRES_PASSWORD || 'secure_pipeline_2024',
max: 20, max: 20,
idleTimeoutMillis: 30000, idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000, connectionTimeoutMillis: 10000,
}); });
// Test connection on startup // Test connection on startup
@ -24,7 +24,8 @@ class Database {
client.release(); client.release();
} catch (err) { } catch (err) {
console.error('❌ User Auth Database connection failed:', err.message); console.error('❌ User Auth Database connection failed:', err.message);
process.exit(1); // Don't exit the process, just log the error
// The service can still start and retry connections later
} }
} }