openapi: 3.0.0 info: version: 2.0.1 title: Anki Clone Application API description: This is the API of the Anki Clone Application. It allows you to manage users, learning packages, learning facts, tags and statistics. paths: # USER API /api/user: get: summary: Get all users (only for admin) operationId: getUser tags: - Users responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/User' '500': description: Internal Server Error post: summary: Create a new user operationId: createUser tags: - Users requestBody: description: The user to create required: true content: application/json: schema: type: object properties: mail: type: string description: The mail of the user example: john.doe@gmail.com required: true pseudo: type: string description: The pseudo of the user example: John required: true password: type: string description: The password of the user example: 123456 required: true profilePicture: type: string description: The profile picture of the user example: https://www.google.com/ required: false responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/User' '400': description: Bad Request '409': description: Conflict '500': description: Internal Server Error /api/user/{user_id}: get: summary: Get a user by id operationId: getUserById tags: - Users parameters: - name: user_id in: path description: The id of the user to retrieve required: true schema: type: number responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/User' '404': description: Not Found '500': description: Internal Server Error put: summary: Update a user by id operationId: updateUserById tags: - Users parameters: - name: user_id in: path description: The id of the user to update required: true schema: type: number requestBody: description: The user to update required: true content: application/json: schema: type: object properties: mail: type: string description: The mail of the user example: john.doe@gmail.com pseudo: type: string description: The pseudo of the user example: John password: type: string description: The password of the user example: 123456 profilePicture: type: string description: The profile picture of the user example: https://www.google.com/ responses: '204': description: Updated '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error /api/user/{user_id}/deactivate: put: summary: Deactivate a user by id operationId: deactivateUserById tags: - Users parameters: - name: user_id in: path description: The id of the user to deactivate required: true schema: type: number responses: '204': description: Updated '404': description: Not Found '500': description: Internal Server Error # LEARNING PACKAGE API /api/package: get: summary: Get all learning packages operationId: getLearningPackage tags: - Learning Packages responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/LearningPackage' '500': description: Internal Server Error post: summary: Create a new learning package operationId: createLearningPackage tags: - Learning Packages requestBody: description: The learning package to create required: true content: application/json: schema: type: object properties: title: type: string description: The title of the learning package example: Learn TypeScript required: true description: type: string description: The description of the learning package example: A comprehensive guide to understanding TypeScript, a statically typed superset of JavaScript. required: false category: type: string description: The category of the learning package example: Programming Language required: false targetAudience: type: string description: The target audience of the learning package example: Developers familiar with JavaScript required: false duration: type: number description: The duration of the learning package in hours example: 2 required: false creatorId: type: number description: The id of the creator of the learning package example: 1 required: true responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/LearningPackage' '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error /api/package/summary: get: summary: Get all learning packages summary operationId: getLearningPackageSummary tags: - Learning Packages responses: '200': description: OK content: application/json: schema: type: array items: type: object properties: packageId: type: number description: The id of the learning package example: 1 title: type: string description: The title of the learning package example: Learn TypeScript '500': description: Internal Server Error /api/package/search: get: summary: Search learning packages by title or tag operationId: searchLearningPackage tags: - Learning Packages parameters: - name: title in: query description: The title of the learning package required: false schema: type: string - name: tag in: query description: The tag of the learning package required: false schema: type: string responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/LearningPackage' '404': description: Not Found '500': description: Internal Server Error /api/package/search-title: post: summary: Search learning packages by title operationId: searchLearningPackageByTitle tags: - Learning Packages requestBody: description: The title of the learning package required: true content: application/json: schema: type: object properties: title: type: string description: The title of the learning package example: Introduction to HTML required: true responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/LearningPackage' '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error /api/package/{package_id}: get: summary: Get a learning package by id operationId: getLearningPackageById tags: - Learning Packages parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/LearningPackage' '404': description: Not Found '500': description: Internal Server Error put: summary: Update a learning package by id operationId: updateLearningPackageById tags: - Learning Packages parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number requestBody: description: The learning package to update required: true content: application/json: schema: type: object properties: title: type: string description: The title of the learning package example: Learn TypeScript description: type: string description: The description of the learning package example: A comprehensive guide to understanding TypeScript, a statically typed superset of JavaScript. category: type: string description: The category of the learning package example: Programming Language targetAudience: type: string description: The target audience of the learning package example: Developers familiar with JavaScript duration: type: number description: The duration of the learning package in hours example: 2 responses: '204': description: Updated '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error delete: summary: Delete a learning package by id operationId: deleteLearningPackageById tags: - Learning Packages parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number responses: '204': description: Deleted '404': description: Not Found '500': description: Internal Server Error # LEARNING FACT API /api/fact: get: summary: Get all learning facts operationId: getLearningFact tags: - Learning Facts responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/LearningFact' '500': description: Internal Server Error /api/fact/{fact_id}: get: summary: Get a learning fact by id operationId: getLearningFactById tags: - Learning Facts parameters: - name: fact_id in: path description: The id of the learning fact required: true schema: type: number responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/LearningFact' '404': description: Not Found '500': description: Internal Server Error put: summary: Update a learning fact by id operationId: updateLearningFactById tags: - Learning Facts parameters: - name: fact_id in: path description: The id of the learning fact required: true schema: type: number requestBody: description: The learning fact to update required: true content: application/json: schema: type: object properties: front: type: string description: The front of the learning fact example: What is TypeScript? back: type: string description: The back of the learning fact example: TypeScript is a statically typed superset of JavaScript. source: type: string description: The source of the learning fact example: https://www.google.com/ relatedImage: type: string description: The related image of the learning fact example: https://www.google.com/ relatedLink: type: string description: The related link of the learning fact example: https://www.google.com/ packageId: type: number description: The id of the learning package example: 1 creatorId: type: number description: The id of the creator of the learning fact example: 1 responses: '204': description: Updated '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error delete: summary: Delete a learning fact by id operationId: deleteLearningFactById tags: - Learning Facts parameters: - name: fact_id in: path description: The id of the learning fact required: true schema: type: number responses: '204': description: Deleted '404': description: Not Found '500': description: Internal Server Error /api/fact/{fact_id}/deactivate: put: summary: Deactivate a learning fact by id operationId: deactivateLearningFactById tags: - Learning Facts parameters: - name: fact_id in: path description: The id of the learning fact required: true schema: type: number responses: '204': description: Updated '404': description: Not Found '500': description: Internal Server Error # TAG API /api/tag: get: summary: Get all tags operationId: getTag tags: - Tags responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Tag' '500': description: Internal Server Error post: summary: Create a new tag operationId: createTag tags: - Tags requestBody: description: The tag to create required: true content: application/json: schema: type: object properties: englishKeyword: type: string description: The english keyword of the tag example: TypeScript required: true frenchTranslation: type: string description: The french translation of the tag example: TypeScript required: true responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/Tag' '400': description: Bad Request '409': description: Conflict '500': description: Internal Server Error /api/tag/{tag_id}: put: summary: Update a tag by id operationId: updateTagById tags: - Tags parameters: - name: tag_id in: path description: The id of the tag required: true schema: type: number requestBody: description: The tag to update required: true content: application/json: schema: type: object properties: englishKeyword: type: string description: The english keyword of the tag example: TypeScript frenchTranslation: type: string description: The french translation of the tag example: TypeScript responses: '204': description: Updated '404': description: Not Found '409': description: Conflict '500': description: Internal Server Error delete: summary: Delete a tag by id operationId: deleteTagById tags: - Tags parameters: - name: tag_id in: path description: The id of the tag required: true schema: type: number responses: '204': description: Deleted '404': description: Not Found '500': description: Internal Server Error # STATISTICS API /api/statistics/user/{user_id}: get: summary: Get the statistics of a user by id operationId: getStatisticsByUserId tags: - Statistics parameters: - name: user_id in: path description: The id of the user required: true schema: type: number responses: '200': description: A list of user statistics content: application/json: schema: type: array items: type: object properties: nextDays: type: object additionalProperties: type: integer todayFacts: type: integer globalProgress: type: number format: double nbCreatedPackages: type: integer '404': description: Not Found '500': description: Internal Server Error # LEARNING PACKAGE <> FACT API /api/package/{package_id}/fact: get: summary: Get all learning facts by learning package id operationId: getLearningFactByLearningPackageId tags: - Learning Packages <> Learning Facts parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/LearningFact' '500': description: Internal Server Error post: summary: Create a new learning fact operationId: createLearningFact tags: - Learning Packages <> Learning Facts parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number requestBody: description: The learning fact to create required: true content: application/json: schema: type: object properties: front: type: string description: The front of the learning fact example: What is TypeScript? required: true back: type: string description: The back of the learning fact example: TypeScript is a statically typed superset of JavaScript. required: true source: type: string description: The source of the learning fact example: https://www.google.com/ required: false relatedImage: type: string description: The related image of the learning fact example: https://www.google.com/ required: false relatedLink: type: string description: The related link of the learning fact example: https://www.google.com/ required: false creatorId: type: number description: The id of the creator of the learning fact example: 1 required: true responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/LearningFact' '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error # LEARNING PACKAGE <> TAG API /api/package/{package_id}/tag: get: summary: Get all tags by learning package id operationId: getTagByLearningPackageId tags: - Learning Packages <> Tags parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/Tag' '500': description: Internal Server Error post: summary: Create a new tag operationId: createTag tags: - Learning Packages <> Tags parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number requestBody: description: The tag to create required: true content: application/json: schema: type: object properties: tagId: type: number description: The id of the tag example: 1 required: true responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/LearningPackageTag' '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error /api/package/{package_id}/tag/{tag_id}: delete: summary: Delete a tag by learning package id and tag id operationId: deleteTagByLearningPackageIdAndTagId tags: - Learning Packages <> Tags parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number - name: tag_id in: path description: The id of the tag required: true schema: type: number responses: '204': description: Deleted '404': description: Not Found '500': description: Internal Server Error # LEARNING PACKAGE <> USER API /api/package/user/{user_id}: get: summary: Get all learning packages by user id operationId: getLearningPackageByUserId tags: - Learning Packages <> Users parameters: - name: user_id in: path description: The id of the user required: true schema: type: number responses: '200': description: OK content: application/json: schema: type: array items: type: object properties: packageId: type: number description: The id of the learning package example: 1 title: type: string description: The title of the learning package example: Learn TypeScript description: type: string description: The description of the learning package example: A comprehensive guide to understanding TypeScript, a statically typed superset of JavaScript. category: type: string description: The category of the learning package example: Programming Language targetAudience: type: string description: The target audience of the learning package example: Developers familiar with JavaScript duration: type: number description: The duration of the learning package in hours example: 2 creationDate: type: string description: The creation date of the learning package example: 2021-01-01 creatorId: type: number description: The id of the creator of the learning package example: 1 progress: type: number description: The progress of the user learning package example: 0 expectedEndDate: type: string description: The expected end date of the user learning package example: 2021-01-01 minutesPerDayObjective: type: number description: The minutes per day objective of the user learning package example: 30 '404': description: Not Found '500': description: Internal Server Error /api/package/creator/{creator_id}: get: summary: Get all learning packages by creator id operationId: getLearningPackageByCreatorId tags: - Learning Packages <> Users parameters: - name: creator_id in: path description: The id of the creator required: true schema: type: number responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/LearningPackage' '404': description: Not Found '500': description: Internal Server Error /api/package/{package_id}/start/{user_id}: post: summary: Start a learning package by learning package id and user id operationId: startLearningPackageByLearningPackageIdAndUserId tags: - Learning Packages <> Users parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number - name: user_id in: path description: The id of the user required: true schema: type: number responses: '201': description: Created content: application/json: schema: $ref: '#/components/schemas/UserLearningPackage' '400': description: Bad Request '404': description: Not Found '500': description: Internal Server Error /api/package/{package_id}/reset/{user_id}: put: summary: Reset a learning package by learning package id and user id operationId: resetLearningPackageByLearningPackageIdAndUserId tags: - Learning Packages <> Users parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number - name: user_id in: path description: The id of the user required: true schema: type: number responses: '204': description: Updated '404': description: Not Found '500': description: Internal Server Error /api/package/{package_id}/stop/{user_id}: delete: summary: Stop a learning package by learning package id and user id operationId: stopLearningPackageByLearningPackageIdAndUserId tags: - Learning Packages <> Users parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number - name: user_id in: path description: The id of the user required: true schema: type: number responses: '204': description: Deleted '404': description: Not Found '500': description: Internal Server Error /api/package/{package_id}/user/{user_id}/overview: get: summary: Get the overview of a learning package by learning package id and user id operationId: getOverviewByLearningPackageIdAndUserId tags: - Learning Packages <> Users parameters: - name: package_id in: path description: The id of the learning package required: true schema: type: number - name: user_id in: path description: The id of the user required: true schema: type: number responses: '200': description: OK content: application/json: schema: type: array items: type: object properties: factId: type: number description: The id of the learning fact example: 1 front: type: string description: The front of the learning fact example: What is TypeScript? relatedImage: type: string description: The related image of the learning fact example: https://www.google.com/ lastReviewed: type: string description: The last reviewed date of the user learning fact example: 2021-01-01 reviewCount: type: number description: The review count of the user learning fact example: 1 '404': description: Not Found '500': description: Internal Server Error # LEARNING FACT <> USER API /api/fact/user/{user_id}: get: summary: Get all learning facts by user id operationId: getLearningFactByUserId tags: - Learning Facts <> Users parameters: - name: user_id in: path description: The id of the user required: true schema: type: number responses: '200': description: A list of learning facts content: application/json: schema: type: array items: $ref: '#/components/schemas/UserLearningFact' '404': description: Not Found '500': description: Internal Server Error /api/fact/{fact_id}/user/{user_id}: get: summary: Get a learning fact by id and user id operationId: getLearningFactByIdAndUserId tags: - Learning Facts <> Users parameters: - name: fact_id in: path description: The id of the learning fact required: true schema: type: number - name: user_id in: path description: The id of the user required: true schema: type: number responses: '200': description: A learning fact content: application/json: schema: $ref: '#/components/schemas/UserLearningFact' '404': description: Not Found '500': description: Internal Server Error /api/fact/{fact_id}/review/{user_id}: put: summary: Review a learning fact by id and user id operationId: reviewLearningFactByIdAndUserId tags: - Learning Facts <> Users parameters: - name: fact_id in: path description: The id of the learning fact required: true schema: type: number - name: user_id in: path description: The id of the user required: true schema: type: number requestBody: description: The user learning fact to update required: true content: application/json: schema: type: object properties: confidenceLevel: type: string description: The confidence level of the user learning fact example: 3 responses: '204': description: Updated content: application/json: schema: $ref: '#/components/schemas/UserLearningFact' '404': description: Not Found '500': description: Internal Server Error servers: [ { url: http://localhost:3000, description: Development server } ] components: schemas: User: type: object properties: userId: type: number description: The id of the user example: 1 mail: type: string description: The mail of the user example: john.doe@gmail.com pseudo: type: string description: The pseudo of the user example: John password: type: string description: The password of the user example: 123456 registrationDate: type: string description: The registration date of the user example: 2021-01-01 profilePicture: type: string description: The profile picture of the user example: https://www.google.com/ isActive: type: boolean description: The status of the user example: true required: - userId - mail - pseudo - password - registrationDate - isActive LearningPackage: type: object properties: packageId: type: number description: The id of the learning package example: 1 title: type: string description: The title of the learning package example: Learn TypeScript description: type: string description: The description of the learning package example: A comprehensive guide to understanding TypeScript, a statically typed superset of JavaScript. category: type: string description: The category of the learning package example: Programming Language targetAudience: type: string description: The target audience of the learning package example: Developers familiar with JavaScript duration: type: number description: The duration of the learning package in hours example: 2 creationDate: type: string description: The creation date of the learning package example: 2021-01-01 creatorId: type: number description: The id of the creator of the learning package example: 1 required: - packageId - title - creationDate - creatorId LearningFact: type: object properties: factId: type: number description: The id of the learning fact example: 1 front: type: string description: The front of the learning fact example: What is TypeScript? back: type: string description: The back of the learning fact example: TypeScript is a statically typed superset of JavaScript. source: type: string description: The source of the learning fact example: https://www.google.com/ relatedImage: type: string description: The related image of the learning fact example: https://www.google.com/ relatedLink: type: string description: The related link of the learning fact example: https://www.google.com/ isActive: type: boolean description: The status of the learning fact example: true packageId: type: number description: The id of the learning package example: 1 creatorId: type: number description: The id of the creator of the learning fact example: 1 required: - factId - front - back - source - isActive - packageId - creatorId Tag: type: object properties: tagId: type: number description: The id of the tag example: 1 englishKeyword: type: string description: The english keyword of the tag example: TypeScript frenchTranslation: type: string description: The french translation of the tag example: TypeScript required: - tagId - englishKeyword UserLearningPackage: type: object properties: userLearningPackageId: type: number description: The id of the user learning package example: 1 startDate: type: string description: The start date of the user learning package example: 2021-01-01 expectedEndDate: type: string description: The expected end date of the user learning package example: 2021-01-01 minutesPerDayObjective: type: number description: The minutes per day objective of the user learning package example: 30 progress: type: number description: The progress of the user learning package example: 0 userId: type: number description: The id of the user example: 1 learningPackageId: type: number description: The id of the learning package example: 1 required: - userLearningPackageId - startDate - progress - userId - learningPackageId UserLearningFact: type: object properties: userLearningFactId: type: number description: The id of the user learning fact example: 1 reviewCount: type: number description: The review count of the user learning fact example: 1 confidenceLevel: type: string description: The confidence level of the user learning fact example: 1 lastReviewed: type: string description: The last reviewed date of the user learning fact example: 2021-01-01 nextReviewDate: type: string description: The next review date of the user learning fact example: 2021-01-01 factId: type: number description: The id of the learning fact example: 1 userId: type: number description: The id of the user example: 1 required: - userLearningFactId - reviewCount - confidenceLevel - lastReviewed - nextReviewDate - factId - userId LearningPackageTag: type: object properties: learningPackageTagId: type: number description: The id of the learning package tag example: 1 packageId: type: number description: The id of the learning package example: 1 tagId: type: number description: The id of the tag example: 1 required: - learningPackageTagId - packageId - tagId