A robust, full-stack User Profile Management System built with a secure, scalable architecture. This project features a Next.js frontend with Shadcn/UI and an Express backend using Clean Architecture and InversifyJS for dependency injection.
Designed for production readiness, it includes JWT cookie-based authentication, RBAC (Role-Based Access Control), email notifications, and a serverless-ready deployment structure for Vercel.
- Secure Auth: JWT-based authentication using HTTP-only cookies (Access & Refresh tokens).
- Email Verification: New user registration requires OTP verification via email.
- RBAC: Role-Based Access Control protecting Admin routes (
adminMiddleware). - Security Headers: Integrated
helmetand CORS configuration for security. - Password Hashing:
bcryptjsfor secure password storage.
- Profile Operations: View, edit, and update user profiles.
- Avatar Management: Users can upload and update profile pictures (integrated with Cloudinary).
- Password Management: Change password and "Forgot Password" flows with secure email verification.
- Email System:
Nodemailerintegration for sending verification, password reset, and login alert emails. - In-App Notifications: Real-time accessible notifications stored in MongoDB (Capped Collections for efficiency).
- Audit Logs: Tracks critical system actions (e.g., user updates, logins).
- Login History: Records user login details including IP and device info.
- User Management: Admin interface to view, search, filter, and block/unblock users.
- Clean Architecture: Backend organized into Controllers, Services, and Repositories with Dependency Injection (InversifyJS).
- Type Safety: Full TypeScript support across both frontend and backend.
- Centralized Frontend Services: API calls abstracted into
authService,profileService, etc. - Modern UI: Built with
Next.js 15(App Router),Tailwind CSS, andShadcn/UIcomponents (Tabs, Cards, Forms).
| Dashboard | Profile |
|---|---|
![]() |
![]() |
| Audit Logs | Login |
|---|---|
![]() |
![]() |
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- State Management: Zustand
- Styling: Tailwind CSS, Shadcn/UI (Radix UI)
- Form Handling: React Hook Form + Zod validation
- API Client: Axios
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: MongoDB (Mongoose), using connection caching for Serverless.
- Cloud Storage: Cloudinary (for avatar uploads)
- DI Container: InversifyJS
- Email: Nodemailer
This is a monorepo setup containing both frontend and backend applications.
User-Profile/
├── apps/
│ ├── backend/ # Express Server
│ │ ├── src/
│ │ │ ├── config/ # Environment & Database config
│ │ │ ├── controllers/ # Request handlers
│ │ │ ├── validators/ # Zod schemas for input validation
│ │ │ ├── services/ # Business logic
│ │ │ ├── repositories/ # Data access layer
│ │ │ ├── models/ # Mongoose schemas
│ │ │ ├── middlewares/ # Auth & Error handling
│ │ │ ├── interfaces/ # Type definitions (SOLID)
│ │ │ └── app.ts # App setup
│ │ ├── api/ # Vercel Serverless Entry point
│ │ └── vercel.json # Deployment config
│ │
│ └── frontend/ # Next.js Client
│ ├── src/
│ │ ├── app/ # App Router pages
│ │ ├── components/ # Reusable UI components
│ │ ├── features/ # Feature-based modular components
│ │ ├── services/ # API service modules
│ │ ├── store/ # Zustand stores
│ │ └── lib/ # Utilities (Axios, etc.)
- Node.js (v18+)
- PNPM (Package Manager)
- MongoDB Instance (Local or Atlas)
# Install dependencies for root (if configured) or individual apps
cd apps/backend && pnpm install
cd ../../apps/frontend && pnpm installCreate .env files in both apps/backend and apps/frontend.
Backend (apps/backend/.env)
PORT=5000
NODE_ENV=development
MONGO_URI=mongodb://localhost:27017/user-profile
JWT_SECRET=your_super_secret_access_key
JWT_REFRESH_SECRET=your_super_secret_refresh_key
JWT_ACCESS_EXPIRY=15m
JWT_REFRESH_EXPIRY=7d
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=user@example.com
SMTP_PASS=password
ALLOWED_ORIGINS=http://localhost:3000
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secretFrontend (apps/frontend/.env)
NEXT_PUBLIC_BACKEND_URL=http://localhost:5000/apiBackend
cd apps/backend
pnpm dev
# Server runs on http://localhost:5000Frontend
cd apps/frontend
pnpm dev
# Client runs on http://localhost:3000The backend exposes a RESTful API. Key endpoints include:
- Auth:
POST /api/auth/register- Create accountPOST /api/auth/login- Sign in (Sets HttpOnly cookies)POST /api/auth/logout- Sign outPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/forgot-password- Request reset link
- Profile:
GET /api/profile- Get current user profilePUT /api/profile- Update profile details
- Admin (Protected):
GET /api/admin/users- List all usersPATCH /api/admin/users/:id/status- Block/Unblock user



