Skip to content

ZohebHasan/Connect

Repository files navigation

Connect: Developer Documentation

Introduction

Welcome to Connect, a revolutionary platform that redefines social media by giving users full control over their data. Our goal is to empower users and provide a secure, privacy-centric platform. We prioritize data protection while providing an exceptional digital experience.

The platform is divided into three branches:

  1. Personal
  2. Professional
  3. Educational

Users can customize their experience across these categories and control what content is visible in each branch.


Table of Contents

  1. Introduction
  2. Getting Started
  3. Version Control
  4. Security
  5. Content Analysis and Moderation
  6. Social Networking Algorithm
  7. Messaging

Getting Started

2.1 Dependencies and Initialization

File Directory Structure

CONNECT
│
├── client
│   ├── build
│   ├── node_modules
│   ├── public
│   ├── src
│   ├── types
│   ├── .gitignore
│   ├── package-lock.json
│   ├── package.json
│   ├── tsconfig.json
│   └── Documentations
│
├── server
│   ├── dist
│   ├── node_modules
│   ├── src
│   ├── types
│   ├── .gitignore
│   ├── package-lock.json
│   ├── package.json
│   └── tsconfig.json
│
├── UML
├── .env
└── connect_documentation.md

Client Setup

  1. Navigate to the client directory:

    cd client
  2. Install the required dependencies:

    npm install
  3. Start the React server:

    npm start

    You can now view Connect in the browser at http://localhost:3000.

Note: The development build is not optimized. Use npm run build to create a production build.


Server Setup

  1. Navigate to the server directory:

    cd server
  2. Install the required dependencies:

    npm install
  3. Compile the TypeScript files:

    cd src
    npx tsc

    This creates .js executables inside the dist directory.

  4. Start the server:

    cd ..
    node dist/server.js

    The server will run on http://localhost:8000.


Database Setup

We use MongoDB as the database for Connect.

  1. Download MongoDB Compass from here.

  2. Connect to the database using the following connection string:

    mongodb+srv://kamrulhassan:fNXADjxipNKubPlP@connect.ny9wvom.mongodb.net/
    

Note: Do not share the connection string with anyone.


Version Control

Git Commands

Make sure you are in the root directory before running these commands.

  1. Add your changes:

    git add .
  2. Commit your changes:

    git commit -m "your message"
  3. Push to your branch:

    git push origin <your_branch>
  4. To check your current branch:

    git branch

Pushing Code

  • Always push to your respective branch first. Collaborate with your teammates through pull requests.
  • Kamrul and Zoheb are the only ones who can push from the TestBranch to main.

Creating a Pull Request

  1. Go to GitHub Pull Requests.
  2. Click on New pull request.
  3. Choose the branch you want to merge from and into.

Security

End-to-End Encryption

We use the Signal Protocol to ensure secure messaging and profile content protection in Connect.

Messaging Encryption

  • Key Generation: Each user generates a unique identity key pair during registration, which consists of identity keys and pre-keys.
  • Double Ratchet Algorithm: Ensures that each message is encrypted with a unique key, offering forward secrecy.

Code Snippets for E2E Encryption in TypeScript

Key Generation:

import { generateIdentityKeyPair, generatePreKeyBundle } from '@signalapp/libsignal-client';

const generateKeys = async () => {
    const identityKeyPair = await generateIdentityKeyPair();
    const preKeyBundle = await generatePreKeyBundle(identityKeyPair);
    return { identityKeyPair, preKeyBundle };
};

Session Setup:

import { SignalProtocolAddress, SessionBuilder, PreKeyBundle } from '@signalapp/libsignal-client';

const setupSession = async (store, address, preKeyBundle: PreKeyBundle) => {
    const sessionBuilder = new SessionBuilder(store, address);
    await sessionBuilder.processPreKey(preKeyBundle);
};

Message Encryption & Decryption:

import { SessionCipher } from '@signalapp/libsignal-client';

const encryptMessage = async (store, address, message) => {
    const sessionCipher = new SessionCipher(store, address);
    const ciphertext = await sessionCipher.encrypt(message);
    return ciphertext;
};

const decryptMessage = async (store, address, ciphertext) => {
    const sessionCipher = new SessionCipher(store, address);
    const plaintext = await sessionCipher.decryptPreKeyWhisperMessage(ciphertext.body, 'binary');
    return plaintext;
};

Profile Content Encryption

  • Profile Content Protection: Each user's profile content (photos, videos, text) is encrypted with a unique symmetric key (AES).
  • The symmetric key is then encrypted using the recipient's public key (ECC).

Profile Encryption in TypeScript:

import { randomBytes, createCipheriv } from 'crypto';

// Generate AES key for content encryption
const generateSenderKey = () => {
    return randomBytes(32); // 256-bit AES key
};

// Encrypt content using the sender's key
const encryptContent = (content: Buffer, senderKey: Buffer) => {
    const iv = randomBytes(16); // Random initialization vector (IV) for AES
    const cipher = createCipheriv('aes-256-cbc', senderKey, iv);
    const encryptedContent = Buffer.concat([cipher.update(content), cipher.final()]);
    return { encryptedContent, iv };
};

// Example content to encrypt
const videoContent = Buffer.from('Example video content');

// Generate the key and encrypt the content
const senderKey = generateSenderKey();
const { encryptedContent, iv } = encryptContent(videoContent, senderKey);

Encrypting the Sender Key with Session Keys:

import { SessionCipher } from '@signalapp/libsignal-client';

// Encrypt sender key using session keys
const encryptSenderKey = async (store, address, senderKey) => {
    const sessionCipher = new SessionCipher(store, address);
    const encryptedSenderKey = await sessionCipher.encrypt(senderKey);
    return encryptedSenderKey;
};

// Example usage for encrypting sender keys for multiple recipients
const encryptedSenderKeyForRecipient1 = await encryptSenderKey(store, recipient1Address, senderKey);
const encryptedSenderKeyForRecipient2 = await encryptSenderKey(store, recipient2Address, senderKey);

// Store the encrypted content and keys on the server
await uploadEncryptedContentToServer({
    encryptedContent,
    iv,
    encryptedKeys: {
        recipient1: encryptedSenderKeyForRecipient1,
        recipient2: encryptedSenderKeyForRecipient2,
    },
});

Content Analysis and Moderation

Content Analysis

We use multi-label classification for tagging content, leveraging models like TensorFlow Lite and PyTorch Mobile.

  • Text, Images, Videos: The system supports analyzing text, multiple images, and video posts.
  • Pre-trained models are fine-tuned for optimal performance across mobile and web platforms.

Social Networking Algorithm

We are implementing a social networking algorithm to enhance user interaction and content recommendation.


Messaging (End-to-End Encrypted)

Messaging on Connect is fully end-to-end encrypted using the Signal Protocol. This ensures private and secure communication between users.


For more details and further technical documentation, please refer to connect_documentation.md.


Connect LLC © 2024

About

Main Source File For Connect Web page

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages