{"id":15098984,"url":"https://github.com/michle99/sba_319_mongodb_database_application","last_synced_at":"2026-02-11T02:32:24.882Z","repository":{"id":207831782,"uuid":"720204066","full_name":"Michle99/sba_319_MongoDB_Database_Application","owner":"Michle99","description":"Create a Node, Express, and MongoDB Server Application with Docker.","archived":false,"fork":false,"pushed_at":"2023-11-23T19:27:50.000Z","size":100518,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-28T22:46:07.374Z","etag":null,"topics":["api-rest","api-testing","chai","chai-http","docker","docker-compose","docker-image","dotenv","express-router","expressjs","mocha-tests","mongodb","mongodb-atlas","mongodb-database","nodejs","nodemon","routes","test-driven-development","yamljs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Michle99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-11-17T20:12:27.000Z","updated_at":"2023-11-23T01:14:55.000Z","dependencies_parsed_at":"2025-03-27T13:48:35.981Z","dependency_job_id":null,"html_url":"https://github.com/Michle99/sba_319_MongoDB_Database_Application","commit_stats":null,"previous_names":["michle99/sba_319_mongodb_database_application"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/Michle99/sba_319_MongoDB_Database_Application","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michle99%2Fsba_319_MongoDB_Database_Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michle99%2Fsba_319_MongoDB_Database_Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michle99%2Fsba_319_MongoDB_Database_Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michle99%2Fsba_319_MongoDB_Database_Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Michle99","download_url":"https://codeload.github.com/Michle99/sba_319_MongoDB_Database_Application/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michle99%2Fsba_319_MongoDB_Database_Application/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271930755,"owners_count":24845474,"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-08-24T02:00:11.135Z","response_time":111,"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":["api-rest","api-testing","chai","chai-http","docker","docker-compose","docker-image","dotenv","express-router","expressjs","mocha-tests","mongodb","mongodb-atlas","mongodb-database","nodejs","nodemon","routes","test-driven-development","yamljs"],"created_at":"2024-09-25T17:01:20.895Z","updated_at":"2026-02-11T02:32:24.842Z","avatar_url":"https://github.com/Michle99.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eSBA 319: MongoDB Database Application\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Michle99 - sba_319_MongoDB_Database_Application](https://img.shields.io/static/v1?label=Michle99\u0026message=sba_319_MongoDB_Database_Application\u0026color=red\u0026logo=github)](https://github.com/Michle99/sba_319_MongoDB_Database_Application \"Go to GitHub repo\")\n[![stars - sba_319_MongoDB_Database_Application](https://img.shields.io/github/stars/Michle99/sba_319_MongoDB_Database_Application?style=social)](https://github.com/Michle99/sba_319_MongoDB_Database_Application)\n[![forks - sba_319_MongoDB_Database_Application](https://img.shields.io/github/forks/Michle99/sba_319_MongoDB_Database_Application?style=social)](https://github.com/Michle99/sba_319_MongoDB_Database_Application)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \n[![SBA_319_MongoDB_Express_Docker_CICD](https://github.com/Michle99/sba_319_MongoDB_Database_Application/actions/workflows/main.yml/badge.svg)](https://github.com/Michle99/sba_319_MongoDB_Database_Application/actions/workflows/main.yml)\n  \n[![License](https://img.shields.io/badge/License-MIT-red)](#license)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Use this template](https://img.shields.io/badge/Generate-Use_this_template-2ea44f?style=for-the-badge)](https://github.com/Michle99/sba_319_MongoDB_Database_Application/generate)\n\n\n\u003c/div\u003e\n\n## Table of Contents\n1. [Introduction](#introduction)\n2. [Objectives](#objectives)\n3. [Movies API Documentation](#movies-api-documentation)\n   - [Base URL](#base-url)\n   - [Get All Movies](#1-get-all-movies)\n   - [Get Single Movie](#2-get-a-single-movie)\n   - [Add a New Movie](#3-add-a-new-movie)\n   - [Update a Movie](#4-update-a-movie)\n   - [Delete a Movie](#5-delete-a-movie)\n   - [Failed Validation Request](#6-failed-validations-request)\n   - [Error Handling](#7-error-handling)\n4. [Swagger Movie API Documentation](#swagger-movie-api-documentation)\n5. [Creating a Docker Image and Container](#creating-a-docker-image-and-container)\n6. [Dependencies](#dependencies)\n7. [Resources](#resources)\n8. [Getting Started](#getting-started)\n\n## Introduction\nThis assessment measures your understanding of MongoDB and your capability to implement its features in a practical manner. You have creative freedom in the topic, material, and purpose of the web application you will be developing, so have fun with it! However, remember to plan the scope of your project to the timeline you have been given.\n\n\n## Objectives\n1. Create a server application with Node, Express, and MongoDB.\n2. Create a CRUD API using Express and MongoDB.\n3. Use MongoDB indexing to make efficient queries.\n4. Create MongoDB validation rules.\n5. Use MongoDB validation to ensure data consistency.\n\n## Movies API Documentation\n\nThe Movies API allows you to manage a collection of movies. It supports CRUD (Create, Read, Update, Delete) operations to interact with movie data.\n\n## Base URL\n[http://localhost:5000/movies](http://localhost:5000/movies)\n\n\n## Movies Routes Requests and Responses\n\n### 1. Get All Movies\n- **Endpoint:** `GET /`\n- **Description:** Get a list of all movies.\n\n- **Example Usage:**\n```\nGET http://localhost:5000/movies\n```\n\n- **Example Response:**\n\n```json\n[\n  {\n    \"_id\": {\n        \"$oid\": \"573a1391f29313caabcd7db6\"\n    },\n    \"plot\": \"In Paris a wild girl becomes possessed by the soul of her twin who died to save her life.\",\n    \"genres\": [\n        \"Drama\"\n    ],\n    \"runtime\": 82,\n    \"cast\": [\n        \"Betty Compson\",\n        \"Clive Brook\",\n        \"Henry Victor\",\n        \"A.B. Imeson\"\n    ],\n    \"title\": \"White Shadows\",\n    \"fullplot\": \"In Paris a wild girl becomes possessed by the soul of her twin who died to save her life.\",\n    \"languages\": [\n        \"English\"\n    ],\n    \"released\": {\n        \"$date\": {\n        \"$numberLong\": \"-1440892800000\"\n        }\n    },\n    \"directors\": [\n        \"Graham Cutts\"\n    ],\n    \"writers\": [\n        \"Alfred Hitchcock\",\n        \"Michael Morton (novel)\"\n    ],\n    \"awards\": {\n        \"wins\": 1,\n        \"nominations\": 0,\n        \"text\": \"1 win.\"\n    },\n    \"lastupdated\": \"2015-05-10 00:19:38.277000000\",\n    \"year\": 1924,\n    \"imdb\": {\n        \"rating\": 6.5,\n        \"votes\": 156,\n        \"id\": 15493\n    },\n    \"countries\": [\n        \"UK\"\n    ],\n    \"type\": \"movie\",\n    \"tomatoes\": {\n        \"viewer\": {\n        \"rating\": 2.8,\n        \"numReviews\": 11\n        },\n        \"lastUpdated\": {\n        \"$date\": \"2015-06-14T18:00:09.000Z\"\n        }\n    },\n    \"num_mflix_comments\": 0\n  }\n  // ...\n]\n\n```\n#### Get All Movies Screenshots\n\n\u003cimg src=\"./sba_319_pic/GET_0.png\" width=\"90%\" alt=\"GET Screenshot 1\"\u003e\n\u003cimg src=\"./sba_319_pic/GET.png\" width=\"90%\" alt=\"GET Screenshot 2\"\u003e\n\n---\n\n### 2. Get a Single Movie\n\n- **Endpoint:** `GET /:id`\n- **Description:** Get details of a specific movie by ID.\n- Parameters:\n    - id: Movie ID\n\n- **Example Usage:**\n```\nGET http://localhost:5000/movies/573a1391f29313caabcd7db6\n```\n\n- **Example Response:**\n```json\n{\n  \"_id\": {\n    \"$oid\": \"573a1391f29313caabcd7db6\"\n  },\n  \"plot\": \"In Paris a wild girl becomes possessed by the soul of her twin who died to save her life.\",\n  \"genres\": [\n    \"Drama\"\n  ],\n  \"runtime\": 82,\n  \"cast\": [\n    \"Betty Compson\",\n    \"Clive Brook\",\n    \"Henry Victor\",\n    \"A.B. Imeson\"\n  ],\n  \"title\": \"White Shadows\",\n  \"fullplot\": \"In Paris a wild girl becomes possessed by the soul of her twin who died to save her life.\",\n  \"languages\": [\n    \"English\"\n  ],\n  \"released\": {\n    \"$date\": {\n      \"$numberLong\": \"-1440892800000\"\n    }\n  },\n  \"directors\": [\n    \"Graham Cutts\"\n  ],\n  \"writers\": [\n    \"Alfred Hitchcock\",\n    \"Michael Morton (novel)\"\n  ],\n  \"awards\": {\n    \"wins\": 1,\n    \"nominations\": 0,\n    \"text\": \"1 win.\"\n  },\n  \"lastupdated\": \"2015-05-10 00:19:38.277000000\",\n  \"year\": 1924,\n  \"imdb\": {\n    \"rating\": 6.5,\n    \"votes\": 156,\n    \"id\": 15493\n  },\n  \"countries\": [\n    \"UK\"\n  ],\n  \"type\": \"movie\",\n  \"tomatoes\": {\n    \"viewer\": {\n      \"rating\": 2.8,\n      \"numReviews\": 11\n    },\n    \"lastUpdated\": {\n      \"$date\": \"2015-06-14T18:00:09.000Z\"\n    }\n  },\n  \"num_mflix_comments\": 0\n}\n```\n#### Get a Single Movie Screenshots\n\u003cimg src=\"./sba_319_pic/GET_ID_0.png\" width=\"90%\" alt=\"Get a single movie screenshot 0\"\u003e\n\u003cimg src=\"./sba_319_pic/GET_ID_1.png\" width=\"90%\" alt=\"Get a single movie screenshot 1\"\u003e\n\n---\n\n### 3. Add a New Movie\n- **Endpoint:** `GET /`\n- **Description:** Add a new movie to the collection.\n\n- **Example Usage:**\n```\nPOST http://localhost:5000/movies\n```\n\n- **Request Body:**\n\n```json\n{\n  \"plot\": \"Takuma Sakamoto, a reclusive gamer, is unexpectedly transported into the virtual world of his favorite MMORPG as his in-game character, the powerful Demon Lord Diablo. Two girls who summoned him to control him end up becoming his servants due to a magic rebound. Takuma, dealing with social anxiety, adopts his in-game persona to navigate the new world. Alongside his companions, Rem and Shera, he embarks on a quest to remove the magic collars while assisting them with their personal struggles that led to their summoning.\",\n  \"genres\": [\"isekai\"],\n  \"runtime\":23,\n  \"cast\": [\n    \"Diablo\",\n    \"Sheera\",\n    \"Rem\"\n  ],\n  \"poster\": \"https://thecinemaholic.com/wp-content/uploads/2021/06/How-not-to-summon.jpg\",\n  \"title\": \"How not to summon a Demon Lord season 2\",\n  \"fullplot\": \"Takuma Sakamoto, a reclusive gamer, is unexpectedly transported into the virtual world of his favorite MMORPG as his in-game character, the powerful Demon Lord Diablo. Two girls who summoned him to control him end up becoming his servants due to a magic rebound. Takuma, dealing with social anxiety, adopts his in-game persona to navigate the new world. Alongside his companions, Rem and Shera, he embarks on a quest to remove the magic collars while assisting them with their personal struggles that led to their summoning.\",\n  \"languages\": [\n    \"English\"\n  ],\n  \"released\": \"2021-04-09T00:00:00.000Z\",\n  \"directors\": [\n    \"Satoshi Kuwabara\"\n  ],\n  \"rated\": \"TV-G\",\n  \"awards\": {},\n  \"lastupdated\": \"\",\n  \"year\": 2018,\n  \"imdb\": {},\n  \"countries\": [\n    \"JAPAN\"\n  ],\n  \"type\": \"ANIME\",\n  \"tomatoes\": {\n    \"viewer\": {},\n    \"fresh\": 6,\n    \"critic\": {\n      \"rating\": 7.6,\n      \"numReviews\": 6,\n      \"meter\": 100\n    },\n    \"rotten\": 0,\n    \"lastUpdated\": \"\"\n  },\n  \"num_mflix_comments\": 0\n}\n\n```\n\n- **Example Response:**\n\n```json\n{\n    \"acknowledged\": true,\n    \"insertedId\": \"6557d63b84def3c71fe4da1c\"\n}\n\n```\n\n#### Post request screenshot\n\u003cimg src=\"./sba_319_pic/POST_REQ.png\" width=\"80%\" alt=\"Post Request and Response\"\u003e\n\n---\n\n### 4. Update a Movie \n- **Endpoint:** PUT /:id\n- **Description:** Update details of a specific movie by ID.\n- **Parameters:**\n    - `id`: Movie ID\n- **Request Body:**\n\n```json\n{\n  \"type\": \"ANIMES WEB SERIES\"\n}\n```\n\n- **Example Usage:**\n```\nPUT http://localhost:5000/movies/573a1391f29313caabcd7db6\n\n```\n\n- **Example Response:**\n```json\n{\n  \"acknowledged\": true,\n  \"modifiedCount\": 1,\n  \"upsertedId\": null,\n  \"upsertedCount\": 0,\n  \"matchedCount\": 1\n}\n\n```\n\n### PUT Request Screenshot\n\u003cimg src=\"./sba_319_pic/PUT_ID.png\" width=\"80%\" alt=\"Update new movie\"\u003e\n\n\n### 5. Delete a Movie\n- **Endpoint: `DELETE /:id`**\n- **Description:** Delete a specific movie by ID.\n- **Parameters:**\n    - `id`: Movie ID\n\n- **Example Usage:**\n```\nDELETE http://localhost:5000/movies/573a1391f29313caabcd7db6\n\n```\n\n- **Example Response:**\n```json\n    {\n    \"acknowledged\": true,\n    \"deletedCount\": 1\n    }\n```\n#### Delete Response Screenshot\n\u003cimg src=\"./sba_319_pic/DELETE.png\" width=\"90%\" alt=\"Delete new movie\"\u003e\n\n\n### 6. FAILED VALIDATIONS REQUEST\n\n- **Validation Rules Function:**\n\n```\n// Define validation rules for the movies collection\nconst validationRules = {\n  $jsonSchema: {\n    bsonType: \"object\",\n    required: [\"plot\", \"genres\", \"type\", \"title\", \"poster\", \"cast\", \"fullplot\", \"runtime\"],\n    // ...\n  }\n};\n```\n\n- **Validation Example REQUEST**\n\n\u003cimg src=\"./sba_319_pic/failed_Validation_0.png\" width=\"90%\" alt=\"Failed movie validations\"\u003e\n\n- **Validation Example Response**\n\n\u003cimg src=\"./sba_319_pic/failed_validation_1.png\" width=\"90%\" alt=\"Failed movie validations\"\u003e\n\n### 7. Error Handling\n- If the request fails, the API will respond with an appropriate error message and status code.\n\n\n## Swagger Movie API Documentation\nThe below screenshot is the API documentation for the routers in the project.\n\nThe url to the swaggerUI API documentation is: [swaggerUI API Documentation](http://localhost:5000/api-docs/)\n\n\n### Swagger API UI\n\u003cimg src=\"./sba_319_pic/swagger_api_ui.png\" width=\"90%\" alt=\"Swagger UI API documentation interface\"\u003e\n\n### Movie Schema\n\u003cimg src=\"./sba_319_pic/movie_schema.png\" width=\"90%\" alt=\"Movie Schema\"\u003e\n\n#### Get All Movies video\nhttps://github.com/Michle99/sba_319_MongoDB_Database_Application/assets/63488970/8457c782-9f1f-4459-a171-3be6b442d7e1\n\n### Get a Single Movie\nhttps://github.com/Michle99/sba_319_MongoDB_Database_Application/assets/63488970/957fdf2f-03bf-4b5b-b074-e4921f678288\n\n### Post a new Movie\nhttps://github.com/Michle99/sba_319_MongoDB_Database_Application/assets/63488970/207bb5e9-a06b-4df0-8109-0f1315fbef10\n\n### Update an existing Movie\nhttps://github.com/Michle99/sba_319_MongoDB_Database_Application/assets/63488970/72c681a4-c8ca-4d6c-8733-29283fe31115\n\n### Delete an existing Movie\nhttps://github.com/Michle99/sba_319_MongoDB_Database_Application/assets/63488970/4babab45-57f9-4e94-af9e-4d00721c10d8\n\n## Creating a Docker Image and Container\n[Docker](https://docs.docker.com) is is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. \n\n- Install docker desktop application:\nTo create a docker container \u0026 image, download \u0026 install docker desktop: [Install Docker Desktop](https://docs.docker.com/get-docker/)\n- Create a [Dockerfile](https://github.com/Michle99/sba_319_MongoDB_Database_Application/blob/main/Dockerfile) in the root directory of the project. \n- Create a `.dockerignore` to exclude modules. Sample [.dockerignore](https://github.com/Michle99/sba_319_MongoDB_Database_Application/blob/main/.dockerignore).\n- Create a docker compose to define the service(s) that will be used for the project. \n[Docker Compose](https://docs.docker.com/compose/) is is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.\n\nHere is a sample [Docker Compose](https://github.com/Michle99/sba_319_MongoDB_Database_Application/blob/main/docker-compose.yml). \n\n- Lastly, build the docker container with the command:\n\n```\ndocker-compose up -d --build\n```\n\nThe Express application will be running on http://localhost:5000/api/movies.\n\n- Docker Repository:\nThe docker image can be downloaded on hub.docker.com. Use the command to pull the docker image:\n\n```\ndocker pull sam12302021/sba_319_mongodb-api\n```\n\n## Dependencies\n- chai\n- chai-http\n- dotenv\n- express\n- mocha\n- mongodb\n- nodemon\n- swagger-jsdoc\n- swagger-ui-express\n- yamljs\n\n\n## Resources\n1. [Mocha](https://mochajs.org) and [Chai](https://www.chaijs.com) for testing.\n2. [Swagger](https://swagger.io/docs/specification/basic-structure/) for Movie API Documentation.\n3. [Test a Node RESTful API with Mocha and Chai](https://www.digitalocean.com/community/tutorials/test-a-node-restful-api-with-mocha-and-chai)\n4. [Documenting your Express API with Swagger](https://blog.logrocket.com/documenting-express-js-api-swagger/)\n5. [Docker](https://docs.docker.com) to build  docker images.\n6. [Docker Compose](https://docs.docker.com/compose/) for defining and running multi-container Docker applications.\n\n## Getting Started\nClone this repo: [sba_319_MongoDB_Database_Application](https://github.com/Michle99/sba_319_MongoDB_Database_Application).\n\n\n- Install dependencies:\n```\nnpm install \n```\nor\n\n```\nnpm i\n```\n\n- Start local server:\n\n```\nnpm run start\n```\n\n## License\n\nReleased under [MIT](/LICENSE) by [@Michle99](https://github.com/Michle99).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichle99%2Fsba_319_mongodb_database_application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichle99%2Fsba_319_mongodb_database_application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichle99%2Fsba_319_mongodb_database_application/lists"}