{"id":50529805,"url":"https://github.com/parbhat-cpp/enthara-assignment","last_synced_at":"2026-06-03T12:01:43.221Z","repository":{"id":355985316,"uuid":"1229889950","full_name":"parbhat-cpp/enthara-assignment","owner":"parbhat-cpp","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-06T05:22:17.000Z","size":174,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-06T06:40:23.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://enthara-assignment-production.up.railway.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parbhat-cpp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-05T13:31:54.000Z","updated_at":"2026-05-06T05:32:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/parbhat-cpp/enthara-assignment","commit_stats":null,"previous_names":["parbhat-cpp/enthara-assignment"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/parbhat-cpp/enthara-assignment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parbhat-cpp%2Fenthara-assignment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parbhat-cpp%2Fenthara-assignment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parbhat-cpp%2Fenthara-assignment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parbhat-cpp%2Fenthara-assignment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parbhat-cpp","download_url":"https://codeload.github.com/parbhat-cpp/enthara-assignment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parbhat-cpp%2Fenthara-assignment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33863264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-03T12:01:41.842Z","updated_at":"2026-06-03T12:01:43.211Z","avatar_url":"https://github.com/parbhat-cpp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ethara - Project \u0026 Task Management Platform\n\nA full-stack project and task management application built with modern web technologies. Users can create projects, manage team members, create tasks, assign them to team members, and track progress with status updates.\n\n## 📋 Table of Contents\n\n- [Features](#features)\n- [Tech Stack](#tech-stack)\n- [Project Structure](#project-structure)\n- [Getting Started](#getting-started)\n- [Setup \u0026 Installation](#setup--installation)\n- [Local Development](#local-development)\n- [Environment Setup](#environment-setup)\n- [API Endpoints](#api-endpoints)\n- [Database Schema](#database-schema)\n- [Deployment](#deployment)\n- [Post-Deployment](#post-deployment)\n- [Troubleshooting](#troubleshooting)\n\n## ✨ Features\n\n### Project Management\n- **Create Projects** - Users can create new projects with name and description\n- **Project Members** - Add/remove team members to projects\n- **View Projects** - See all projects where user is creator or member\n- **Delete Projects** - Project creators can delete projects\n\n### Task Management\n- **Create Tasks** - Add tasks to projects with title, description, priority, due date\n- **Update Tasks** - Modify task details (admin and task creator only)\n- **Task Status Tracking** - Track progress with statuses: To Do, In Progress, Done\n- **Task Priority** - Set priority levels: Low, Medium, High\n- **Task Assignment** - Assign tasks to project members (admin only)\n- **Unassign Tasks** - Remove task assignments\n- **View Tasks** - Users can only see tasks they created, are assigned to, or are project admin\n- **Delete Tasks** - Task/project creators can delete tasks\n\n### User Management\n- **User Registration** - Sign up with email and password\n- **User Login** - Secure login with JWT authentication\n- **Password Security** - Passwords hashed with bcrypt\n- **User Search** - Search users by email when adding members\n\n### Access Control\n- **Role-Based Access** - Different permissions for project creators, task creators, and team members\n- **Task Permissions** - Members can only update their task status\n- **Admin Controls** - Project creators have full task management control\n\n## 🛠️ Tech Stack\n\n### Frontend\n- **Framework**: React 18+\n- **Routing**: TanStack Router (v1)\n- **State Management**: TanStack Query v5 (data fetching \u0026 caching)\n- **Form Handling**: TanStack React Form\n- **Validation**: Zod\n- **Styling**: Tailwind CSS\n- **Build Tool**: Vite\n- **Type Safety**: TypeScript\n- **Notifications**: React Hot Toast\n- **HTTP Client**: Fetch API with credentials support\n\n### Backend\n- **Runtime**: Node.js\n- **Framework**: Express.js v5\n- **Database**: MongoDB with Mongoose\n- **Authentication**: JWT (JSON Web Tokens)\n- **Password Security**: bcrypt\n- **Request Validation**: Zod\n- **CORS**: Configured for cross-origin requests\n- **Type Safety**: TypeScript\n- **Dev Server**: Nodemon\n\n### DevOps\n- **Deployment**: Railway\n- **Database Hosting**: MongoDB Atlas\n\n## 📁 Project Structure\n\n```\nethara-assignment/\n├── backend/\n│   ├── src/\n│   │   ├── config/\n│   │   │   └── db.ts              # MongoDB connection\n│   │   ├── controllers/\n│   │   │   ├── auth.controller.ts # Auth endpoints\n│   │   │   ├── project.controller.ts\n│   │   │   └── task.controller.ts\n│   │   ├── middlewares/\n│   │   │   └── is-auth.ts         # JWT verification\n│   │   ├── models/\n│   │   │   ├── users.model.ts\n│   │   │   ├── project.model.ts\n│   │   │   └── task.model.ts\n│   │   ├── routes/\n│   │   │   ├── auth.routes.ts\n│   │   │   ├── project.routes.ts\n│   │   │   ├── task.routes.ts\n│   │   │   └── index.ts\n│   │   ├── types/\n│   │   │   ├── auth.types.ts\n│   │   │   ├── project.types.ts\n│   │   │   ├── task.types.ts\n│   │   │   └── req.types.ts\n│   │   └── index.ts               # Express app setup\n│   ├── package.json\n│   ├── tsconfig.json\n│   └── .env\n│\n├── frontend/\n│   ├── src/\n│   │   ├── components/\n│   │   │   ├── ui/                # Reusable UI components\n│   │   │   ├── TaskUpdateDialog.tsx\n│   │   │   └── AddMemberDialog.tsx\n│   │   ├── integrations/\n│   │   │   └── tanstack-query/\n│   │   ├── routes/\n│   │   │   ├── __root.tsx         # Root layout\n│   │   │   ├── index.tsx          # Login/Register\n│   │   │   └── dashboard/\n│   │   │       ├── index.tsx      # Projects list\n│   │   │       └── project.$projectId.tsx\n│   │   ├── lib/\n│   │   │   └── utils.ts\n│   │   ├── styles.css\n│   │   └── router.tsx\n│   ├── package.json\n│   ├── vite.config.ts\n│   └── .env\n│\n└── README.md\n```\n\n## 🚀 Getting Started\n\n### Prerequisites\n- Node.js 18+ ([Download](https://nodejs.org/))\n- npm or yarn\n- Git\n- MongoDB (local or MongoDB Atlas account)\n\n## 📝 Setup \u0026 Installation\n\n### Step 1: Clone the Repository\n```bash\ngit clone \u003crepository-url\u003e\ncd ethara-assignment\n```\n\n### Step 2: Database Setup\n\n#### Option A: Using MongoDB Atlas (Recommended for Production)\n1. Go to [MongoDB Atlas](https://www.mongodb.com/cloud/atlas)\n2. Create a free account or log in\n3. Create a new project\n4. Create a cluster (select free tier)\n5. Create a database user with username and password\n6. Get connection string in format: `mongodb+srv://username:password@cluster.mongodb.net/dbname`\n\n#### Option B: Local MongoDB\n```bash\n# macOS (using Homebrew)\nbrew tap mongodb/brew\nbrew install mongodb-community\nbrew services start mongodb-community\n\n# Linux (Ubuntu/Debian)\nsudo apt-get install mongodb\n\n# Windows\n# Download and install from https://www.mongodb.com/try/download/community\n```\n\n### Step 3: Backend Setup\n```bash\ncd backend\n\n# Install dependencies\nnpm install\n\n# Create .env file with your configuration\n# Copy from .env.example and fill in your values\ncp .env.example .env\n\n# Edit .env with your database URL and JWT secret\n# See Environment Setup section below\n```\n\n### Step 4: Frontend Setup\n```bash\ncd ../frontend\n\n# Install dependencies\nnpm install\n\n# Create .env file\ncat \u003e .env \u003c\u003c EOF\nVITE_NODE_ENV=development\nVITE_BACKEND_URL=http://localhost:8080\nEOF\n```\n\n## 🏗️ Local Development\n\n### Terminal 1: Start Backend Server\n```bash\ncd backend\nnpm run dev\n```\nExpected output:\n```\nServer is running on port 8080\n```\n\n### Terminal 2: Start Frontend Dev Server\n```bash\ncd frontend\nnpm run dev\n```\nExpected output:\n```\nLocal: http://localhost:3000\n```\n\n### Access the Application\n1. Open browser to `http://localhost:3000`\n2. Sign up with a test account\n3. Create a project\n4. Add team members and tasks\n\n### Available npm Scripts\n\n**Backend:**\n- `npm run dev` - Start development server with auto-reload\n- `npm run build` - Compile TypeScript to JavaScript\n- `npm start` - Run compiled backend\n\n**Frontend:**\n- `npm run dev` - Start Vite dev server\n- `npm run build` - Build for production\n- `npm run preview` - Preview production build\n- `npm run lint` - Run ESLint\n- `npm run format` - Format and fix code\n- `npm run check` - Check code formatting\n\n## 🔧 Environment Setup\n\n### Backend Configuration (.env)\n\nCreate `backend/.env`:\n```env\n# Environment\nNODE_ENV=development\n\n# Server Port\nPORT=8080\n\n# JWT Configuration\nJWT_SECRET=your-super-secret-key-min-32-characters-for-production\n\n# MongoDB Configuration\nDB_URL=mongodb://localhost:27017/ethara\n# OR for MongoDB Atlas:\n# DB_URL=mongodb+srv://username:password@cluster.mongodb.net/dbname\nDB_USER=your-db-username\nDB_PASSWORD=your-db-password\n\n# CORS Configuration\nCORS_ORIGIN=http://localhost:3000\n```\n\n### Frontend Configuration (.env)\n\nCreate `frontend/.env`:\n```env\n# Environment\nVITE_NODE_ENV=development\n\n# Backend API URL\nVITE_BACKEND_URL=http://localhost:8080\n```\n\n### Environment Variables Explained\n\n| Variable | Description | Example |\n|----------|-------------|---------|\n| `NODE_ENV` | Environment mode | `development`, `production` |\n| `PORT` | Server port | `8080`, `5000` |\n| `JWT_SECRET` | Secret for JWT signing | Min 32 characters, use strong random string |\n| `DB_URL` | MongoDB connection URI | `mongodb+srv://user:pass@cluster.mongodb.net/db` |\n| `CORS_ORIGIN` | Frontend URL for CORS | `http://localhost:3000`, `https://app.example.com` |\n| `VITE_NODE_ENV` | Frontend environment | `development`, `production` |\n| `VITE_BACKEND_URL` | Backend API URL | `http://localhost:8080`, `https://api.example.com` |\n\n### Generating JWT_SECRET\n\n```bash\n# Using Node.js\nnode -e \"console.log(require('crypto').randomBytes(32).toString('hex'))\"\n\n# Using OpenSSL (Linux/Mac)\nopenssl rand -hex 32\n```\n\n## 📡 API Endpoints\n\n### Authentication Routes (`/api/auth`)\n\n| Method | Endpoint | Description | Auth |\n|--------|----------|-------------|------|\n| POST | `/login` | User login | ❌ |\n| POST | `/signup` | User registration | ❌ |\n| GET | `/user?email=example@email.com` | Search user by email | ✅ |\n\n**Login Request:**\n```json\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"password123\"\n}\n```\n\n**Signup Request:**\n```json\n{\n  \"fullname\": \"John Doe\",\n  \"email\": \"john@example.com\",\n  \"password\": \"password123\"\n}\n```\n\n### Project Routes (`/api/project`)\n\n| Method | Endpoint | Description | Auth | Role |\n|--------|----------|-------------|------|------|\n| POST | `/create` | Create new project | ✅ | Any |\n| GET | `/get-all` | Get all user's projects | ✅ | Any |\n| GET | `/get/:projectId` | Get project details | ✅ | Creator/Member |\n| PATCH | `/add/:projectId/:userId` | Add member to project | ✅ | Creator |\n| PATCH | `/remove/:projectId/:userId` | Remove member from project | ✅ | Creator |\n| DELETE | `/delete/:projectId` | Delete project | ✅ | Creator |\n\n**Create Project Request:**\n```json\n{\n  \"name\": \"Project Name\",\n  \"description\": \"Project description\",\n  \"members\": [\"userId1\", \"userId2\"]\n}\n```\n\n### Task Routes (`/api/task`)\n\n| Method | Endpoint | Description | Auth | Role |\n|--------|----------|-------------|------|------|\n| POST | `/create/:projectId` | Create task | ✅ | Creator |\n| GET | `/all/:projectId` | Get project tasks | ✅ | Creator/Member/Assigned |\n| GET | `/:taskId` | Get task details | ✅ | Creator/Assigned |\n| PATCH | `/update/:projectId/:taskId` | Update task | ✅ | Creator/Assigned |\n| PATCH | `/assign/:projectId/:taskId/:userId` | Assign task to user | ✅ | Creator |\n| PATCH | `/unassign/:projectId/:taskId/:userId` | Unassign task from user | ✅ | Creator |\n| DELETE | `/delete/:projectId/:taskId` | Delete task | ✅ | Creator |\n\n**Create Task Request (Admin):**\n```json\n{\n  \"title\": \"Task Title\",\n  \"description\": \"Task description\",\n  \"priority\": \"High\",\n  \"dueDate\": \"2024-12-31\",\n  \"assignedTo\": [\"userId1\"]\n}\n```\n\n**Update Task Request (Admin):**\n```json\n{\n  \"title\": \"Updated Title\",\n  \"description\": \"Updated description\",\n  \"priority\": \"Medium\",\n  \"dueDate\": \"2024-12-31\",\n  \"status\": \"In Progress\",\n  \"assignedTo\": [\"userId1\", \"userId2\"]\n}\n```\n\n**Update Task Request (Member):**\n```json\n{\n  \"status\": \"Done\"\n}\n```\n\n**Task Status Options:**\n- `To Do`\n- `In Progress`\n- `Done`\n\n**Priority Options:**\n- `Low`\n- `Medium`\n- `High`\n\n## 📊 Database Schema\n\n### User Model\n```typescript\n{\n  _id: ObjectId\n  fullname: String (required)\n  email: String (required, unique)\n  password: String (hashed, required)\n  createdAt: Date\n  updatedAt: Date\n}\n```\n\n### Project Model\n```typescript\n{\n  _id: ObjectId\n  name: String (required)\n  description: String\n  createdBy: ObjectId (User)\n  members: [ObjectId] (User array)\n  createdAt: Date\n  updatedAt: Date\n}\n```\n\n### Task Model\n```typescript\n{\n  _id: ObjectId\n  title: String (required)\n  description: String (required)\n  dueDate: Date (required)\n  priority: String enum ['Low', 'Medium', 'High']\n  status: String enum ['To Do', 'In Progress', 'Done']\n  createdBy: ObjectId (User)\n  assignedTo: [ObjectId] (User array)\n  projectId: ObjectId (Project)\n  createdAt: Date\n  updatedAt: Date\n}\n```\n\n## 🔐 Authentication Flow\n\n1. **Registration**: User signs up → Password hashed with bcrypt → JWT token created\n2. **Login**: User logs in → Password verified → JWT token issued\n3. **Requests**: Token sent via HTTP-only cookie → Middleware verifies JWT\n4. **Protected Routes**: Only accessible with valid JWT\n\n## 🚢 Deployment\n\n### Prerequisites for Railway\n- Railway account ([Create here](https://railway.app))\n- GitHub repository with your code\n- MongoDB Atlas account for database\n\n### Step-by-Step Railway Deployment\n\n#### 1. Prepare Your Code\n```bash\n# Ensure both backend and frontend have build scripts\n# Backend: package.json should have \"build\": \"tsc\"\n# Frontend: package.json should have \"build\": \"vite build\"\n\n# Ensure backend has start script\n# Backend: package.json should have \"start\": \"node dist/index.js\"\n```\n\n#### 2. Push Code to GitHub\n```bash\ngit add .\ngit commit -m \"Ready for deployment\"\ngit push origin main\n```\n\n#### 3. Create Railway Project\n1. Go to [Railway Dashboard](https://railway.app)\n2. Click \"New Project\"\n3. Select \"Deploy from GitHub\"\n4. Authorize Railway with GitHub\n5. Select your repository\n\n#### 4. Deploy Backend Service\n1. Click \"Add Service\" → \"GitHub Repo\"\n2. Select your repository\n3. Configure:\n   - **Root Directory**: `backend`\n   - **Start Command**: `npm run build \u0026\u0026 npm start`\n   - **Runtime**: Node.js\n\n#### 5. Add MongoDB Service\n1. Click \"Add Service\" → \"MongoDB\"\n2. Railway automatically provisions a MongoDB instance\n3. Note the connection variables provided\n\n#### 6. Configure Backend Environment Variables\nIn Railway Backend Service:\n1. Go to **Variables** tab\n2. Add the following:\n\n```\nNODE_ENV=production\nPORT=8080\nJWT_SECRET=\u003cgenerate-secure-random-string\u003e\nDB_URL=\u003ccopy-from-MongoDB-service\u003e\nCORS_ORIGIN=https://\u003cfrontend-service-name\u003e.up.railway.app\n```\n\n#### 7. Deploy Frontend Service\n1. Click \"Add Service\" → \"GitHub Repo\"\n2. Select your repository\n3. Configure:\n   - **Root Directory**: `frontend`\n   - **Build Command**: `npm install \u0026\u0026 npm run build`\n   - **Start Command**: `npm start`\n   - **Runtime**: Node.js\n\n#### 8. Configure Frontend Environment Variables\nIn Railway Frontend Service:\n1. Go to **Variables** tab\n2. Add:\n\n```\nVITE_NODE_ENV=production\nVITE_BACKEND_URL=https://\u003cbackend-service-name\u003e.up.railway.app\n```\n\n#### 9. Connect Services\n1. Click on Backend service\n2. In **Variables** tab, link to MongoDB service\n3. Update `DB_URL` to use the connected MongoDB\n\n### Production Deployment Checklist\n\n- [ ] MongoDB Atlas or Railway MongoDB configured\n- [ ] Backend environment variables set correctly\n- [ ] Frontend environment variables set correctly\n- [ ] `CORS_ORIGIN` matches frontend URL exactly\n- [ ] `JWT_SECRET` is strong and random (32+ characters)\n- [ ] Both services deployed successfully\n- [ ] No build errors in Railway logs\n- [ ] Application loads without errors\n- [ ] Authentication works (login/signup)\n- [ ] Projects and tasks can be created\n- [ ] Cookies are being set (check DevTools)\n\n## 📍 Post-Deployment\n\n### Verify Deployment\n\n1. **Check Service Status**\n   - Go to Railway Dashboard\n   - Verify both services show \"Healthy\"\n   - Check build logs for errors\n\n2. **Test Application**\n   - Visit frontend URL\n   - Create test account\n   - Test all features:\n     - Create project\n     - Add members\n     - Create task\n     - Update task status\n     - Assign/unassign tasks\n\n3. **Check Logs**\n   - Backend logs should show:\n     ```\n     Server is running on port 8080\n     CORS Origin: https://...\n     ```\n   - Look for any error messages\n\n4. **Verify Database**\n   - MongoDB Atlas dashboard\n   - Check data is being stored\n   - Monitor connections\n\n### Troubleshooting Production\n\n**Service Won't Deploy:**\n- Check build logs in Railway\n- Verify `start` script exists in backend package.json\n- Ensure all dependencies are in package.json (not devDependencies)\n\n**401 Authentication Errors:**\n- Check `CORS_ORIGIN` exactly matches frontend URL (no trailing slash)\n- Verify `JWT_SECRET` is set in backend\n- Clear browser cookies and re-login\n- Check browser DevTools Network tab for cookie issues\n\n**Cookie Not Being Set:**\n- Ensure frontend URL uses HTTPS (Railway provides this)\n- Verify `sameSite: 'none'` and `secure: true` in backend\n- Check CORS has `credentials: true`\n- Check `CORS_ORIGIN` is correct\n\n**Database Connection Error:**\n- Verify MongoDB service is running\n- Check `DB_URL` in environment variables\n- Verify credentials are correct\n- Check IP whitelist if using MongoDB Atlas\n\n### Monitoring \u0026 Maintenance\n\n**Useful Railway Features:**\n- **Metrics**: Monitor CPU, memory, network usage\n- **Logs**: Real-time application logs\n- **Network**: View incoming/outgoing requests\n- **Environment**: Manage variables and secrets\n\n**Regular Checks:**\n- Monitor error rates in logs\n- Check disk usage\n- Review JWT secret rotation policy\n- Update dependencies periodically\n\n### Custom Domain (Optional)\n\n1. In Railway service settings\n2. Go to **Domain** tab\n3. Click \"Add Domain\"\n4. Enter your custom domain\n5. Update DNS records at your domain provider\n6. Wait for SSL certificate to issue\n\n## 📝 API Response Format\n\n### Success Response\n```json\n{\n  \"success\": true,\n  \"message\": \"Operation successful\",\n  \"data\": { /* response data */ }\n}\n```\n\n### Error Response\n```json\n{\n  \"success\": false,\n  \"message\": \"Error description\",\n  \"error\": { /* error details */ }\n}\n```\n\n## 🔐 Security Features\n\n- ✅ Password hashing with bcrypt\n- ✅ JWT-based authentication\n- ✅ HTTP-only cookies (prevents XSS)\n- ✅ CORS protection\n- ✅ Input validation with Zod\n- ✅ Role-based access control\n- ✅ Secure cookie settings (Secure, HttpOnly, SameSite)\n\n## 📚 Key Features in Detail\n\n### Role-Based Permissions\n\n**Project Creators** can:\n- Add/remove members\n- Create tasks\n- Update all task details\n- Assign/unassign tasks\n- Delete project\n\n**Task Creators** can:\n- Update task details\n- Update task status\n- Assign/unassign tasks\n- Delete task\n\n**Assigned Members** can:\n- View assigned tasks\n- Update only task status\n\n### Task Visibility\n\nUsers can see tasks where they are:\n- The project creator\n- The task creator\n- Assigned to the task\n\n## 🐛 Troubleshooting\n\n## 🐛 Troubleshooting\n\n### Development Issues\n\n#### Backend Won't Start\n```bash\n# Error: Port already in use\n# Solution: Change PORT in .env or kill process on that port\n\n# Error: Cannot connect to MongoDB\n# Solution: \n# 1. Check MongoDB is running: mongosh or mongo shell\n# 2. Verify DB_URL in .env\n# 3. For Atlas: Check IP whitelist includes your IP\n\n# Error: nodemon command not found\n# Solution: npm install --save-dev nodemon\n```\n\n#### Frontend Won't Start\n```bash\n# Error: VITE_BACKEND_URL not working\n# Solution: Environment variables must start with VITE_\n\n# Error: Blank page or 404\n# Solution:\n# 1. Check npm run dev output for errors\n# 2. Clear browser cache\n# 3. Check console tab in DevTools\n```\n\n### Authentication Issues\n\n#### 401 Unauthorized Errors\n```\nIssue: Getting 401 on all API requests after login\nSolutions:\n1. Check cookies in DevTools \u003e Application \u003e Cookies\n   - Should have \"token\" cookie\n   - Should have Secure, HttpOnly, SameSite=None flags\n2. Verify JWT_SECRET is same in .env\n3. Check CORS_ORIGIN matches frontend URL exactly\n4. Clear cookies: DevTools \u003e Application \u003e Storage \u003e Clear site data\n5. Logout and login again\n6. Check backend logs for token errors\n```\n\n#### Cookies Not Being Set\n```\nIssue: Login succeeds but no token cookie appears\nSolutions:\n1. Check backend sameSite setting (should be 'none' for production)\n2. Verify frontend uses credentials: 'include' in fetch\n3. Check domain/subdomain match for cross-origin\n4. Ensure backend returns Set-Cookie header\n5. Browser console may show security warnings - check them\n```\n\n#### Password Issues\n```\nIssue: Login fails with \"Invalid credentials\"\nSolutions:\n1. Verify password is correct (case-sensitive)\n2. Ensure user exists: check MongoDB\n3. Check bcrypt is installed: npm list bcrypt\n4. Try resetting password by creating new account\n```\n\n### CORS \u0026 Cross-Origin Issues\n\n#### CORS Error in Browser\n```\nError: \"Access to XMLHttpRequest blocked by CORS policy\"\nSolutions:\n1. Verify CORS_ORIGIN in backend .env\n2. Check it matches frontend URL exactly (no trailing slash)\n3. For production: use https://domain.up.railway.app format\n4. Restart backend after changing CORS_ORIGIN\n```\n\n#### Preflight Request Failing\n```\nError: OPTIONS request returns 403/404\nSolutions:\n1. Ensure backend CORS middleware is before routes\n2. Check optionsSuccessStatus: 200 is set\n3. Verify allowedHeaders includes 'Content-Type'\n4. Check methods array includes 'OPTIONS'\n```\n\n### Database Issues\n\n#### Cannot Connect to MongoDB\n```\nError: \"connect ECONNREFUSED 127.0.0.1:27017\"\nSolutions (Local MongoDB):\n1. Start MongoDB:\n   - macOS: brew services start mongodb-community\n   - Linux: sudo systemctl start mongod\n   - Windows: mongod command or service start\n\n2. Verify MongoDB is running:\n   - mongosh or mongo (should connect)\n   \n3. Check bind_ip in /etc/mongod.conf (if not localhost)\n\nSolutions (MongoDB Atlas):\n1. Check connection string in DB_URL\n2. Verify IP whitelist: Atlas \u003e Network Access\n3. Add your current IP or allow all (0.0.0.0/0)\n4. Check username/password in connection string\n5. Try copying fresh connection string from Atlas\n```\n\n#### Database Command Failed\n```\nError: Database \"admin\" seeding failed\nSolutions:\n1. Check MongoDB is actually running\n2. Verify DB credentials are correct\n3. Ensure user has right permissions\n4. Check MongoDB version compatibility\n```\n\n### Deployment Issues\n\n#### Railway Deployment Fails\n```\nError: \"Build failed\"\nSolutions:\n1. Check build logs in Railway dashboard\n2. Verify start command exists in package.json\n3. Check all dependencies are in package.json (not devDependencies)\n4. Ensure TypeScript compiles: npm run build locally\n5. Verify node_modules is in .gitignore\n6. Try rebuilding: Railway \u003e Service \u003e Rebuild\n```\n\n#### Service Goes Down After Deploy\n```\nError: Service crashes immediately\nSolutions:\n1. Check Railway logs for error messages\n2. Verify all environment variables are set\n3. Check PORT variable (Railway assigns automatically)\n4. Ensure database connection string is correct\n5. Try: Railway \u003e Logs \u003e scroll to find error\n6. Check memory/CPU usage: may be insufficient\n```\n\n#### Frontend Shows Backend 404\n```\nError: All API calls return 404\nSolutions:\n1. Verify VITE_BACKEND_URL is set correctly\n2. Check backend service is running (Railway dashboard)\n3. Try accessing backend URL directly in browser\n4. Verify API routes match exactly (case-sensitive)\n5. Check backend logs for routing errors\n```\n\n### Performance Issues\n\n#### Slow Database Queries\n```\nSolutions:\n1. Add database indexes for common queries\n2. Monitor connection pool size\n3. Check Atlas performance metrics\n4. Consider pagination for large datasets\n```\n\n#### High Memory Usage\n```\nSolutions:\n1. Check for memory leaks in logs\n2. Reduce batch operation sizes\n3. Add pagination to list endpoints\n4. Monitor via Railway metrics\n```\n\n## 📚 Key Features in Detail\n\n### Role-Based Permissions\n\n**Project Creators** can:\n- Add/remove members\n- Create tasks\n- Update all task details\n- Assign/unassign tasks\n- Delete project\n\n**Task Creators** can:\n- Update task details\n- Update task status\n- Assign/unassign tasks\n- Delete task\n\n**Assigned Members** can:\n- View assigned tasks\n- Update only task status\n\n### Task Visibility\n\nUsers can see tasks where they are:\n- The project creator\n- The task creator\n- Assigned to the task\n\n## 🔐 Security Features\n\n- ✅ Password hashing with bcrypt\n- ✅ JWT-based authentication\n- ✅ HTTP-only cookies (prevents XSS)\n- ✅ CORS protection\n- ✅ Input validation with Zod\n- ✅ Role-based access control\n- ✅ Secure cookie settings (Secure, HttpOnly, SameSite)\n\n## 📝 API Response Format\n\n### Success Response\n```json\n{\n  \"success\": true,\n  \"message\": \"Operation successful\",\n  \"data\": { /* response data */ }\n}\n```\n\n### Error Response\n```json\n{\n  \"success\": false,\n  \"message\": \"Error description\",\n  \"error\": { /* error details */ }\n}\n```\n\n## 🚀 Building for Production\n\n### Backend Build\n```bash\ncd backend\n\n# Compile TypeScript to JavaScript\nnpm run build\n\n# This creates a dist/ directory with compiled code\n# Verify it works:\nnpm start\n```\n\n### Frontend Build\n```bash\ncd frontend\n\n# Build for production\nnpm run build\n\n# This creates a dist/ directory with optimized assets\n# Preview the build:\nnpm run preview\n```\n\n### Docker Support (Optional)\n\nIf you want to use Docker for deployment:\n\n**Backend Dockerfile:**\n```dockerfile\nFROM node:18-alpine\n\nWORKDIR /app\n\nCOPY package*.json ./\nRUN npm install\n\nCOPY src ./src\nCOPY tsconfig.json ./\n\nRUN npm run build\n\nEXPOSE 8080\n\nCMD [\"npm\", \"start\"]\n```\n\n**Frontend Dockerfile:**\n```dockerfile\nFROM node:18-alpine AS build\n\nWORKDIR /app\n\nCOPY package*.json ./\nRUN npm install\n\nCOPY . .\n\nRUN npm run build\n\nFROM node:18-alpine\n\nWORKDIR /app\n\nRUN npm install -g serve\n\nCOPY --from=build /app/dist ./dist\n\nEXPOSE 3000\n\nCMD [\"serve\", \"-s\", \"dist\", \"-l\", \"3000\"]\n```\n\n## 📚 Additional Resources\n\n### Documentation\n- [Express.js Documentation](https://expressjs.com/)\n- [React Documentation](https://react.dev/)\n- [MongoDB Documentation](https://docs.mongodb.com/)\n- [TanStack Router](https://tanstack.com/router/latest)\n- [TanStack Query](https://tanstack.com/query/latest)\n\n### Tools \u0026 Services\n- [Railway Documentation](https://docs.railway.app/)\n- [MongoDB Atlas](https://www.mongodb.com/cloud/atlas)\n- [JWT Introduction](https://jwt.io/)\n- [Zod Documentation](https://zod.dev/)\n\n### Learning Resources\n- Node.js \u0026 Express: [nodejs.org](https://nodejs.org/)\n- React Patterns: [React Best Practices](https://react.dev/learn)\n- Database Design: [MongoDB Tutorials](https://university.mongodb.com/)\n\n## 🤝 Contributing\n\nTo contribute to this project:\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/amazing-feature`\n3. Commit changes: `git commit -m 'Add amazing feature'`\n4. Push to branch: `git push origin feature/amazing-feature`\n5. Open a Pull Request\n\nPlease ensure:\n- Code is formatted with prettier\n- No lint errors: `npm run lint`\n- TypeScript compiles without errors\n- All environment variables are documented\n\n## 📄 License\n\nISC\n\n## 👤 Author\n\nParbhat Sharma\n\n## 📞 Support\n\nFor issues and questions:\n1. Check [Troubleshooting](#troubleshooting) section\n2. Review [API Endpoints](#api-endpoints) documentation\n3. Check backend logs in Railway/Terminal\n4. Check browser console for frontend errors\n5. Review GitHub Issues\n\n---\n\n**Last Updated:** May 6, 2026\n**Version:** 1.0.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparbhat-cpp%2Fenthara-assignment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparbhat-cpp%2Fenthara-assignment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparbhat-cpp%2Fenthara-assignment/lists"}