Skip to content
Vivek8749Public

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Revo

Revo is a community platform that mixes Reddit-style communities (posts, votes, threaded comments) with Telegram-style messaging (real-time chats, groups, broadcast channels and bots).

  • Backend: Node.js, Express 5, TypeScript, MongoDB (Mongoose), Socket.IO, Redis
  • Frontend: React 19, Vite, Tailwind CSS v4, Socket.IO client

Features

Messaging (Telegram-style)

Feature Notes
Direct messages, groups, broadcast channels Channels: only admins post, members read
Saved Messages A personal cloud chat with yourself
Replies, forwarding, editing (48h), delete for me / for everyone Forwarded messages keep "Forwarded from …"
Emoji reactions One reaction per user, like Telegram
Pinned messages Banner at the top of the chat, cycles through pins
Read receipts ✓ sent / ✓✓ read, live
Typing indicators, online status, last seen "Last seen" can be hidden in privacy settings
Polls Anonymous or public, single or multiple choice, close a poll
File, image, video and audio attachments Upload with progress; paste images from the clipboard
Scheduled messages and "send without sound" Scheduler delivers on time, even with several instances
@mentions and rich text **bold**, __italic__, ~~strike~~, `code`, code blocks, links
Unread counters, chat folders, pin / mute / archive / delete chat Folders: All, Unread, Personal, Groups, Channels, Archived
Group admin tools Promote/demote admins, kick, permissions, slow mode, invite links (/join/:code)
Message search In one chat or across all chats
Block users Blocked users can't DM you
Desktop notifications When the tab is in the background; respects muted chats

Bots

  • @RevoBot is a built-in bot that works in every chat: /help, /dice, /flip, /roll 100, /poll Question | A | B, /remind 10m Stretch!
  • Create your own bots on the /bots page (like BotFather): set the name, …bot username, commands and webhook, and get a token.
  • Telegram-like Bot API at /api/bot/<token>/<method>: getMe, getUpdates, sendMessage, sendPoll, editMessageText, deleteMessage, setWebhook, deleteWebhook, setMyCommands, getMyCommands.
  • Privacy mode: in groups, a bot only receives /commands, @mentions of itself and replies to its own messages. In private chats it receives everything.
  • Command autocomplete: typing / in the chat box shows the commands available in that chat.

