A privacy-preserving data analysis platform using homomorphic encryption and secure machine learning. This platform allows you to perform statistical computations and ML predictions on encrypted data without ever decrypting it.
- Statistical Operations: Average, Sum, Variance, Count
- Machine Learning: Logistic Regression, Linear Regression
- Homomorphic Encryption: CKKS scheme for floating-point operations
- Zero-Knowledge: Server never sees actual data values
- Web Interface: Intuitive drag-and-drop file upload
- REST API: Complete API documentation
- Real-time Results: Instant encrypted computation results
- Visualization: Interactive charts and graphs
- End-to-End Encryption: Data encrypted before leaving client
- Secure Computation: Homomorphic operations on encrypted data
- Audit Logging: Complete operation tracking
- CORS Protection: Configurable cross-origin policies
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ Backend │ │ Database │
│ (HTML/JS) │◄──►│ (FastAPI) │◄──►│ (SQLite) │
│ Port 3000 │ │ Port 8000 │ │ (Logs) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Python 3.8+
- pip (Python package manager)
-
Clone the repository
git clone <repository-url> cd homomorphic-privacy-platform
-
Install dependencies
pip install -r backend/requirements.txt
-
Start the system
python start_system.py
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
homomorphic-privacy-platform/
├── backend/ # Backend FastAPI application
│ ├── main.py # FastAPI application entry point
│ ├── encryption_utils.py # Homomorphic encryption utilities
│ ├── requirements.txt # Python dependencies
│ ├── routes/ # API route modules
│ │ ├── compute.py # Statistical operations
│ │ ├── model.py # ML predictions
│ │ └── logs.py # Logging and reports
│ ├── db/ # Database models
│ │ └── models.py # SQLite models
│ └── utils/ # Utility functions
├── frontend/ # Frontend web application
│ ├── index.html # Main web interface
│ ├── logs.html # Logs interface
│ ├── script.js # Frontend JavaScript
│ ├── logs.js # Logs JavaScript
│ └── style.css # Styling
├── sample_data/ # Sample datasets for testing
│ ├── financial_data.csv # Financial dataset
│ ├── housing_data.csv # Housing dataset
│ ├── medical_data.csv # Medical dataset
│ ├── student_scores.csv # Student scores dataset
│ └── generate_sample_data.py # Data generator
├── encrypted_data/ # Mock encrypted data for testing
│ ├── encrypted_test_data.json # General test data
│ ├── encrypted_financial_data.json # Financial encrypted data
│ ├── encrypted_medical_data.json # Medical encrypted data
│ ├── encrypted_housing_data.json # Housing encrypted data
│ ├── encrypted_student_data.json # Student encrypted data
│ └── generate_encrypted_data.py # Encrypted data generator
├── local_client/ # Local client utilities
│ ├── encrypt_and_send.py # Client encryption script
│ └── requirements.txt # Client dependencies
├── logs/ # Application logs
├── start_system.py # MAIN: Unified system startup
├── start_backend.py # Backend-only startup
├── start_frontend.py # Frontend-only startup
├── start_system.bat # Windows batch script
├── start_system.sh # Linux/Mac shell script
├── test_system.py # System integration tests
├── docker-compose.yml # Docker orchestration
├── Dockerfile # Root Dockerfile
├── netlify.toml # Netlify deployment config
├── vercel.json # Vercel deployment config
├── env.example # Environment variables template
└── README.md # This file
python start_system.pyThis starts both backend and frontend automatically.
# Terminal 1 - Backend
python start_backend.py
# Terminal 2 - Frontend
python start_frontend.py# Windows
start_system.bat
# Linux/Mac
chmod +x start_system.sh
./start_system.shpython test_system.pypython sample_data/generate_sample_data.pypython encrypted_data/generate_encrypted_data.pyGET /healthPOST /compute/average
POST /compute/sum
POST /compute/variance
POST /compute/countPOST /model/predict/logistic_regression
POST /model/predict/linear_regressionGET /logs/ # List all logs
GET /logs/stats # Operation statistics
GET /logs/report/csv # Generate CSV report
GET /logs/report/download/{filename} # Download report- Host:
0.0.0.0(configurable inmain.py) - Port:
8000(configurable inmain.py) - Logs: Stored in
logs/directory - Database: SQLite in
backend/data/logs.db
- Port:
3000(configurable instart_frontend.py) - API URL:
http://localhost:8000(configurable inscript.js)
# Build the Docker image
docker build -t encrypted-analytics .
# Run the container
docker run -p 8000:8000 encrypted-analyticsdocker-compose up -d- Purpose: Raw CSV datasets for testing
- Generated by:
generate_sample_data.py - Contains: Financial, medical, housing, and student data
- Purpose: Mock encrypted data for testing API endpoints
- Generated by:
generate_encrypted_data.py - Note: This is mock encrypted data for demonstration purposes
The local_client/ directory contains a Python client library for:
- Encrypting data using homomorphic encryption
- Sending encrypted data to the backend API
- Receiving and decrypting computation results
- Testing the system programmatically
# Run demo
python local_client/encrypt_and_send.py --demo
# Custom computation
python local_client/encrypt_and_send.py --operation average --data 1 2 3 4 5- Demo Mode: Uses mock encryption for demonstration
- Production Ready: Framework supports real homomorphic encryption
- Key Management: Keys should be managed securely in production
- Replace mock encryption with real TenSEAL implementation
- Implement proper key management
- Add authentication and authorization
- Configure HTTPS
- Set up proper logging and monitoring
The system provides comprehensive logging:
- Application Logs:
logs/app.log - Startup Logs:
logs/startup.log - Database Logs: Stored in SQLite database
- API Logs: Available via
/logs/endpoints
- Use the provided startup scripts
- Access via localhost
- Use Dockerfile for containerized deployment
- Suitable for cloud platforms
- Frontend: Vercel/Netlify (using
vercel.json/netlify.toml) - Backend: Render/Railway/Heroku
- Database: Cloud SQL/PostgreSQL
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the API documentation at
http://localhost:8000/docs - Review the logs in the
logs/directory - Open an issue in the repository
- Real homomorphic encryption implementation
- Additional ML models (Random Forest, Neural Networks)
- Multi-party computation support
- Cloud deployment guides
- Performance optimization
- Advanced visualization features
- Authentication and authorization
- Production environment configuration
** Note**: This is a demonstration platform. For production use, implement proper security measures and real homomorphic encryption.
# Start everything
python start_system.py
# Test the system
python test_system.py
# Generate sample data
python sample_data/generate_sample_data.py
# Generate encrypted test data
python encrypted_data/generate_encrypted_data.py
# Run client demo
python local_client/encrypt_and_send.py --demo