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.
- Overview
- Architecture
- Tech Stack
- Features
- Project Structure
- Getting Started
- API Documentation
- Authentication Flow
- Roles & Permissions
- Contributing
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.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 | 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) |
| 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 |
| 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 |
- π¬ 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
- π 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
- π‘ Admin Panel β manage users (view, ban/unban), groups, channels
- π SuperAdmin Panel β create/manage admins
- π Role-based Access β
user,admin,superAdminroles enforced on both frontend and backend
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
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 |
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 installEach 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.examplefor all available options.
# 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)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 startExpected output for each service:
IAM service listening on port 3001
Database connected successfully.
RabbitMQ token validation listener ready.
RabbitMQ user data listener ready.
# Terminal 4
cd Client
npm run devOpen http://localhost:5173 in your browser.
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.
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()
);- Log in at
http://localhost:5173/superAdmin/logIn - Navigate to the Add Admin tab
- Fill in the admin details
- Open
http://localhost:5173 - Enter your email β receive a 6-digit OTP code
- Enter the code β complete your profile
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.
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)
| Action | User | Admin | SuperAdmin |
|---|---|---|---|
| Send messages | β | β | β |
| Create groups/channels | β | β | β |
| View all users | β | β | β |
| Ban/unban users | β | β | β |
| View all groups/channels | β | β | β |
| Create admins | β | β | β |
| Manage admins | β | β | β |
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "feat: add your feature" - Push to the branch:
git push origin feature/your-feature - Open a Pull Request
Please make sure:
.envfiles are never committed*.pemfiles are never committed (already in.gitignore)JWTSecretis always set via environment variable, never hardcoded
Made with β€οΈ using Node.js, React, and MongoDB