Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kunalbansall/assignment-submission-portal
"This project is a backend system designed for managing assignment submissions. It allows users to submit assignments, which can be reviewed by admins. It includes user authentication, assignment upload, and review functionality, with secure JWT authentication and admin-only controls."
https://github.com/kunalbansall/assignment-submission-portal
express jwt-authentication mongodb nodejs oauth2
Last synced: about 1 month ago
JSON representation
"This project is a backend system designed for managing assignment submissions. It allows users to submit assignments, which can be reviewed by admins. It includes user authentication, assignment upload, and review functionality, with secure JWT authentication and admin-only controls."
- Host: GitHub
- URL: https://github.com/kunalbansall/assignment-submission-portal
- Owner: KunalBansall
- Created: 2024-11-16T14:18:15.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-16T15:18:13.000Z (about 2 months ago)
- Last Synced: 2024-11-16T15:31:00.432Z (about 2 months ago)
- Topics: express, jwt-authentication, mongodb, nodejs, oauth2
- Language: JavaScript
- Homepage:
- Size: 60.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Assignment Submission Portal
A robust backend system for managing assignment submissions with user and admin functionality.
## Features
- User and Admin authentication
- Assignment submission system
- Assignment review system (accept/reject)
- OAuth2 integration
- JWT Authentication
- Role-Based Controls
- MongoDB database
- Express.js backend## Setup
1. Install dependencies:
```bash
npm install
```2. Start the server:
```bash
node src/index.js
```## API Endpoints
### Authentication
- **POST /api/auth/register**
Register a new user or admin.
**Request body**:
```json
{
"name": "user_name",
"email": "user_email",
"password": "user_password"
}
```- **POST /api/auth/login**
Login and receive a JWT token for authentication.
**Request body**:
```json
{
"email": "user_email",
"password": "user_password"
}
```- **GET /api/auth/admins**
Get a list of all admins.
**Authorization**: Bearer token required.### Assignment Management (Admin-only)
- **POST /api/assignments/upload**
Upload an assignment for review by an admin.
**Request body**:
```json
{
"task": "task_description",
"adminId": "admin_id"
}
```
**Authorization**: Bearer token required.- **GET /api/admin/assignments**
Fetch all assignments assigned to the admin.
**Authorization**: Bearer token required.- **POST /api/admin/assignments/:id/accept**
Accept the assignment with the given ID.
**URL Parameters**: `:id` (assignment ID).
**Authorization**: Bearer token required.- **POST /api/admin/assignments/:id/reject**
Reject the assignment with the given ID.
**URL Parameters**: `:id` (assignment ID).
**Authorization**: Bearer token required.### Authentication
The system uses **JWT (JSON Web Tokens)** for authentication. To access restricted endpoints (like those for admins), include the token in the `Authorization` header:
```bash
Authorization: Bearer
```
You can obtain a token by logging in with the `/api/auth/login` endpoint.### Example API Requests
1. **Register a User**
**URL**: `POST /api/auth/register`
**Request Body**:
```json
{
"name": "John Doe",
"email": "[email protected]",
"password": "password123"
}
```2. **Login**
**URL**: `POST /api/auth/login`
**Request Body**:
```json
{
"email": "[email protected]",
"password": "password123"
}
```**Response**:
```json
{
"token": "your_jwt_token_here"
}
```3. **Upload Assignment**
**URL**: `POST /api/assignments/upload`
**Request Body**:
```json
{
"task": "Complete the React.js project",
"adminId": "admin_id_here"
}
```
**Headers**:
```bash
Authorization: Bearer
```4. **Get Assignments for Admin**
**URL**: `GET /api/admin/assignments`
**Headers**:
```bash
Authorization: Bearer
```5. **Accept an Assignment**
**URL**: `POST /api/admin/assignments/:id/accept`
**URL Parameters**: `:id` - The ID of the assignment to accept.
**Headers**:
```bash
Authorization: Bearer
```6. **Reject an Assignment**
**URL**: `POST /api/admin/assignments/:id/reject`
**URL Parameters**: `:id` - The ID of the assignment to reject.
**Headers**:
```bash
Authorization: Bearer
```## Technologies Used
Node.js: JavaScript runtime environment.
Express.js: Web framework for Node.js.
MongoDB: NoSQL database for storing users and assignments.
JWT: JSON Web Tokens for user authentication.
bcryptjs: For password hashing.
dotenv: To manage environment variables.
express-validator: To validate incoming requests.
OAuth2: For Google authentication .
```