DevNest is a scalable backend platform inspired by X (Twitter), built with Node.js, TypeScript, Express, Prisma, PostgreSQL, and Redis.
It follows a clean, layered architecture and focuses on building production-ready social platform features with performance, scalability, and maintainability in mind.
DevNest strictly follows this flow:
Routes β Controller β Service β Repository β Database
- β Clear separation of concerns
- β Easy to test and refactor
- β Business logic isolated from HTTP & DB layers
- β Scales cleanly as features grow
- Node.js
- TypeScript
- Express.js
- Prisma ORM
- PostgreSQL
- Redis (Caching & Queues)
- BullMQ (Background Jobs)
- Multer (File Uploads)
- Vite + React (Frontend)
- Tailwind CSS (Styling)
- JWT Authentication (Access & Refresh Tokens)
src/
βββ modules/ # Feature-based texture (Controller, Service, Routes)
βββ middlewares/ # Auth, Rate Limiting, Validation, Error Handling
βββ jobs/ # Background workers (Email, Notifications)
βββ lib/ # Core utilities (Prisma, Redis, Logger)
βββ types/ # Global type definitions
βββ app.ts # Express setup
βββ server.ts # Server entry point
frontend/ # React + Vite application
βββ src/
β βββ api/ # Axios client & API modules
β βββ components/ # Reusable UI components
β βββ context/ # React Context (Auth)
β βββ pages/ # Route pages
β βββ main.tsx # Frontend entry point
uploads/ # Static file storage (Images)
Each module follows:
module/
βββ module.routes.ts
βββ module.controller.ts
βββ module.service.ts
βββ module.repository.ts
βββ module.types.ts- JWT-based authentication
- Access & refresh token flow
- Secure route protection via middleware
- Authenticated user attached to
req.user
Redis is used as a shared caching layer across modules to improve performance and reduce database load.
- User profile reads
- Feed responses
- Posts & interactions
- Follow / block checks
- Frequently accessed relational data
- Read-through caching
- Cache invalidation on write/update/delete
- Fallback to database on cache miss
Request β Redis β Database (if cache miss) β Redis update β Response
- π Faster response times
- π Reduced database queries
- π Better scalability under load
- Register & login
- Profile management
- Follow / unfollow users
- Cached profile reads
- Create posts
- Fetch posts efficiently
- Cached post lists
- Like / unlike posts
- Prevent duplicate likes
- Cache-aware invalidation
- Comment on posts
- Delete own comments
-
Block users
-
Unblock users
-
View blocked users list
-
Blocking removes follow relationships
-
Blocked users cannot:
- follow
- like
- comment
- view feed content
- Feed based on follow relationships
- Block-aware feed filtering
- Redis-cached feed responses
- BullMQ + Redis based job queue
- Asynchronous email sending (Welcome emails)
- Notification generation (Likes, Follows)
- Rate Limiting: Redis-based sliding window limiter protected endpoints.
- JWT Auth: Secure access/refresh token rotation.
- Helmet & CORS: Enhanced security headers.
- Image uploads via Multer
- Static file serving for user avatars and post images
Key models:
UserPostFollowBlockedUserLikeComment
Designed with:
- Unique constraints
- Indexes for performance
- Cascade deletes
- Proper relational modeling
git clone https://github.com/johnvesslyalti/dev-nest.git
cd dev-nestnpm installCreate a .env file:
DATABASE_URL=postgresql://user:password@localhost:5432/devnest
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_jwt_secret
REFRESH_TOKEN_SECRET=your_refresh_secretnpx prisma generate
npx prisma migrate devredis-servernpm run devOpen a new terminal:
cd frontend
npm install
npm run devThe app will be available at http://localhost:5173.
- β No Prisma calls in controllers
- β No HTTP logic in services
- β No business logic in repositories
- β Repositories handle DB access
- β Services enforce business rules
- β Redis caching handled consistently per module
- WebSocket-based real-time updates (Socket.io)
- Retweets / reposts
- Hashtags & trending topics
- Direct messaging
- API documentation (Swagger / OpenAPI)
Johnvessly Alti Backend-focused Software Engineer Building scalable systems with clean architecture.
Pull requests are welcome. Please open an issue before making major changes.
MIT License