Configuration & Environment
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The AI Assistant platform operates using a distributed configuration model spanning three primary tiers: a Python-based Machine Learning (ML) service, a Node.js Authentication and Orchestration service, and a React-based frontend. This system relies on environment variables defined in .env files and static configurations within Python modules to manage API keys, database connection strings, and model parameters.
The environment is designed to support dual AI execution paths: local inference using the Phi-3 model and remote inference via the Google Gemini API. Orchestration of these environments is managed through a central startup sequence that ensures service availability and health before initializing the full application stack.
Sources: README.md:12-42, PROJECT_STRUCTURE_GIT.md:73-100
Service Ports & Network Layout
The application architecture is segmented by specific port assignments to facilitate inter-service communication via REST APIs.
| Service | Port | Description |
|---|---|---|
| Python AI Service | 5000 | Flask-based API for model inference and NLP tasks. |
| Node.js Auth Service | 5001 | Express server managing users, MongoDB, and service orchestration. |
| React Frontend | 3000 | Vite-powered development server for the user interface. |
| MongoDB | 27017 | Database for persisting users, conversations, and memories. |
Sources: README.md:15-37, QUICK_START.md:16-20, start_app.bat:27-80
The following diagram illustrates the network flow and port dependencies during a standard user interaction:
Environment Variables
The system requires specific environment variables to be defined in .env files located in the respective service directories.
Node.js Auth Service Configuration
Located at Ai-Assistant-v2/auth-service/.env.
| Variable | Default Value | Description |
|---|---|---|
PORT | 5001 | Listening port for the orchestration service. |
MONGODB_URI | mongodb://127.0.0.1:27017/ai-assistant-v2 | Connection string for MongoDB. |
JWT_SECRET | N/A (Required) | Secret key for signing JSON Web Tokens. |
PYTHON_AI_URL | http://localhost:5000 | URL for the backend Python ML service. |
NODE_ENV | development | Operating environment mode. |
Sources: README.md:104-109, Ai-Assistant-v2/auth-service/server.js:16-18
Python AI Service Configuration
Located at backend/.env.
| Variable | Description |
|---|---|
PORT | Listening port for the Flask service (default 5000). |
GEMINI_API_KEY | API key for Google Generative AI integration. |
Sources: README.md:99-101, backend/ml_config/model_config.py:31
Machine Learning Configuration
The Python service uses a structured configuration file backend/ml_config/model_config.py to manage internal model parameters and paths.
Phi-3 Local Model Settings
The local model is configured to run specifically on the CPU to avoid stability issues with certain GPU drivers.
PHI3_CONFIG = {
'model_path': os.path.join(MODELS_DIR, 'phi3', 'Phi-3-mini-4k-instruct-q4.gguf'),
'use_gpu': False,
'n_gpu_layers': 0,
'n_ctx': 2048,
'n_threads': 8,
'temperature': 0.3,
'max_tokens': 500,
}
Sources: backend/ml_config/model_config.py:12-23
Gemini API Settings
Remote inference parameters for the Google Gemini integration.
| Parameter | Value | Description |
|---|---|---|
model_name | gemini-flash-latest | The specific model version used. |
temperature | 0.7 | Controls randomness in generation. |
top_p | 0.95 | Nucleus sampling probability. |
max_tokens | 500 | Response length limit. |
Sources: backend/ml_config/model_config.py:30-36
Runtime Management & Health Checks
The environment state is managed through start_app.bat, which performs sequential health checks using PowerShell to verify service readiness before continuing the boot process.
Security and Persistence
Environment security is enforced by ignoring .env and large model files in Git.
- Git Ignored Files:
.env(all directories),*.gguf(models),node_modules/,.venv/. - Database Persistence: User data, conversation history, and memories are persisted in MongoDB. The
UserSchemaincludes an auto-hashing middleware for passwords usingbcrypt(10 rounds) before storage.
Sources: PROJECT_STRUCTURE_GIT.md:144-154, Ai-Assistant-v2/auth-service/server.js:37-45
Conclusion
The configuration environment of the AI Assistant provides a rigid yet configurable structure that facilitates dual-model operations. By isolating secrets in environment variables and centralizing model parameters in Python modules, the system ensures that performance-critical settings (like CPU threading for Phi-3) are maintained while allowing flexible deployments across different environments.