A simple, professional-grade chat application supporting one-on-one conversations between two users. Built for clarity, maintainability, and ease of testing.
This project is a Mini Chat Application that enables chat between two users. It is designed for demonstration and learning purposes, focusing on clean architecture and modern web technologies.
| Layer | Technology |
|---|---|
| Frontend | Next.js, Tailwind CSS |
| Backend | Node.js, Express |
| Language | TypeScript |
| Database | MongoDB |
| Testing | Jest |
- Node.js (v18+ recommended)
- npm
- MongoDB Atlas
git clone <repo-url>
cd ConversationsMONGODB_URI=your_mongodb_uri
PORT=4000
NEXT_PUBLIC_API_BASE=http://localhost:4000
Open two terminals:
cd backend
npm install
npm run devcd frontend
npm install
npm run dev- No real authentication.
- Simulate login by sending an
x-user-idheader with every API request. - Seed Users:
- User 1:
{ id: 1, name: "Alice" } - User 2:
{ id: 2, name: "Bob" }User 2:{ id: 3, name: "Carol" }
- User 1:
- To test chat between users, open two browser windows and set different
x-user-idvalues (e.g., via browser devtools or by modifying the frontend logic).
- User-to-user chat (1:1)
- Pagination for conversations and messages
- Unit tests for validation
- Clean RESTful API design
- Simple authentication simulation via header
| Method | Endpoint | Description | Auth (x-user-id) |
|---|---|---|---|
| GET | /users/me |
Get current user info | Required |
| GET | /conversations |
List conversations (paginated) | Required |
| POST | /conversations |
Start new conversation | Required |
| GET | /conversations/:id/messages |
List messages in conversation | Required |
| POST | /messages |
Send message to conversation | Required |
cd backend
npm run testMONGODB_URI= your-url
PORT=4000
NEXT_PUBLIC_API_BASE=http://localhost:4000