The Discussions Service is a microservice in the DevOhh platform that manages community discussions and comments.
It provides:
- Discussion CRUD operations with topic categorization
- Commenting system with pagination
- Role-based access (Admin/User)
- Secure authentication with JWT
- Input validation with Zod
- Full test coverage with Jest & Testcontainers
This service powers the social and collaborative features of the platform.
- 📝 Discussions – Create, update, delete, and retrieve discussions
- 💬 Comments – Add and fetch comments with pagination
- 🏷 Topics – Discussions organized into Career, Compensation, Feedback, Interview
- 🔒 Authentication & Roles – JWT authentication, Admin vs. User permissions
- ⚡ Pagination – Efficient pagination for large discussions & comments
- 🛡 Validation – Input validation with Zod schemas
- 🗄 Database – PostgreSQL + Prisma ORM for persistence
- 🧪 Testing – Integration tests with Jest + Testcontainers
- Backend: Node.js, TypeScript, Express
- Database: PostgreSQL, Prisma ORM
- Auth: JWT (Access & Refresh tokens, HTTP-only cookies)
- Validation: Zod
- Testing: Jest, Supertest, Testcontainers Postman
- Node.js (v18+)
- Docker
- PostgreSQL
- RabbitMQ
- pnpm package manager
- Docker (for testing with Testcontainers)
note:- You can use docker-compose for external services (PostgreSQL, RabbitMQ, Redis).
-
Clone the repository
git clone https://github.com/mdarkanurl/DeshCode.git
-
And navigate to
app/discussionscd app/discussions -
Install necessary dependency
pnpm install --frozen-lockfile
-
Add environment variable create a
.envfile and add the variable. Use.env.examplefor guidance. -
Setup database
pnpm prisma:generate npx prisma migrate deploy
-
Run the app
pnpm dev # development pnpm build && pnpm start # production
POST /api/v1/discussions # Create discussion (Authenticated user)
GET /api/v1/discussions # Get all discussions (filters: topic, pagination)
GET /api/v1/discussions/:id # Get specific discussion
PUT /api/v1/discussions/:id # Update discussion (Owner only)
DELETE /api/v1/discussions/:id # Delete discussion (Owner only)POST /api/v1/comments/:discussionId # Create comment (Authenticated user)
GET /api/v1/comments?discussionId=ID # Get comments with paginationGET /api/health # Service health check
GET / # Service infoThis service includes comprehensive test coverage with Jest & Testcontainers.
note:- Auth service must be up and running in order to test discussions service.
pnpm test- ✅ Application tests (health, root, DB)
- ✅ Discussion management (CRUD, validation, auth)
- ✅ Comments (CRUD, pagination, validation)
- ✅ Authentication & authorization (JWT, roles)
- ✅ Error handling (invalid input, permissions)
- Start Postgres container
- Login as user/admin
- Create test discussions
- Add comments
- Validate permissions & responses
- Cleanup
The Discussions Service follows clean architecture with layered design:
- API Layer – Express routes, middleware (auth, roles)
- Business Layer – Services for discussions & comments
- Data Layer – PostgreSQL + Prisma ORM
- Validation – Zod schemas for request validation
- Security – JWT tokens, HTTP-only cookies, RBAC
- Scalability – Pagination & indexing for large datasets
Contributions, issues, and feature requests are welcome! If you want to contribute to DeshCode, please follow the guidelines outlined in the contributing.md file.
MIT License