A controlled business-to-customer chat platform where access is gated by admin approval. All conversations are one-to-one between customers and the business.
- User Registration & Access Control - Admin approval workflow with user statuses (Pending, Approved, Rejected, Suspended)
- Real-time Messaging - Socket.io powered 1:1 chats with typing indicators
- Media Permission System - Admin-controlled per-user media sharing
- Announcements/Broadcasts - Send updates to all or selected users
- Business Reports - Transaction issue reporting system
- Admin Dashboard - User management, message monitoring, report handling
- Runtime: Node.js v18+
- Framework: Express.js v5
- Real-time: Socket.io v4
- Database: PostgreSQL (via Xata or local)
- ORM: Prisma v7 (with driver adapters)
- Authentication: JWT (jose) + Argon2
- Validation: Zod
- Logging: Pino
- Node.js v18 or higher
- PostgreSQL database (local or cloud like Xata)
- Redis (optional, for Socket.io scaling)
-
Clone the repository
git clone https://github.com/benkaesy820/doedev360.git cd doedev360 -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envand update:DATABASE_URL="postgresql://user:password@host:port/database?sslmode=require" JWT_SECRET="your-secure-jwt-secret" REFRESH_TOKEN_SECRET="your-secure-refresh-secret" -
Generate Prisma client
npx prisma generate
-
Push database schema
npx prisma db push
-
Seed test users (optional)
npm run db:seed
npm run devnpm startThe server will start on http://localhost:5000
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login |
| POST | /api/auth/refresh-token |
Refresh access token |
| POST | /api/auth/logout |
Logout |
| GET | /api/auth/me |
Get current user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/users |
List all users |
| GET | /api/users/:id |
Get user details |
| PATCH | /api/users/:id/status |
Approve/reject/suspend user |
| PATCH | /api/users/:id/media-permission |
Grant/revoke media permission |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/conversations/my-conversation |
Get user's conversation |
| GET | /api/conversations |
List all conversations (Admin) |
| GET | /api/conversations/:id/messages |
Get messages |
| POST | /api/conversations/:id/messages |
Send message |
| PATCH | /api/conversations/:id/read |
Mark as read |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/announcements |
List announcements |
| GET | /api/announcements/unread-count |
Get unread count |
| POST | /api/announcements |
Create announcement (Admin) |
| POST | /api/announcements/:id/read |
Mark as read |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/reports/my-reports |
Get user's reports |
| GET | /api/reports |
List all reports (Admin) |
| POST | /api/reports |
Submit report |
| PATCH | /api/reports/:id/status |
Update status (Admin) |
authenticate- Send JWT tokentyping_start- User started typingtyping_stop- User stopped typingjoin_conversation- Join conversation roomleave_conversation- Leave conversation room
authenticated- Authentication successfulauth_error- Authentication failedreceive_message- New messagetyping_start/typing_stop- Typing indicators
After running npm run db:seed:
| Role | Password | |
|---|---|---|
| Admin | admin@evmessages.com | admin123 |
| User | user@example.com | user123 |
├── prisma/
│ ├── schema.prisma # Database models
│ └── seed.js # Seed script
├── src/
│ ├── config/ # App & database config
│ ├── middleware/ # Auth & error handling
│ ├── routes/ # API endpoints
│ ├── sockets/ # Socket.io handlers
│ ├── utils/ # JWT, validators, logger
│ ├── app.js # Express app
│ └── server.js # Entry point
├── .env.example # Environment template
└── package.json
| Command | Description |
|---|---|
npm run dev |
Start development server with hot reload |
npm start |
Start production server |
npm run db:migrate |
Run database migrations |
npm run db:push |
Push schema to database |
npm run db:seed |
Seed test data |
npm run db:studio |
Open Prisma Studio |
Private - All rights reserved