{"id":31036976,"url":"https://github.com/mahbub2001/verdict-vista-backend","last_synced_at":"2025-09-14T04:45:07.404Z","repository":{"id":305522015,"uuid":"1023097271","full_name":"Mahbub2001/Verdict-Vista-Backend","owner":"Mahbub2001","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-20T16:05:07.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-20T16:25:20.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://verdict-vista-backend.vercel.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/Mahbub2001.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}},"created_at":"2025-07-20T14:18:44.000Z","updated_at":"2025-07-20T16:05:11.000Z","dependencies_parsed_at":"2025-07-20T16:36:08.497Z","dependency_job_id":null,"html_url":"https://github.com/Mahbub2001/Verdict-Vista-Backend","commit_stats":null,"previous_names":["mahbub2001/verdict-vista-backend"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Mahbub2001/Verdict-Vista-Backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mahbub2001%2FVerdict-Vista-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mahbub2001%2FVerdict-Vista-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mahbub2001%2FVerdict-Vista-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mahbub2001%2FVerdict-Vista-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mahbub2001","download_url":"https://codeload.github.com/Mahbub2001/Verdict-Vista-Backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mahbub2001%2FVerdict-Vista-Backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275062968,"owners_count":25398888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"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":"2025-09-14T04:45:05.771Z","updated_at":"2025-09-14T04:45:07.376Z","avatar_url":"https://github.com/Mahbub2001.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Debate Platform Backend\n\nA robust Node.js backend API for the AI-powered debate platform built with Express.js, MongoDB, and TypeScript.\n\n## Features\n\n- **User Authentication**: JWT-based authentication with registration and login\n- **Debate Management**: Create, read, update, and delete debates\n- **Argument System**: Add arguments to debates with voting functionality\n- **User Profiles**: User management with statistics tracking\n- **Real-time Features**: Support for debate timers and live interactions\n- **Security**: Helmet, CORS, rate limiting, and input validation\n- **Database**: MongoDB with Mongoose ODM\n- **TypeScript**: Full TypeScript support for type safety\n\n## Tech Stack\n\n- **Runtime**: Node.js\n- **Framework**: Express.js\n- **Database**: MongoDB with Mongoose\n- **Language**: TypeScript\n- **Authentication**: JWT (JSON Web Tokens)\n- **Validation**: express-validator\n- **Security**: Helmet, CORS, bcryptjs\n- **Logging**: Morgan\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js (v16 or higher)\n- MongoDB (local or cloud instance)\n- npm or yarn\n\n### Installation\n\n1. Clone the repository and navigate to the backend folder:\n```bash\ncd backend\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Create environment file:\n```bash\ncp .env.example .env\n```\n\n4. Configure your environment variables in `.env`:\n```env\nPORT=5000\nNODE_ENV=development\nMONGODB_URI=mongodb://localhost:27017/debate_platform\nJWT_SECRET=your-super-secret-jwt-key\nJWT_EXPIRES_IN=7d\nFRONTEND_URL=http://localhost:9002\n```\n\n5. Start MongoDB (if running locally):\n```bash\nmongod\n```\n\n6. Run the development server:\n```bash\nnpm run dev\n```\n\nThe server will start on `http://localhost:5000`\n\n### Build for Production\n\n```bash\nnpm run build\nnpm start\n```\n\n## API Endpoints\n\n### Authentication\n- `POST /api/auth/register` - Register a new user\n- `POST /api/auth/login` - Login user\n\n### Users\n- `GET /api/users` - Get all users (with pagination)\n- `GET /api/users/:id` - Get user by ID\n- `GET /api/users/me` - Get current user profile (protected)\n- `PUT /api/users/me` - Update current user profile (protected)\n- `GET /api/users/leaderboard` - Get user leaderboard\n\n### Debates\n- `GET /api/debates` - Get all debates (with filtering and pagination)\n- `GET /api/debates/:id` - Get debate by ID\n- `POST /api/debates` - Create new debate (protected)\n- `PUT /api/debates/:id` - Update debate (protected, creator only)\n- `DELETE /api/debates/:id` - Delete debate (protected, creator only)\n- `GET /api/debates/categories` - Get all debate categories\n\n### Arguments\n- `GET /api/debates/:debateId/arguments` - Get arguments for a debate\n- `POST /api/debates/:debateId/arguments` - Create new argument (protected)\n- `GET /api/arguments/:id` - Get argument by ID\n- `PUT /api/arguments/:id` - Update argument (protected, author only)\n- `DELETE /api/arguments/:id` - Delete argument (protected, author only)\n- `POST /api/arguments/:id/vote` - Vote/unvote on argument (protected)\n\n## Database Schema\n\n### User Schema\n```typescript\n{\n  name: string;\n  email: string;\n  password: string;\n  avatarUrl: string;\n  debatesParticipated: number;\n  totalVotes: number;\n  createdAt: Date;\n  updatedAt: Date;\n}\n```\n\n### Debate Schema\n```typescript\n{\n  title: string;\n  description: string;\n  tags: string[];\n  category: string;\n  imageUrl: string;\n  creatorId: ObjectId;\n  duration: number;\n  endTime: Date;\n  isActive: boolean;\n  createdAt: Date;\n  updatedAt: Date;\n}\n```\n\n### Argument Schema\n```typescript\n{\n  debateId: ObjectId;\n  authorId: ObjectId;\n  side: 'support' | 'oppose';\n  text: string;\n  votes: number;\n  votedBy: ObjectId[];\n  createdAt: Date;\n  updatedAt: Date;\n}\n```\n\n## Security Features\n\n- **JWT Authentication**: Secure token-based authentication\n- **Password Hashing**: bcryptjs for secure password storage\n- **Rate Limiting**: Prevents API abuse\n- **CORS**: Configured for cross-origin requests\n- **Helmet**: Security headers\n- **Input Validation**: express-validator for request validation\n- **MongoDB Injection Protection**: Mongoose built-in protection\n\n## Development\n\n### Scripts\n\n- `npm run dev` - Start development server with nodemon\n- `npm run build` - Build TypeScript to JavaScript\n- `npm start` - Start production server\n- `npm run lint` - Run ESLint\n- `npm run format` - Format code with Prettier\n- `npm test` - Run tests\n\n### Project Structure\n\n```\nsrc/\n├── config/          # Configuration files\n├── middleware/      # Express middleware\n├── models/          # Mongoose models\n├── routes/          # API routes\n├── types/           # TypeScript type definitions\n├── app.ts           # Express app setup\n└── server.ts        # Server entry point\n```\n\n## Error Handling\n\nThe API uses a consistent error response format:\n\n```json\n{\n  \"success\": false,\n  \"error\": \"Error message\",\n  \"data\": [] \n}\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahbub2001%2Fverdict-vista-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahbub2001%2Fverdict-vista-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahbub2001%2Fverdict-vista-backend/lists"}