Spaces:
Build error
Build error
File size: 6,779 Bytes
1ac9f32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | ---
title: The Algorithm
emoji: π§
colorFrom: pink
colorTo: red
sdk: docker
app_port: 7860
pinned: false
license: mit
short_description: AI-powered relationship analyzer β privacy-first, BYOK.
---
<div align="center">
<img src="static/favicon.png" width="120" alt="The Algorithm Logo" style="border-radius: 1rem; margin-bottom: 2rem;" />
<h1>The Algorithm</h1>
<p><strong>A paranoid-level, privacy-first AI relationship analyzer.</strong></p>
<p>Stop sending your most intimate chat history to random servers.</p>
<p>
<a href="https://img.shields.io/badge/python-3.11+-blue?style=for-the-badge&logo=python&logoColor=white"><img src="https://img.shields.io/badge/python-3.11+-blue?style=for-the-badge&logo=python&logoColor=white" alt="Python" /></a>
<a href="https://img.shields.io/badge/Flask-3.0+-black?style=for-the-badge&logo=flask&logoColor=white"><img src="https://img.shields.io/badge/Flask-3.0+-black?style=for-the-badge&logo=flask&logoColor=white" alt="Flask" /></a>
<a href="https://img.shields.io/badge/Privacy-100%25%20Zero--Knowledge-22c55e?style=for-the-badge"><img src="https://img.shields.io/badge/Privacy-100%25%20Zero--Knowledge-22c55e?style=for-the-badge" alt="Privacy" /></a>
</p>
<h3>π <a href="https://thealgorithm.rixabh.workers.dev/">Try the Live App Here</a></h3>
</div>
<hr/>
## π Overview
**The Algorithm** is an open-source tool that analyzes exported chat logs from WhatsApp, Telegram, Instagram, and Discord to generate comprehensive behavioral insights and relationship coaching.
Unlike other platforms that store and read your data, The Algorithm operates on a strict **zero-knowledge, BYOK (Bring Your Own Key)** architecture. Your chat data is parsed in volatile memory, anonymized on the edge, and instantly destroyed the millisecond the analysis completes.
## β¨ Features
- **Deep AI Analysis**: Generate an instant "Spotify Wrapped" style report detailing communication health, attachment styles, humor synchronization, and areas for growth.
- **True Cross-Platform**: Natively supports chat exports from `WhatsApp (.txt)`, `Telegram (.html)`, `Instagram (.json)`, and `Discord (.json)`.
- **Bring Your Own Key (BYOK)**: Supports Google Gemini, Anthropic Claude, and OpenAI GPT-4o. You provide the API key; we provide the engine.
- **Retro Groovy Pop-Art UI**: A gorgeous, vibrant interface featuring paper grain textures, bold typography, and personality-driven design.
- **Shareable Vibe Card**: Export a beautifully designed snap of your relationship stats (Total Messages, Share %, Avg Response, and Mirroring).
- **Customizable Analysis Tone**: Control the AI's personality by choosing between Playful, Balanced, or Direct analysis modes.
## π‘οΈ Zero-Knowledge Architecture
We don't want your data. Period.
1. **Client-Side Anonymization**: Personally Identifiable Information (PII) like emails, phone numbers, and full names are heavily redacted directly in the browser *before* the data touches our server.
2. **Pure RAM Processing**: We refuse to use a database. Uploaded files are streamed into active memory, parsed, and never written permenantly to disk.
3. **Aggressive Deletion**: A strict Python `finally` block guarantees that all temporary memory associated with your session is permanently destroyed instantly.
4. **Stats-Only LLM Pipeline**: Your raw chat logs are *never* sent to OpenAI, Anthropic, or Google. Our Python backend processes the chats locally and sends only an anonymous, numerical statistical payload to the LLM.
## π Getting Started Locally
Running The Algorithm on your own machine takes less than two minutes.
### Prerequisites
- Python 3.11+
- Virtualenv or Conda (recommended)
### Installation
1. Clone the repository and navigate to the project directory:
```bash
git clone https://github.com/rixabhh/TheAlgorithm.git
cd TheAlgorithm
```
2. Create a virtual environment and install dependencies:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
```
3. Run the Flask application:
```bash
python app.py
```
4. Open `http://127.0.0.1:7860` in your browser.
## π³ Docker Deployment
The Algorithm is fully dockerized and ready for production deployment on render, Railway, or VPS.
```bash
docker build -t the-algorithm .
docker run -p 7860:7860 the-algorithm
```
## ποΈ Architecture Flowchart
```mermaid
graph TD
A[User Uploads Chat] -->|Browser| B(Client-Side Scrubbing);
B -->|Sensitive Data Masked| C[Flask Server app.py];
C -->|Memory Buffer| D{Platform Parser};
D -->|WhatsApp| E[JSON Message Array];
D -->|Telegram| E;
D -->|Instagram| E;
D -->|Discord| E;
E --> F[Analytics Engine];
F -->|Raw Stats| G[LLM Service];
G -->|API Request| H((OpenAI / Anthropic / Gemini));
H -->|JSON Report| I[Dashboard UI];
I -->|User Session Ends| J((Data Destroyed Forever));
classDef user fill:#8b5cf6,stroke:#fff,color:#fff
classDef secure fill:#22c55e,stroke:#fff,color:#fff
classDef danger fill:#f43f5e,stroke:#fff,color:#fff
class A user;
class B,J secure;
class H danger;
```
## π Project Structure
```text
TheAlgorithm/
βββ app.py # Main Flask application & routes
βββ core/
β βββ analytics.py # Calculates conversation statistics
β βββ llm_service.py # Handles external BYOK LLM API requests
β βββ parsers.py # Platform-specific chat parsers (WA, TG, IG, Discord)
βββ static/
β βββ css/style.css # Retro Pop-Art Vanilla CSS design system
β βββ js/ # Client-side UI logic and PII scrubbing
β βββ fonts/ # Self-hosted fonts for privacy
βββ templates/
β βββ index.html # Landing page & upload interface
β βββ dashboard.html # Analytics & Insights display
β βββ instructions.html # Export walkthroughs per platform
β βββ privacy.html # Detailed zero-knowledge policy
βββ .github/workflows/ # CI/CD and Hugging Face deployment Action
βββ requirements.txt # Python dependencies
```
## π€ Contributors
Contributions are completely welcome! Be it adding support for a new chat platform, improving the analytical models, or refining the UI.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |