百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

iChat

> 编程语言
开源

iChat 是一款实时聊天应用程序,具有身份验证、用户配置文件(包括配置图片上传)和通过 WebSockets 进行消息传递等功能。

382 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

iChat 是一款实时聊天应用程序,具有身份验证、用户配置文件(包括配置图片上传)和通过 WebSockets 进行消息传递等功能。

iChat

Real-time chat application with authentication, user profiles (including profile picture upload), and messaging over WebSockets.

Features

  • Authentication (register, login, logout) using JWT in httpOnly cookies
  • Auth session check endpoint (/auth/check)
  • Profile picture upload (base64 upload -> Cloudinary)
  • Real-time messaging with Socket.IO
  • Contacts list and chat history
  • Basic API protection/rate limiting via Arcjet middleware

Tech Stack

Frontend

  • React (Vite)
  • Zustand (state management)
  • TailwindCSS + daisyUI
  • Axios
  • Socket.IO Client

Backend

  • Node.js + Express
  • MongoDB + Mongoose
  • Socket.IO
  • JWT (httpOnly cookie)
  • Cloudinary (media uploads)
  • Arcjet (rate limiting / protection)

Project Structure

  • frontend/ — React app
  • backend/ — Express + Socket.IO server

Prerequisites

  • Node.js (LTS recommended)
  • MongoDB connection string (MongoDB Atlas or local)
  • Cloudinary account (for profile pictures / image messages)

Setup

1) Clone and install dependencies

Backend

bash
cd backend
npm install

Frontend

bash
cd frontend
npm install

2) Environment variables

Create .env files in both backend/ and frontend/.

backend/.env

The backend uses these variables (based on the code in backend/server.js, backend/config/db.js, backend/utils/generateToken.js, and backend/config/cloudinary.js):

env
# Server
PORT=3000
NODE_ENV=development
CLIENT_URL=http://localhost:5173

# Database
MONGODB_URI=mongodb+srv://:@

# Auth
JWT_SECRET=your_super_secret_jwt_key

# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# Email (if configured)
RESEND_API_KEY=your_resend_api_key

Notes:

  • MONGODB_URI is used like ${MONGODB_URI}/iChat in backend/config/db.js.
  • Cookies are set as httpOnly and will use:
    • secure: true only in production
    • sameSite: "none" in production, "strict" in development

frontend/.env

Frontend uses VITE_API_URL for non-development builds (see frontend/src/lib/axios.js).

env
VITE_API_URL=http://localhost:3000/

In development mode, the frontend automatically uses http://localhost:3000/.

3) Run the app (development)

Start backend

bash
cd backend
npm run dev

Backend starts on http://localhost:3000 by default.

Start frontend

bash
cd frontend
npm run dev

Frontend starts on http://localhost:5173 by default.

API Routes (Backend)

Base URL: http://localhost:3000

Auth (/auth)

  • POST /auth/register
  • POST /auth/login
  • POST /auth/logout
  • GET /auth/check (requires auth cookie)
  • PUT /auth/update-profile (requires auth cookie)

Messages (/messages)

  • GET /messages/contacts (requires auth cookie)
  • GET /messages/chats (requires auth cookie)
  • GET /messages/:id (requires auth cookie)
  • POST /messages/send/:id (requires auth cookie)

Real-time (Socket.IO)

  • Socket server is created in backend/utils/socket.js.
  • Socket connections are authenticated using the jwt cookie (backend/middlewares/socketAuth.js).

Production Notes

  • Configure CLIENT_URL to your deployed frontend URL.
  • Ensure cookies work across domains:
    • backend must enable CORS with credentials: true
    • cookie sameSite/secure must match your deployment (HTTPS required for sameSite=none).

Scripts

Backend (backend/package.json)

  • npm run dev — start server with nodemon
  • npm start — start server

Frontend (frontend/package.json)

  • npm run dev — start Vite dev server
  • npm run build — production build
  • npm run preview — preview production build
  • npm run lint — run ESLint

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言