Installation and Setup
Step-by-step guide to install and run Oneliac.
System Requirements
Minimum Requirements
- OS: Linux, macOS, or Windows
- Python: 3.9+
- RAM: 2 GB
- Storage: 500 MB
Recommended for Production
- OS: Linux (Ubuntu 20.04+)
- Python: 3.11+
- RAM: 8 GB+
- Storage: 10 GB+ SSD
- CPU: Multi-core (4+)
Installation Steps
Step 1: Clone Repository
git clone https://github.com/Oneliac/Product-Oneliac.git
cd Product-Oneliac
Step 2: Create Virtual Environment
# Using venv
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Or using conda
conda create -n oneliac python=3.11
conda activate oneliac
Step 3: Install Dependencies
pip install -r requirements.txt
Key dependencies:
- FastAPI: Web framework
- Pydantic: Data validation
- Cryptography: Encryption
- PyTorch: Machine learning
- aiohttp: Async HTTP client
Step 4: Set Environment Variables
# Create .env file
cat > .env << EOF
# Blockchain
SOLANA_ENDPOINT=https://api.devnet.solana.com
# Server
HOST=0.0.0.0
PORT=8000
LOG_LEVEL=info
# Database (if using external)
DATABASE_URL=sqlite:///oneliac.db
# IPFS (optional)
IPFS_ENDPOINT=https://ipfs.io
# Encryption
FERNET_KEY=your_base64_encryption_key_here
EOF
# Load environment variables
source .env
Step 5: Run API Server
# Development (with auto-reload)
uvicorn agents.api:app --reload --host 0.0.0.0 --port 8000
# Production (see Deployment section)
uvicorn agents.api:app --host 0.0.0.0 --port 8000 --workers 4
Step 6: Verify Installation
# Check health endpoint
curl http://localhost:8000/health
# Expected response
{
"status": "healthy",
"version": "0.1.0",
"message": "Healthcare agents API operational"
}
Access interactive API docs at: http://localhost:8000/docs
Configuration
FastAPI Configuration
# agents/api.py
app = FastAPI(
title="Privacy-Preserving Healthcare Agents API",
description="Decentralized medical data analysis with zero-knowledge proofs",
version="0.1.0",
docs_url="/docs",
redoc_url="/redoc"
)
# CORS Configuration
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Restrict in production
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Solana Configuration
# agents/api.py
solana_endpoint = os.getenv(
"SOLANA_ENDPOINT",
"https://api.devnet.solana.com"
)
# Available endpoints:
# - Devnet (testing): https://api.devnet.solana.com
# - Testnet: https://api.testnet.solana.com
# - Mainnet-beta: https://api.mainnet-beta.solana.com
Database Setup (Optional)
For persistent storage:
# Using SQLite (default)
# Database created automatically
# Using PostgreSQL
pip install psycopg2-binary
export DATABASE_URL=postgresql://user:password@localhost/oneliac
# Using MySQL
pip install mysql-connector-python
export DATABASE_URL=mysql://user:password@localhost/oneliac
Encryption Key Generation
Generate and secure encryption keys:
from cryptography.fernet import Fernet
import base64
# Generate key
key = Fernet.generate_key()
print(f"Encryption key: {key.decode()}")
# Save to secure location
with open('/secure/location/encryption_key.bin', 'wb') as f:
f.write(key)
# Load in application
with open('/secure/location/encryption_key.bin', 'rb') as f:
encryption_key = f.read()
cipher = Fernet(encryption_key)
Testing Installation
Run Unit Tests
pytest tests/ -v
Run Specific Test
pytest tests/test_agents.py::test_eligibility_check -v
Test API Endpoints
# Test health endpoint
curl http://localhost:8000/health
# Test eligibility endpoint
curl -X POST http://localhost:8000/verify-eligibility \
-H "Content-Type: application/json" \
-d '{
"patient_data": {
"patient_id": "TEST_001",
"encrypted_data": "test_data",
"ipfs_cid": "QmTest",
"data_hash": "abc123"
},
"procedure_code": "PROC001"
}'
Troubleshooting Installation
Issue: Python Version Mismatch
# Check Python version
python --version
# If version < 3.9, install newer version
# macOS: brew install python@3.11
# Ubuntu: sudo apt-get install python3.11
Issue: PyTorch Installation Fails
# PyTorch requires specific CPU/GPU support
# Install CPU version
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Or with GPU support (CUDA 11.8)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Issue: Port Already in Use
# Use different port
uvicorn agents.api:app --port 8001
# Or kill process using port 8000
lsof -i :8000
kill -9 <PID>
Issue: Module Not Found
# Ensure virtual environment is activated
source venv/bin/activate
# Reinstall dependencies
pip install -r requirements.txt
# Check installation
pip list
Development Workflow
Install Development Dependencies
pip install -r requirements-dev.txt
Includes:
- pytest: Testing framework
- black: Code formatter
- flake8: Linter
- mypy: Type checker
Code Formatting
# Format code with black
black agents/
# Check linting
flake8 agents/
# Type checking
mypy agents/
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=agents
# Run specific test file
pytest tests/test_agents.py
Next Steps
- Docker Deployment - Containerize for easier deployment
- Production Setup - Configure for production
- Monitoring - Set up monitoring and logging
- Security - Implement security measures
Quick Start Summary
# 1. Clone and setup
git clone https://github.com/Oneliac/Product-Oneliac.git
cd Product-Oneliac
python3 -m venv venv
source venv/bin/activate
# 2. Install and configure
pip install -r requirements.txt
cp .env.example .env
# 3. Run
uvicorn agents.api:app --reload
# 4. Access
open http://localhost:8000/docs