{"id":18398731,"url":"https://github.com/mongodb-developer/microservices-architecture-mongodb","last_synced_at":"2025-04-14T10:52:40.807Z","repository":{"id":233090913,"uuid":"783965168","full_name":"mongodb-developer/microservices-architecture-mongodb","owner":"mongodb-developer","description":"Templates to create a Java Spring Boot microservices architecture with MongoDB","archived":false,"fork":false,"pushed_at":"2024-04-15T17:39:20.000Z","size":35,"stargazers_count":8,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T00:06:30.793Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb-developer.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":"2024-04-08T23:27:50.000Z","updated_at":"2025-03-24T16:01:53.000Z","dependencies_parsed_at":"2024-04-13T20:05:14.071Z","dependency_job_id":"cfe22e1e-bbcc-40c6-a5be-6dea18fafc22","html_url":"https://github.com/mongodb-developer/microservices-architecture-mongodb","commit_stats":null,"previous_names":["mongodb-developer/microservices-architecture-mongodb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fmicroservices-architecture-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fmicroservices-architecture-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fmicroservices-architecture-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fmicroservices-architecture-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb-developer","download_url":"https://codeload.github.com/mongodb-developer/microservices-architecture-mongodb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868808,"owners_count":21174755,"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","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":[],"created_at":"2024-11-06T02:24:06.477Z","updated_at":"2025-04-14T10:52:40.784Z","avatar_url":"https://github.com/mongodb-developer.png","language":"Java","readme":"# Microservices Architecture with MongoDB\n\nThis repository contains a set of templates to help you create a Java Spring Boot microservices architecture with MongoDB.\n\nIn this repo you'll find: \n\n- A config-server on port 8888\n- A service-registry on port 8761\n- An api-gateway on port 8080\n- Two microservices:\n  - company-service on port 8081\n  - employee-service on port 8082\n\n## Prerequisites\n\n- Docker (for local ephemeral MongoDB nodes or you can use MongoDB Atlas)\n- Java 21\n- Maven 3.6.3+\n\n## Getting Started\n\n### MongoDB\n\nMicroservices are supposed to be independent of each others. For this reason, we need two MongoDB instances: one for each microservice.\n\n**With Docker** \n\nThe following script will start two local single node replica set nodes on port 27017 and 27018.\n```bash\n./1_docker-start-mongodb.sh\n```\n\nWhen you are done:\n\n```bash\n./3_docker-stop-mongodb.sh\n```\n\n**With MongoDB Atlas**\n\nYou can create two tests clusters on MongoDB Atlas and overwrite the default MongoDB URIs before starting the two microservices.\n\nFor the `company_service` use:\n\n```bash\nexport MONGODB_URI_1=\"ATLAS_URI_HERE\"\n```\n\nFor the `employee_service` use:\n\n```bash\nexport MONGODB_URI_2=\"ATLAS_URI_HERE\"\n```\n\n### Start Spring Boot projects\n\nOpen five terminals: one for each folder.\n\nBefore we start the microservices, we need to retrieve their [config repository](https://github.com/mongodb-developer/microservices-architecture-mongodb-config-repo): \n\n```bash\ngit clone git@github.com:mongodb-developer/microservices-architecture-mongodb-config-repo.git\n```\n\nUpdate the file [config-server/src/main/resources/application.properties](config-server%2Fsrc%2Fmain%2Fresources%2Fapplication.properties) so this property points to the config repo.\n\n```properties\nspring.cloud.config.server.git.uri=${HOME}/Work/microservices-architecture-mongodb-config-repo\n```\n\nNow we can start the Spring Boot projects.\n\nStart with the `config-server` as the microservices need this one running to be able to retrieve their configuration.\n\n```bash\ncd config-server\nmvn clean spring-boot:run\n```\n\n```bash\ncd service-registry\nmvn clean spring-boot:run\n```\n\n```bash\ncd company-service\nexport MONGODB_URI_1=\"ATLAS_URI_HERE\" # optional\nmvn clean spring-boot:run\n```\n\n```bash\ncd employee-service\nexport MONGODB_URI_2=\"ATLAS_URI_HERE\" # optional\nmvn clean spring-boot:run\n```\n\n```bash\ncd api-gateway\nmvn clean spring-boot:run\n```\n\n## Test the REST APIs\n\nThe `api-gateway` running on port 8080 can distribute the queries to the relevant microservices.\n\nYou can test all the APIs using the script:\n\n```bash\n./2_api-tests.sh\n```\n\n\u003e Note that the script is only targeting the port 8080 of the api-gateway.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb-developer%2Fmicroservices-architecture-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb-developer%2Fmicroservices-architecture-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb-developer%2Fmicroservices-architecture-mongodb/lists"}