|
1 | | -# https-github.com-koders-in-backend-task-User-Auth |
| 1 | +# 🚀 Backend Intern Task: Authentication System for Trading Platform |
| 2 | + |
| 3 | +## 📌 Task Title: |
| 4 | +**Build Core Authentication System for a Trading Platform using Node.js, Express, and MongoDB** |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 🧠 Background: |
| 9 | +You’re contributing to the backend development of a **proprietary trading evaluation platform**. This platform allows traders to register, complete simulated trading challenges, and qualify for funded trading accounts based on performance. |
| 10 | + |
| 11 | +As a backend intern, your first assignment is to **build the core user authentication system** that will allow users to sign up, log in, reset their passwords, and securely access their accounts using JWT-based authentication. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## 📝 Task Description: |
| 16 | +You are required to implement the **core user authentication system** using a secure and modular approach. The backend must support user registration, login, password reset, and route protection using JWT tokens. |
| 17 | + |
| 18 | +The goal is to create a clean, scalable, and production-ready authentication flow using industry standards. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## ✅ Task Requirements: |
| 23 | + |
| 24 | +### ⚙️ Backend Stack: |
| 25 | +- **Node.js** |
| 26 | +- **Express.js** |
| 27 | +- **MongoDB + Mongoose** |
| 28 | +- **JWT (JSON Web Tokens)** |
| 29 | +- **dotenv** (for environment variables) |
| 30 | + |
| 31 | +### 🔐 Authentication Logic: |
| 32 | +- JWT-based login and route protection |
| 33 | +- Token generation and verification |
| 34 | +- Expiry handling and error responses |
| 35 | + |
| 36 | +### 🧩 User Model (MongoDB): |
| 37 | +- `fullName`: String |
| 38 | +- `email`: String (unique) |
| 39 | +- `password`: String (store in plain text for this task only) |
| 40 | +- `isEmailVerified`: Boolean |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## 📁 Project Structure Guidelines: |
| 45 | +```bash |
| 46 | +backend/ |
| 47 | +├── controllers/ |
| 48 | +│ └── auth.controller.js |
| 49 | +├── routes/ |
| 50 | +│ └── auth.routes.js |
| 51 | +├── models/ |
| 52 | +│ └── user.model.js |
| 53 | +├── middleware/ |
| 54 | +│ └── auth.middleware.js |
| 55 | +├── utils/ |
| 56 | +├── config/ |
| 57 | +├── server.js |
| 58 | +└── .env |
| 59 | +``` |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## 🔍 Core Features to Implement: |
| 64 | + |
| 65 | +### 🔐 Authentication Routes: |
| 66 | +| Endpoint | Method | Auth | Description | |
| 67 | +|----------|--------|------|-------------| |
| 68 | +| `/api/auth/register` | POST | ❌ | Signup with email & password | |
| 69 | +| `/api/auth/login` | POST | ❌ | Login with credentials | |
| 70 | +| `/api/auth/reset-password` | POST | ❌ | Request password reset | |
| 71 | +| `/api/auth/new-password` | POST | ❌ | Set new password | |
| 72 | +| `/api/user/profile` | GET | ✅ | Get authenticated user profile | |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## 🧪 Test Flow: |
| 77 | +- Register → Login → Access Protected Route |
| 78 | +- Reset password and login again |
| 79 | +- Use Postman or ThunderClient to verify API working |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## 💡 Notes: |
| 84 | +- Password can be stored as plain text for this test (no hashing or email validation needed) |
| 85 | +- Keep logic modular and follow separation of concerns |
| 86 | +- Use clear naming and clean code |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 📦 Deliverables: |
| 91 | +1. Create a **new branch** in this repository. |
| 92 | +2. Push your code into the `backend/` directory. |
| 93 | +3. **Create a Pull Request (PR)** to the `main` branch in this same repo with: |
| 94 | + - Your **Full Name** |
| 95 | + - Your **Role** (e.g., *Backend Intern*) |
| 96 | + - A short description of what you have implemented |
| 97 | + - Optional: A short Loom/video demo of the API testing |
| 98 | + |
| 99 | +**Example PR Title:** |
| 100 | +`[Backend Intern] Auth System Setup - John Doe` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## 🕒 Timeline: |
| 105 | +- ⏰ **3 Days** |
| 106 | +- Focus on clean implementation, proper structure, and code readability |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## 🚫 Common Mistakes to Avoid: |
| 111 | +- Hardcoding config/secrets instead of using `.env` |
| 112 | +- Not validating input (basic checks required) |
| 113 | +- Skipping route protection for private APIs |
| 114 | +- Merging everything into one file — **keep it modular** |
0 commit comments