Skip to content
Stefan edited this page Jun 29, 2025 · 2 revisions

Demo snimak

Na sledecem linku se nalazi demo snimak projekta: https://www.youtube.com/watch?v=6EixlUrPyvs

Architecture

Architecture

🔧 Building and running the application

Build and Run

Use case diagram

Use Case Diagram

APIs and Database schemas

Question service

Database schema

Name Type
id uuid
title string
description string
author string
votes int
answers int
views int
tags [string]
createdAt timestamp
modifiedAt timestamp

API

GET /questions

  • Description: Returns a list of the most recent questions, in the future could be implemented to return most relevant questions.

  • Response:

    • 200 OK, [Question] - Returns a list of questions with all of the information.

GET /questions/{id}

  • Description: Returns a list of the most recent questions, in the future could be implemented to return most relevant questions.

  • Response:

    • 200 OK, Question - Returns a question.
    • 404 Not Found - Returns Not Found if the question with given id does not exist.

GET /questions/tags/{tag}

  • Description: Returns a list of the most recent questions with given tag in the future could be implemented to return most relevant questions.

  • Response:

    • 200 OK, Question - Returns a list of questions.

POST /questions

  • Description: Creates a new question and saves it to a database.

  • Request body:

{
  "title": "Title of a question",
  "description": "Description of a question",
  "author": "",
  "tags": [string]
}
  • Response:
    • 200 OK, Question - Returns a questions that was created.
    • 400 Bad Request - Returns Bad Request when one of the fields is missing or is of a wrong type.

PUT /questions/{id}

  • Description: Updates a question.

  • Request body:

{
  "id", "uuid of the question",
  "title": "New title or old title if it is left unchanged",
  "description": "New description or old description",
  "tags": [string]
}
  • Response:
    • 200 OK, Question - Returns a question if it was updated successfully.
    • 400 Bad Request - Returns Bad Request when one of the fields is missing or is of a wrong type.
    • 401 Unauthorized - If a user that is not an author of a question tries to modify it.
    • 404 Not Found - If the question id is not found.

DELETE /questions/{id}

  • Description: Deletes a question with given id and all of the comments.

  • Response:

    • 204 No Content - If a question is deleted successfully.
    • 401 Unauthorized - If a user that is not the author of a question tries to delete it.
    • 404 Not Found - If a question with given id is not found.

POST /questions/{id}/vote

  • Description: Gives +1 or -1 votes to a question.

  • Request body:

{
  "id": "uuid",
  "votes": "upvote" or "downvote"
}
  • Response:
    • 200 Ok - If a vote has been successfully submitted.
    • 400 Bad Request - If request body contains invalid information.
    • 401 Unauthorized - If a user that is not logged in tries to vote on a question.
    • 404 Not Found - If a question with given id is not found.

Comment service

Database schema

Name Type
comment_id ObjectId
question_id ObjectId
author_id ObjectId
content string
votes int
upvotes [ObjectId]
downvotes [ObjectId]
creationDate timestamp
modifiedDate timestamp

API

General rules - every request must contain authorization token

GET /comments/{questionId}

  • Description: Returns a list of all comments on selected question.

  • Response:

    • 200 OK, [Comment] - Returns the list of comments.
    • 400 Bad Requset - If the question ID is invalid.
    • 500 Internal Server Error

POST /comments/{questionId}

  • Description: Creates a new comment on question with given id.

  • Request body:

{
    "content": string,  
    "userId": ObjectId
}
  • Response:
    • 200 OK, Comment - Returns the comment that was created.
    • 400 Bad Request - Returns error message with information on what field is missing or what value has wrong type.
    • 404 Not Found - If the question with given id does not exist.
    • 500 Internal Server Error

PUT /comments/{commentId}

  • Description: Updates the comment with given id.

  • Request body:

{
    "content": string,
    "userId": ObjectId
}
  • Response:
    • 200 OK, Comment - Returns comment if it was updated successfully.
    • 400 Bad Request - Returns error message with information on what field is missing or what value has wrong type.
    • 401 Unauthorized - If a user that is not an author of a comment tries to modify it.
    • 404 Not Found - If the comment with given id does not exists.
    • 500 Internal Server Error

DELETE /comments/{questionId}

  • Description: Deletes all the comments for question with given id.

  • Response:

    • 204 No Content - If the comments are deleted successfully.
    • 400 Bad Request - If question ID is invalid.
    • 401 Unauthorized - If user is not a moderator or if request is not sent by question service.
    • 500 Internal Server Error - If internal server error occurs.

DELETE /comments/{questionId}/{commentId}

  • Description: Deletes the comment with given id.

  • Response:

    • 204 No Content - If the comment is deleted successfully.
    • 401 Unauthorized - If a user that is not the author of the comment nor moderator tries to delete it.
    • 404 Not Found - If the comment with given id does not exist.
    • 500 Internal Server Error - If internal server error occurs.

PUT /comment/{commentId}/upvote

  • Description: Gives +1 votes to the comment.

  • Request body:

{
    "userId": ObjectId
}
  • Response:
    • 200 Ok - Returns current vote count if a vote has been successfully submitted.
    • 400 Bad Request - If same vote has been already submitted.
    • 401 Unauthorized - If a user that is not logged in tries to vote on the comment.
    • 404 Not Found - If a comment with given id does not exist.

PUT /comment/{commentId}/downvote

  • Description: Gives -1 votes to the comment.

  • Request body:

{
    "userId": ObjectId
}
  • Response:
    • 200 Ok - Returns current vote count if a vote has been successfully submitted.
    • 400 Bad Request - If same vote has been already submitted.
    • 401 Unauthorized - If a user that is not logged in tries to vote on the comment.
    • 404 Not Found - If a comment with given id is not found.

Account service

Database schema

Name Type
email string
user_id uuid
username string
password string
name string
surname string
picturePath string
year int
course string

API

Every request must contain username/author_id token

GET /users/

  • Return all users
  • Response: *200 OK

GET /users/{username}

  • Return profile account
  • Response:
    • 200 OK, Profile data - Return profile information
    • 404 Not found - Account doesn't exist

POST /users/login

  • Check if user exists with given username

POST /users

  • request json data:
 {
    "email" : string,
    "username" : string,
    "password" : string, 
    "name" : string,
    "course" : string
}
  • Response:
    • 201 OK, Return true if profile was created.
    • 400 Bad request - Missing some information
    • 403 Forbidden - Account already exist with same username

PUT /users/{username}

  • Update password with given password in body

  • Response:

    • 200 OK - Successfully update
    • 400 Bad request - Incorrect password
    • 404 Not found - User does not exist.

PATCH /users/

  • Update data info
  • Response:
    • 201 OK Successfully update
    • 400 Bad request - Incorrect data

DELETE /users/{username}

*DELETE account with given password in body

  • Response:
    • 200 OK - Successfully deleted
    • 404 Not found - User does not exist.

Clone this wiki locally