A production-ready, highly scalable authentication and authorization system. This project implements a modern monorepo architecture with a NestJS backend and a Next.js frontend.
This project is divided into two primary services, each with its own specialized documentation. While the frontend provides a sleek interface, this is a backend-heavy project focused on complex distributed security patterns and modular API design.
The "Brain" of the project. Focuses on:
- Modular Domain Design: High separation of concerns.
- Unique Swagger & Constants Architecture: Unlike standard implementations, every API response message, status code, and Swagger documentation point is driven by a centralized Constants System. This ensures Zero Documentation Drift—your API docs are always perfectly synchronized with the actual business logic.
- Security Pipeline: Multi-step cryptographic signup and session management.
- Database Hygiene: Automated cleanup of OTPs and rotated tokens.
- Audit Logging: Comprehensive forensic logging of sensitive actions.
Read the Backend README for architecture details and API documentation.
The "Face" of the project. Focuses on:
- App Router: Leveraging modern React patterns.
- Context Management: Global Auth state and Axios interceptors.
- Smooth UX: Multi-step form flows for complex onboarding.
Read the Frontend README for UI structure and setup instructions.
What sets this repository apart is its Unified Response & Documentation Engine.
Instead of hardcoding strings in controllers and DTOs, this project utilizes a centralized ResponseMessages and HttpStatusCodes system that links directly to the Swagger (OpenAPI) documentation.
Why this is a game-changer:
- Zero Drift: Change a message in one constant file, and it updates across the logic, the automated tests, and the public API documentation simultaneously.
- Type-Safe Documentation: By leveraging NestJS decorators with these constants, the Swagger UI becomes a living contract that is mathematically guaranteed to match the backend's behavior.
- Frontend Harmony: Frontend developers can rely on standardized status codes and message keys, reducing integration friction.
- Node.js (v18+)
- PostgreSQL
- npm or yarn
Clone the repo and install dependencies:
git clone https://github.com/aarogyaojha/AuthProject.git
cd AuthProjectcd backend
npm install
cp .env.example .env # Configure your Postgres DB here
npx prisma migrate dev
npm run start:devcd ../frontend
npm install
cp .env.example .env.local
npm run dev| Layer | Technology |
|---|---|
| Backend | NestJS, Passport.js, Prisma, PostgreSQL |
| Frontend | Next.js 15, React, Axios |
| Security | JWT, Secure Cookies, Cryptographic OTP |
| DevOps | Docker, Monorepo Structure |
This project is licensed under the MIT License - see the LICENSE file for details.