### Start Web Application Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Start the Quizzard application for local web development. ```bash pnpm run dev ``` -------------------------------- ### Autocomplete Endpoint JSON Response Example Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-2-Report This is an example JSON response from the GET /autocomplete endpoint, showing a list of up to five valid English words that start with a given prefix. ```json [ "car", "care", "carry", "carrier", "cat" ] ``` -------------------------------- ### Start Mobile Application Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Start the Quizzard application for local mobile development. ```bash npm start ``` -------------------------------- ### Install Web Dependencies Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Install necessary pnpm dependencies for local web deployment. ```bash pnpm i ``` -------------------------------- ### Install Dependencies Source: https://github.com/bounswe/bounswe2024group5/blob/main/mobile/Quizzard/README.md Installs and updates project dependencies using npm. ```bash npm install npm update ``` -------------------------------- ### Get Users Followed by User API Request Source: https://github.com/bounswe/bounswe2024group5/wiki/Customer-Milestone-3-Report Example of an HTTP GET request to retrieve the list of users that a specific user is following. ```http GET /api/users/john_doe/following HTTP/1.1 ``` -------------------------------- ### Install Mobile Dependencies Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Install necessary npm dependencies for local mobile deployment. ```bash npm install npm install expo npm update ``` -------------------------------- ### Auto-complete Response Example Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-2-Report Example JSON response for auto-complete suggestions when the prefix is 'ne'. ```json [ "new", "need", "never", "next", "news", "needs", "near", "network", "nearly", "necessary" ] ``` -------------------------------- ### Reply to Post API Response Example Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-3-Report Example JSON response for the 'reply to post' endpoint, showing the details of the newly created reply. ```json { "id": 456, "postId": 12, "username": "johndoe", "content": "This is my reply to the post.", "createdAt": "2024-12-20T14:30:00Z", "updatedAt": "2024-12-20T14:30:00Z" } ``` -------------------------------- ### User Registration API Response Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-3-Report Example JSON response after a successful user registration. ```json { "id": 1, "username": "johndoe", "name": "John Doe", "email": "johndoe@example.com", "profile_picture": null, "englishProficiency": "b1", "points": 750, "created_quizzes": 0, "created_at": "2024-12-20T10:00:00Z", "updated_at": "2024-12-20T10:00:00Z" } ``` -------------------------------- ### Get Correct Answers API Response Example Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-3-Report Example JSON response for the 'get-correct-answers' endpoint, listing a set of correct answers. ```json [ "süratli", "çabuk", "hızlı", "yapışmak", "oruç tutmak", "dayanmak", "perhiz yapmak", "tez canlı", "çıkmaz", "sımsıkı" ] ``` -------------------------------- ### Build and Deploy Application Source: https://github.com/bounswe/bounswe2024group5/wiki/Customer-Milestone-2-Report Use this command to build and deploy the application from the main directory of the GitHub repository. ```bash docker-compose up --build ``` -------------------------------- ### Initialize Database Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Initialize the database for the Quizzard application using Docker Compose. ```bash # Database initialization commands docker compose up -d database ``` -------------------------------- ### GET /posts/{postId}/replies Request Body Source: https://github.com/bounswe/bounswe2024group5/blob/main/doc/acceptance-criteria.md Example of a request body to retrieve replies for a specific forum post. Requires the postId. ```json { "postId": 3 } ``` -------------------------------- ### GET /posts/{postId}/replies Successful Response Source: https://github.com/bounswe/bounswe2024group5/blob/main/doc/acceptance-criteria.md Example of a successful response when retrieving replies for a forum post. Returns an array of reply objects. ```json [ { "id": 0, "postId": 3, "username": "string", "content": "string", "createdAt": "2024-12-03T13:35:26.509Z", "updatedAt": "2024-12-03T13:35:26.509Z" } ] ``` -------------------------------- ### Build and Run Local Deployment Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Build and run the Quizzard application locally using Docker Compose. ```bash docker compose up --build -d ``` -------------------------------- ### Get Users Followed by User API Response Source: https://github.com/bounswe/bounswe2024group5/wiki/Customer-Milestone-3-Report Example of an HTTP 200 OK response containing a JSON array of users followed by a specified user. ```json HTTP/1.1 200 OK Content-Type: application/json [ { "username": "jane_smith" }, { "username": "michael_gates" }, { "username": "mike_jones" } ] ``` -------------------------------- ### Get Recommended Quiz Questions Source: https://github.com/bounswe/bounswe2024group5/wiki/Postman-API-Collection GET request to get recommended questions for a quiz, including Authorization header and a JSON body with quizAttemptId, questionId, and newAnswer. ```json { "quizAttemptId":8, "questionId":16, "newAnswer":"hiz" } ``` -------------------------------- ### Register Sequence Diagram Source: https://github.com/bounswe/bounswe2024group5/wiki/Sequence-Diagrams Illustrates the user registration process, from guest user input to database addition via UserController. ```mermaid sequenceDiagram actor GuestUser participant UserController participant Database GuestUser->>+UserController: register(Map) UserController->>+Database: add_user(Map) alt No existing user with same username Database-->>UserController: success UserController-->>GuestUser: Registered successfully else Database-->>-UserController: failure (User exists) UserController-->>-GuestUser: Registration failed: Username already exists end ``` -------------------------------- ### Login Sequence Diagram Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Sequence-Diagrams Illustrates the user login process, from guest user input to authentication via the Auth Controller and Database. ```mermaid sequenceDiagram actor GU as GuestUser participant LP as LoginPage participant AC as AuthController participant DB as Database GU->>+LP: login(credentials) LP->>+AC: authenticate(loginDTO) AC->>+DB: checkCredentials() alt Valid Credentials DB-->>-AC: success AC-->>-LP: success LP-->>-GU: redirectToHome() else Invalid Credentials DB-->>AC: error AC-->>LP: error LP-->>GU: displayError(ERR_CODE, ERR_MESSAGE) end ``` -------------------------------- ### Get Quiz by ID Source: https://github.com/bounswe/bounswe2024group5/wiki/Postman-API-Collection GET request to retrieve a specific quiz using its ID. ```json ``` -------------------------------- ### Backup Database Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Perform a database backup for the Quizzard application. ```bash # Database backup docker exec -it mysqldump -u root -p quizzard > backup.sql ``` -------------------------------- ### Turkish Repository for Auto-complete Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-2-Report Native SQL query for the Turkish repository to find words starting with a prefix, considering scores from joined English words, and ordered by score. ```java @Query(value = """ SELECT word FROM ( SELECT t.word, MIN(e.score) AS score FROM turkish t INNER JOIN translate tr ON t.id = tr.turkish_id INNER JOIN english e ON e.id = tr.english_id WHERE t.word LIKE :prefix% AND e.score != 2000 AND t.word NOT LIKE '% %' GROUP BY t.word ) AS sub ORDER BY score LIMIT 10 """, nativeQuery = true) List findTop5ByWordStartingWith(@Param("prefix") String prefix); ``` -------------------------------- ### Get Word Autocomplete Suggestions Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-2-Report Use this GET endpoint to fetch word suggestions based on a provided prefix. Supports specifying the language for suggestions. ```typescript const queryParams = new URLSearchParams({ prefix, language: 'english' | 'turkish' }); const response = await fetch(`${hostUrl}/api/autocomplete?${queryParams}`, { headers: { 'Authorization': `Bearer ${TOKEN}` } }); // Response [ "book", "boot", "boom", "booth", "bootstrap" ] ``` -------------------------------- ### Get /autocomplete?prefix={prefix}&language={language} Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-2-Report Provides word suggestions based on a given prefix and language. Returns a list of suggestions or a bad request error. ```APIDOC ## Get /autocomplete?prefix={prefix}&language={language} ### Description Retrieves a list of word suggestions based on a provided prefix and language. This endpoint is useful for features like type-ahead search or input assistance. ### Method GET ### Endpoint /autocomplete ### Parameters #### Query Parameters - **prefix** (string) - Required - The prefix to search for. - **language** (string) - Required - The language of the words to suggest. ### Response #### Success Response (200) - **suggestions** (array of strings) - A list of suggested words. #### Error Response (400) - **message** (string) - Error message indicating a bad request, likely due to invalid parameters. ``` -------------------------------- ### Restore Database Source: https://github.com/bounswe/bounswe2024group5/wiki/System-Manual Restore the Quizzard application database from a backup file. ```bash # Restore database cat backup.sql | docker exec -it mysql -u root -p quizzard ``` -------------------------------- ### PUT /posts/{postId} Successful Response Example Source: https://github.com/bounswe/bounswe2024group5/blob/main/doc/acceptance-criteria.md Example of a successful JSON response when updating a post using the PUT /posts/{postId} endpoint. ```json { "id": 0, "username": "string", "title": "string", "content": "string", "tags": [ "fast" ], "noUpvote": 0, "noReplies": 0, "createdAt": "2024-12-03T13:39:00.141Z", "updatedAt": "2024-12-03T13:39:00.141Z" } ``` -------------------------------- ### Get Posts Source: https://github.com/bounswe/bounswe2024group5/wiki/Postman-API-Collection Retrieves a list of all posts. ```APIDOC ## GET /posts ### Description Retrieves a list of all posts. ### Method GET ### Endpoint {{url}}/api/posts ``` -------------------------------- ### User Registration API Request Source: https://github.com/bounswe/bounswe2024group5/wiki/451-Customer-Milestone-3-Report Example of a POST request to register a new user. Requires username, name, email, password, and English proficiency. ```http POST http://34.121.241.21:80/api/auth/register Content-Type: application/json { "username": "johndoe", "name": "John Doe", "email": "johndoe@example.com", "password": "securePassword123", "englishProficiency": "b1" } ```