Communities (Reddit-style)

  • Communities with rules, moderators, public or private visibility, and a linked group chat.
  • Text, link and image posts.
  • Up/down votes; the feed sorts by Hot (Reddit's ranking), New or Top (hour, day, week, month, year, all time).
  • Home feed scope: "All" or only the communities you've joined.
  • Threaded comments with voting, editing, soft delete and sorting (Best, Top, New, Old).
  • Saved posts, profiles with karma, pinned posts.
  • Sharing a post into a chat shows it as a rich card.
  • Real-time notifications: mentions, replies, comments on your posts, replies to your comments, and being added to groups.

How Redis is used

Redis is optional. Without REDIS_URL, every feature falls back to an in-memory implementation, which only works for a single backend instance.

Use Keys Why
User cache for auth user:<id> (5 min) Avoids a MongoDB lookup on every request and socket handshake
Chat settings cache chatsettings:<id> Pinned, muted and archived chats for the chat list
Unread counters unread:<userId> hash O(1) badges. Rebuilt from MongoDB if missing, so counts are never wrong
Presence presence:online, presence:sockets:<id> Online status shared across instances and tabs
Feed cache feed:v<n>:… (20 s) Hot/new/top pages. New posts invalidate by bumping the version
Community list cache channels:public Explore page
Rate limiting ratelimit:* API, login, messages, uploads and Bot API
Slow mode slowmode:<room>:<user> SET NX EX per member
Bot updates queue bot:updates:<botId> sorted set For getUpdates long polling
Socket.IO adapter pub/sub Broadcasts reach users connected to any instance

Getting started

With Docker (recommended)

docker compose up --build

Without Docker

Requirements: Node 20+, MongoDB, and optionally Redis.

# Backend
cd backend
cp .env.example .env   # then edit secrets
npm install
npm run dev            # http://localhost:8000

# Frontend (in another terminal)
cd frontend
npm install
npm run dev            # http://localhost:5173

The backend creates the @RevoBot account automatically on first start.

Environment variables (backend)

See backend/.env.example. The required ones are MONGODB_URI, JWT_SECRET and JWT_REFRESH_SECRET. REDIS_URL is strongly recommended in production.

When you run several backend instances, set PRESENCE_RESET_ON_BOOT=false and put them behind a load balancer with sticky sessions (needed by Socket.IO's polling transport).


Architecture

backend/src
├── config/redis.ts          Redis client (optional, auto-fallback)
├── controllers/             HTTP handlers (thin)
├── services/                Business logic shared by REST and sockets
│   ├── message.service.ts   send/edit/delete/react/pin/poll/forward/read/schedule
│   ├── room.service.ts      chat list, room details, per-user chat settings
│   ├── bot.service.ts       bot accounts, tokens, update queue, webhooks
│   ├── botCommands.service.ts  @RevoBot slash commands
│   ├── cache / presence / unread / notification / vote / scheduler
├── socket/                  Socket.IO server + emitter helpers
├── models/                  Mongoose models
└── routes/

Every chat action exists both as a Socket.IO event with an acknowledgement (used by the web app) and as a REST endpoint (useful for mobile clients and bots). Both call the same service functions.

Socket.IO events

Client → server events take an ack callback and reply { ok, data } | { ok: false, error }:

room:list, room:open, room:subscribe, message:send, message:history, message:edit, message:delete, message:react, message:pin, message:forward, message:read, poll:vote, poll:close, presence:query, typing (no ack).

Server → client events:

message:new, message:edited, message:deleted, message:reaction, message:pinned, message:scheduled, poll:updated, messages:read, typing, presence:update, room:added, room:removed, room:updated, chat:settings, notification:new.

REST API overview

Area Endpoints
Auth POST /api/auth/{signup,login,logout,logout-all,logout-device,refresh}, GET /api/auth/{me,sessions}
Users GET /api/users/search, GET /api/users/u/:username, PATCH /api/users/me, POST/DELETE /api/users/:id/block
Rooms GET/POST /api/rooms, GET /api/rooms/saved, GET/PATCH/DELETE /api/rooms/:id, participants, admins, invite-link, GET/POST /api/rooms/invite/:code[/join], GET /api/rooms/:id/commands
Messages GET/POST /api/messages/room/:roomId, PATCH/DELETE /api/messages/:id, /react, /pin, /vote, /close-poll, POST /api/messages/forward, GET /api/messages/search, scheduled messages
Chat settings POST /api/dm-channel/:roomId/{pin,unpin,mute,unmute,archive,unarchive}, DELETE /api/dm-channel/:roomId
Communities GET /api/channels/{public,search,my-channels}, POST /api/channels, GET/PUT /api/channels/:slug, join, leave, moderators
Posts GET /api/posts?sort=&t=&scope=&channel=&author=&page=, POST /api/posts, GET/PATCH/DELETE /api/posts/:id, /vote, /save, /pin, /comments
Comments PATCH/DELETE /api/comments/:id, POST /api/comments/:id/vote
Notifications GET /api/notifications, /unread-count, POST /read-all, POST /:id/read
Uploads POST /api/uploads (multipart file)
Bots GET/POST /api/bots, PATCH/DELETE /api/bots/:id, POST /api/bots/:id/token, Bot API at /api/bot/<token>/<method>

Minimal bot example

TOKEN="<token from the /bots page>"
API="http://localhost:8000/api/bot/$TOKEN"

# Poll for updates (pass offset = last update_id + 1 to confirm them)
curl "$API/getUpdates?offset=0"

# Reply
curl -X POST "$API/sendMessage" -H "Content-Type: application/json" \
     -d '{"room_id":"<room id>","text":"Hi! 👋","reply_to_message_id":"<message id>"}'

Security notes

  • Refresh tokens are stored hashed, rotated on every use, and reuse is detected. Access tokens last 15 minutes; the socket refreshes automatically.
  • Room membership is checked for every chat read and write.
  • User search input is regex-escaped.
  • Uploads get random file names. HTML, SVG and JS uploads are rejected, and files are served with nosniff, a sandbox CSP, and Content-Disposition: attachment for anything that isn't media.
  • Rate limits apply per IP and per user, backed by Redis.

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages