Skip to content

Uranus313/Iris_Messenger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

133 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌸 Iris Messenger

A full-stack, real-time messaging platform built with a Node.js microservices backend and a React frontend.

Inspired by Telegram β€” supports direct messages, groups, channels, file sharing, and role-based administration.

Node.js React TypeScript TailwindCSS PostgreSQL MongoDB RabbitMQ


πŸ“‹ Table of Contents


πŸ” Overview

Iris Messenger is a microservices-based real-time messaging application that mirrors the core experience of Telegram. It is built from scratch with a focus on clean architecture, security, and scalability.

Real-time communication is powered by Socket.io, inter-service communication uses RabbitMQ for token validation and user data exchange, and file uploads are handled internally via gRPC.


πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        React Client                         β”‚
β”‚              Vite Β· TypeScript Β· TailwindCSS                β”‚
β”‚              React Query Β· Socket.io-client                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTPS        β”‚ HTTPS        β”‚ HTTPS / WSS
         β–Ό              β–Ό              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  IAM :3001 β”‚  β”‚ Core :3003 β”‚  β”‚ Media:3002 β”‚
β”‚  (Auth &   β”‚  β”‚(Messaging, β”‚  β”‚  (Files,   β”‚
β”‚   Users)   β”‚  β”‚ Groups,    β”‚  β”‚  GridFS)   β”‚
β”‚            β”‚  β”‚ Channels,  β”‚  β”‚            β”‚
β”‚ PostgreSQL β”‚  β”‚  Socket.io)β”‚  β”‚  MongoDB   β”‚
β”‚ + Sequelizeβ”‚  β”‚  MongoDB   β”‚  β”‚  GridFS    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚                β”‚                β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   RabbitMQ     β”‚
              β”‚ Token Validationβ”‚
              β”‚  User Data      β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  gRPC :8087    β”‚
              β”‚  File Uploads  β”‚
              β”‚ (IAM β†’ Media)  β”‚
              β”‚ (Core β†’ Media) β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Service Responsibilities

Service Port Database Responsibility
IAM 3001 PostgreSQL Authentication (OTP), user/admin/superAdmin management
Core 3003 MongoDB Messaging, groups, channels, directs, contacts, Socket.io
Media 3002 MongoDB (GridFS) File upload/download via REST and gRPC
Gateway 3000 β€” Reverse proxy (WIP)

πŸ›  Tech Stack

Backend

Layer Technology
Runtime Node.js 18+ (ES Modules)
Framework Express.js
Auth DB PostgreSQL + Sequelize ORM
Messaging DB MongoDB + Mongoose
File Storage MongoDB GridFS
Message Broker RabbitMQ (amqplib)
File Transfer (internal) gRPC
Real-time Socket.io
Auth JWT (httpOnly cookies)
Password Hashing bcrypt
Validation Joi
Logging Winston + Morgan

Frontend

Layer Technology
Framework React 18 + Vite
Language TypeScript 5.6
Styling TailwindCSS 3 + DaisyUI 4 (32 themes)
State / Data React Query (TanStack Query v5)
Forms React Hook Form
Routing React Router DOM v7
Real-time Socket.io-client

✨ Features

Messaging

  • πŸ’¬ Direct Messages β€” one-to-one private conversations
  • πŸ‘₯ Groups β€” multi-user chats with member roles (owner, admin, member)
  • πŸ“’ Channels β€” broadcast-only channels (only owner can send)
  • πŸ“Ž File Attachments β€” image upload via gRPC to Media service
  • ⚑ Real-time β€” Socket.io for instant message delivery

User

  • πŸ” OTP Authentication β€” email-based verification, no passwords for users
  • πŸ‘€ Profile Management β€” name, bio, username, phone, profile picture
  • πŸ” User Search β€” search by email
  • πŸ‘₯ Contacts β€” add/remove contacts
  • 🚫 Block/Unblock β€” block other users from messaging you
  • 🎨 32 Themes β€” full DaisyUI theme support, persisted to localStorage

Administration

  • πŸ›‘ Admin Panel β€” manage users (view, ban/unban), groups, channels
  • πŸ‘‘ SuperAdmin Panel β€” create/manage admins
  • πŸ”‘ Role-based Access β€” user, admin, superAdmin roles enforced on both frontend and backend

πŸ“ Project Structure

Iris_Messenger/
β”‚
β”œβ”€β”€ Services/
β”‚   β”œβ”€β”€ IAM/                        # Identity & Access Management
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ application/        # Business logic (controllers)
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/             # Sequelize models
β”‚   β”‚   β”‚   β”œβ”€β”€ infrastructure/     # DB queries
β”‚   β”‚   β”‚   β”œβ”€β”€ presentation/       # Express routes
β”‚   β”‚   β”‚   β”œβ”€β”€ contracts/          # Joi validation schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   β”‚   └── secret/.env     # ← environment variables
β”‚   β”‚   β”‚   └── DB/                 # PostgreSQL connection
β”‚   β”‚   β”œβ”€β”€ index.js                # Entry point
β”‚   β”‚   └── .env.example
β”‚   β”‚
β”‚   β”œβ”€β”€ Core/                       # Messaging Service
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ Application/        # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ Domain/             # Mongoose models
β”‚   β”‚   β”‚   β”œβ”€β”€ Infrastructure/     # DB queries
β”‚   β”‚   β”‚   β”œβ”€β”€ Presentation/       # Routes + Socket.io
β”‚   β”‚   β”‚   β”œβ”€β”€ contracts/          # Joi validation
β”‚   β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   β”‚   └── secret/.env     # ← environment variables
β”‚   β”‚   β”‚   └── DB/                 # MongoDB connection
β”‚   β”‚   └── .env.example
β”‚   β”‚
β”‚   β”œβ”€β”€ Media/                      # File Storage Service
β”‚   β”‚   β”œβ”€β”€ Application/            # upload/download logic + gRPC server
β”‚   β”‚   β”œβ”€β”€ Presentation/           # REST routes
β”‚   β”‚   β”œβ”€β”€ DB/                     # MongoDB + GridFS
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── secret/.env         # ← environment variables
β”‚   β”‚   β”œβ”€β”€ index.js                # Entry point
β”‚   β”‚   └── .env.example
β”‚   β”‚
β”‚   β”œβ”€β”€ gateWay/                    # Reverse Proxy (WIP)
β”‚   β”œβ”€β”€ cert.pem                    # SSL certificate (self-signed, dev only)
β”‚   └── key.pem                     # SSL private key  (NEVER commit to prod)
β”‚
└── Client/                         # React Frontend
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ admin/                  # Admin & SuperAdmin panels + login
    β”‚   β”œβ”€β”€ user/
    β”‚   β”‚   β”œβ”€β”€ login/              # OTP login flow (3 stages)
    β”‚   β”‚   └── mainPage/           # Main chat UI
    β”‚   β”‚       β”œβ”€β”€ chat/           # DirectPage, GroupPage, ChannelPage
    β”‚   β”‚       β”œβ”€β”€ chatList/       # Sidebar chat list
    β”‚   β”‚       └── menu/           # Settings, Contacts, Add Group/Channel
    β”‚   β”œβ”€β”€ hooks/                  # React Query data fetching hooks
    β”‚   β”œβ”€β”€ layouts/                # Auth guards (UserHomeLayout, etc.)
    β”‚   β”œβ”€β”€ contexts/               # UserContext
    β”‚   β”œβ”€β”€ interfaces/             # TypeScript interfaces
    β”‚   └── consts/                 # API base URLs
    β”œβ”€β”€ tailwind.config.js
    └── package.json

πŸš€ Getting Started

Prerequisites

Make sure the following are installed and running:

Requirement Install Guide
Node.js v18+ nodejs.org
PostgreSQL 14+ postgresql.org
MongoDB 6+ mongodb.com
RabbitMQ 3.12+ rabbitmq.com

Installation

Clone the repository and install dependencies for all services:

git clone https://github.com/your-username/Iris_Messenger.git
cd Iris_Messenger
# IAM Service
cd Services/IAM && npm install

# Core Service
cd ../Core && npm install

# Media Service
cd ../Media && npm install

# Frontend
cd ../../Client && npm install

Configuration

Each service needs a .env file. Starter files have been created at:

Service Path
IAM Services/IAM/src/config/secret/.env
Core Services/Core/src/config/secret/.env
Media Services/Media/config/secret/.env

Minimum required changes:

