Skip to content

Kashcx-dev/InstaKG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

InstaKG

React NodeJS C++ Postgres WebAssembly Socket.io

InstaKG is a secure, real-time messaging application focused on uncompromising privacy. It features a custom End-to-End Encryption (E2EE) protocol utilizing a unique "degenerative tree" architecture for scalable group messaging, backed by a high-performance WebAssembly math engine.

Core Features

  • Custom E2EE Degenerative Tree: Unlike standard paired ratchets, InstaKG chains group participants cryptographically based on their join order. This allows secure, scalable group key distribution without compromising zero-knowledge principles.
  • High-Performance Cryptography: A custom C++ math engine (math_engine.cpp) handles intensive modular exponentiation, compiled to WebAssembly (Wasm) to run natively in the browser.
  • Real-Time Communication: Instant message delivery via WebSockets (Socket.io), including live reactions, read receipts, and role-based group management.
  • Built-in AI Assistant: ikg_bot is an integrated Small Language Model (SLM) powered by Ollama, ready to assist users directly within their chats.

Architecture Pipeline

graph TD
    A[Client UI - React] -->|Message Input| B(Wasm Math Engine)
    B -->|Encrypt payload using Group Key| C[Encrypted Payload]
    C -->|Socket.io / HTTP| D(Backend API - Node.js)
    D -->|Verify Auth & Store Log| E[(PostgreSQL Database)]
    D -->|Socket.io Emit| F[Recipient Client]
    F -->|Wasm Math Engine| G[Decrypt Message]
    G --> H[Render in UI]
    
    subgraph "IKG Bot Integration"
    D -->|If @ikg_bot triggered| I[Ollama SLM]
    I -->|Generate response| D
    end
Loading

Tech Stack

  • Frontend: React, Vite, WebAssembly (C++ via Emscripten), Socket.io-client
  • Backend: Node.js, Express, Socket.io, Multer, DOMPurify
  • Database: PostgreSQL (pg)
  • AI Integration: Ollama (gemma2:2b)

Environment Configuration

To run this project locally, you must configure two separate .env files for the frontend and backend.

1. Backend .env

Create a .env file in the backend/ directory:

PORT=5000
JWT_SECRET=your_jwt_secret_here
CRYPT_SALT=12
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
PG_USER=postgres
PG_PASSWORD=your_db_password
PG_HOST=localhost
PG_PORT=5432
PG_DATABASE=instakg

2. Frontend .env

Create a .env file in the react-frontend/ directory. These variables act as the base parameters for the cryptographic math engine:

VITE_SEED=98
VITE_BASE=19
VITE_MODULUS=4294967291

Setup Instructions

  1. Database Setup

    • Ensure PostgreSQL is running locally.
    • Create a database named instakg (or match your PG_DATABASE env variable).
  2. Backend Setup

    cd backend
    npm install
    npm start

    Note: The backend starts via node src/main.js. Ensure Ollama is running locally if you want to use the ikg_bot.

  3. Frontend Setup

    cd react-frontend
    npm install
    npm run dev

    Note: If you make changes to the cryptographic logic in math_engine.cpp, you will need to recompile it to WebAssembly using Emscripten (emcc) before restarting the frontend development server.

About

InstaKG is a next-generation chat app where human connection meets instant AI assistance, all seamlessly woven into one conversation.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages