A zk-based verifiable recommender system for recommending articles from Rekt News. It generates similarity matrices and provides cryptographic proofs to ensure the integrity of the computation. The current system is content-based, with plans underway to evolve into a hybrid recommender by incorporating collaborative filtering techniques.
We believe no news site or social platform should control what you see behind the scenes. Our mission is to build a web where integrity and transparency come first.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β API Layer β β Text Processor β β ZK Proof Gen β
β β β β β β
β β’ Authenticationββββββ β’ Cleaning ββββββ β’ LuminAIR β
β β’ Request Route β β β’ Stemming β β β’ Verification β
β β’ Error Handle β β β’ N-gram Gen β β β’ Serialization β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β Similarity Calc β
β β
β β’ TF-IDF Matrix β
β β’ Cosine Sim β
β β’ Result Export β
βββββββββββββββββββ
- Input Validation: JSON structure validation and content type verification
- Text Preprocessing:
- URL and crypto address removal
- Markdown syntax cleaning
- Stop word filtering
- Word stemming and normalization
- Feature Extraction:
- Term frequency calculation
- N-gram generation (bigrams and trigrams)
- Tag and auditor boosting
- TF-IDF Computation:
- Inverse document frequency calculation
- Term filtering by document frequency
- Matrix construction
- Similarity Analysis (Verifiable):
- Vector normalization
- Cosine similarity computation
- Zero-knowledge proof generation
- Result Storage:
- Matrix serialization
- Proof data export
- Metadata generation
GET /healthResponse:
{
"status": "healthy",
"service": "rekt-recommender-api",
"version": "0.1.3"
}POST /process
Content-Type: application/json
X-API-Key: your-api-keyRequest Body:
{
"timestamp": 1640995200,
"posts": [
{
"date": "12/31/2023",
"title": "DeFi Protocol Exploit Analysis",
"excerpt": "Detailed analysis of the recent exploit...",
"slug": "defi-protocol-exploit-analysis",
"tags": ["DeFi", "Security", "Analysis"],
"rekt": {
"amount": 50000000,
"audit": "Trail of Bits",
"date": "12/30/2023"
}
}
]
}Response:
{
"request_id": "123e4567-e89b-12d3-a456-426614174000",
"status": "success",
"message": "Articles processed successfully",
"data": {
"articles_processed": 45,
"similarity_matrix_shape": [45, 45],
"proof_size_bytes": 2048,
"output_directory": "./outputs/result_123e4567-e89b-12d3-a456-426614174000"
}
}GET /download/{request_id}
X-API-Key: your-api-keyResponse: ZIP file containing:
article_ids.json- List of processed article identifierssimilarity_matrix.json- Computed similarity matrixproof.bin- Zero-knowledge proof datacircuit_settings.bin- Proof verification settingsmetadata.json- Processing metadata and statistics
POST /cleanup
X-API-Key: your-api-keyResponse:
{
"request_id": "123e4567-e89b-12d3-a456-426614174000",
"status": "success",
"message": "Manual cleanup completed. Removed directories older than 24 hours."
}| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 8080 |
No |
MAX_UPLOAD_SIZE_MB |
Maximum upload size in MB | 100 |
No |
API_KEY |
Authentication key (min 16 chars) | - | Yes |
OUTPUT_DIR |
Results storage directory | ./outputs |
No |
RESULT_TTL_HOURS |
Result retention time in hours | 24 |
No |
The system uses configurable parameters for text processing:
- Tag Boost:
5x- Multiplier for tag term importance - Auditor Boost:
3x- Multiplier for auditor term importance - Max Document Percentage:
80%- Maximum document frequency for terms - Min Document Thresholds:
- Unigrams:
5documents minimum - N-grams:
2documents minimum
- Unigrams:
- Rust 1.70+ with Cargo
- Git
-
Clone the repository:
git clone <repository-url> cd rekt-recommender-api
-
Set up environment variables:
export API_KEY="your-secure-api-key-here-min-16-chars" export PORT=8080 export OUTPUT_DIR="./outputs" export RESULT_TTL_HOURS=24
-
Build and run:
# Development cargo run # Production cargo build --release ./target/release/rekt-recommender-api
-
Build the image:
docker build -t rekt-recommender . -
Run the container:
docker run -d \ -p 8080:8080 \ -e API_KEY="your-secure-api-key" \ -e OUTPUT_DIR="/app/outputs" \ -v $(pwd)/outputs:/app/outputs \ rekt-recommender
The project includes a cloudbuild.yaml configuration for automated deployment to Google Cloud:
gcloud builds submit --config cloudbuild.yaml .# Process articles from JSON file
curl -X POST http://localhost:8080/process \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d @articles.json# Download processing results
curl -X GET http://localhost:8080/download/123e4567-e89b-12d3-a456-426614174000 \
-H "X-API-Key: your-api-key" \
-o results.zip# Check service health
curl http://localhost:8080/healthsrc/
βββ main.rs # Application entry point and server setup
βββ api.rs # HTTP handlers and authentication
βββ config.rs # Configuration management
βββ types.rs # Data structures and serialization
βββ utils.rs # Utility functions for file operations
βββ recommender/
βββ mod.rs # Main recommender system logic
βββ text_processing.rs # Natural language processing
- RecommenderSystem: Main orchestrator for the processing pipeline
- TextProcessor: Handles all text cleaning and feature extraction
- ApiKey: Request guard for authentication
- CleanupFairing: Background task manager for result cleanup
# Install dependencies
cargo build
# Run tests
cargo test
# Check for linting issues
cargo clippy
# Format code
cargo fmt