# 1. Set your PostgreSQL password in IAM .env
DB_PASSWORD=your_postgres_password

# 2. Set a strong JWT secret β€” MUST be identical in all 3 services
JWTSecret=a_very_long_random_string_at_least_32_characters

# 3. Set your frontend origin in all 3 services
ALLOWED_ORIGINS=http://localhost:5173

πŸ“ See each service's .env.example for all available options.


Running the App

1. Start Infrastructure

# PostgreSQL β€” usually runs as a system service
# Verify it's running:
pg_isready

# MongoDB
mongod --dbpath "C:/data/db"       # Windows
# mongod --dbpath /data/db         # Linux/Mac

# RabbitMQ
rabbitmq-server                    # or start via Windows Services
# Management UI: http://localhost:15672  (user: guest, pass: guest)

2. Start Backend Services

Open 3 separate terminals:

# Terminal 1 β€” IAM (port 3001)
cd Services/IAM
npm start

# Terminal 2 β€” Core (port 3003)
cd Services/Core
npm start

# Terminal 3 β€” Media (port 3002)
cd Services/Media
npm start

Expected output for each service:

IAM service listening on port 3001
Database connected successfully.
RabbitMQ token validation listener ready.
RabbitMQ user data listener ready.

3. Start Frontend

# Terminal 4
cd Client
npm run dev

Open http://localhost:5173 in your browser.


⚠️ Self-Signed Certificate Setup (Important!)

The backend services run on HTTPS with self-signed certificates. Browsers will block API requests until you manually accept each certificate.

Visit each URL once and click "Advanced β†’ Accept Risk":

Service URL
IAM https://localhost:3001
Core https://localhost:3003
Media https://localhost:3002

After accepting all three, the frontend will work correctly.


First-Time Database Setup

Create a SuperAdmin

The SuperAdmin account must be seeded directly. Connect to PostgreSQL and insert a bcrypt-hashed password:

-- Connect to your database
\c Iris

-- Generate a bcrypt hash for your password first (e.g., using Node.js):
-- node -e "require('bcrypt').hash('yourpassword', 10).then(console.log)"

INSERT INTO "SuperAdmins" (email, password, "createdAt", "updatedAt")
VALUES (
  'superadmin@iris.com',
  '$2b$10$yourGeneratedHashHere',
  NOW(),
  NOW()
);

Create an Admin

  1. Log in at http://localhost:5173/superAdmin/logIn
  2. Navigate to the Add Admin tab
  3. Fill in the admin details

Register as a User

  1. Open http://localhost:5173
  2. Enter your email β†’ receive a 6-digit OTP code
  3. Enter the code β†’ complete your profile

πŸ“– API Documentation

After starting the Core service, the combined Swagger UI is available at:

https://localhost:3003/swagger

This includes documentation for both IAM and Core service endpoints.


πŸ” Authentication Flow

User enters email
       β”‚
       β–Ό
POST /users/createOTP  ──► Email sent with 6-digit code
       β”‚
       β–Ό
POST /users/checkOTP
       β”‚
       β”œβ”€ Existing user ──► JWT issued β†’ httpOnly cookie β†’ Navigate to app
       β”‚
       └─ New user ──► "incompleteUser" JWT β†’ Sign-up form
                              β”‚
                              β–Ό
                       POST /users/signUp
                              β”‚
                              β–Ό
                       JWT issued β†’ httpOnly cookie β†’ Navigate to app
  • Tokens are stored in httpOnly cookies (not localStorage) β€” protected against XSS
  • Tokens expire after 30 days
  • Admin/SuperAdmin use email + password (bcrypt-hashed)

πŸ‘₯ Roles & Permissions

Action User Admin SuperAdmin
Send messages βœ… βœ… βœ…
Create groups/channels βœ… βœ… βœ…
View all users ❌ βœ… βœ…
Ban/unban users ❌ βœ… βœ…
View all groups/channels ❌ βœ… βœ…
Create admins ❌ ❌ βœ…
Manage admins ❌ ❌ βœ…

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m "feat: add your feature"
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

Please make sure:

  • .env files are never committed
  • *.pem files are never committed (already in .gitignore)
  • JWTSecret is always set via environment variable, never hardcoded

Made with ❀️ using Node.js, React, and MongoDB

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages