{"id":20520786,"url":"https://github.com/erebelo/spring-mongodb-demo","last_synced_at":"2026-04-29T22:40:17.982Z","repository":{"id":157727175,"uuid":"559700840","full_name":"erebelo/spring-mongodb-demo","owner":"erebelo","description":"Java REST API project using Spring Boot 3 and MongoDB","archived":false,"fork":false,"pushed_at":"2025-11-11T03:25:50.000Z","size":593,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-11T05:27:46.333Z","etag":null,"topics":["back-end","backend","backend-api","backend-service","java","junit","junit5","mockito","mongo","mongodb","non-relational-database","spring","spring-boot","spring-boot-3","springboot","unit-test"],"latest_commit_sha":null,"homepage":"https://api.erebelo.com/spring-mongodb-demo/swagger-ui/index.html","language":"Java","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/erebelo.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-30T22:33:06.000Z","updated_at":"2025-11-11T03:25:53.000Z","dependencies_parsed_at":"2024-02-26T21:47:50.631Z","dependency_job_id":"e26dab92-5d68-41c1-910b-d539abacb387","html_url":"https://github.com/erebelo/spring-mongodb-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erebelo/spring-mongodb-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erebelo%2Fspring-mongodb-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erebelo%2Fspring-mongodb-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erebelo%2Fspring-mongodb-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erebelo%2Fspring-mongodb-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erebelo","download_url":"https://codeload.github.com/erebelo/spring-mongodb-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erebelo%2Fspring-mongodb-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32447293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"ssl_error","status_checked_at":"2026-04-29T22:10:49.234Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["back-end","backend","backend-api","backend-service","java","junit","junit5","mockito","mongo","mongodb","non-relational-database","spring","spring-boot","spring-boot-3","springboot","unit-test"],"created_at":"2024-11-15T22:22:57.173Z","updated_at":"2026-04-29T22:40:17.947Z","avatar_url":"https://github.com/erebelo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring MongoDB Demo\n\nREST API project developed in Java using Spring Boot 3 and MongoDB.\n\n## Features\n\n- **HandlerInterceptor**: Intercepts requests to verify whether they contain the required HTTP header attribute.\n- **HandlerMethodArgumentResolver**: Retrieves a header value and assigns it to an argument type in controller methods.\n- **AbstractMongoEventListener**: Persists historical data for each POST, UPDATE, PATCH, and DELETE operation.\n- **AuditorAware**: Inserts values for auditable attributes such as `username`, document `version`, and `date` of operations in the persisted document.\n- **Converter** and **ConverterFactory**: Customize data transformations, such as converting enums to `String` or `Object`, and formatting `LocalDate` to `Date` (UTC, no offset) for MongoDB persistence and retrieval.\n- **ConstraintValidator**: Validates request fields and associated business rules by declaring an annotation in the request class.\n- **Asynchronous Task Execution**: Uses `CompletableFuture` to handle tasks asynchronously, optimizing performance by managing threads and enabling non-blocking operations.\n- **Logging**: Tracks application logs using `Log4j2`.\n- **Global Exception Handler**: Manages errors across the application.\n- **RestTemplate**: Facilitates HTTP requests to REST APIs.\n- **SSL/TLS**: Configures secure connections to MongoDB.\n- **Unit Tests**: Comprehensive test coverage for the entire application.\n- **Bulk Insert**: Implements a reusable bulk insert engine using MongoDB's `BulkOperations` to efficiently insert large datasets while gracefully tracking failures.\n\n## Requirements\n\n- Java 17\n- Spring Boot 3.x.x\n- Apache Maven 3.8.6\n\n## Libraries\n\n- [spring-common-parent](https://github.com/erebelo/spring-common-parent): Manages the Spring Boot version and provide common configurations for plugins and formatting.\n- [spring-common-lib](https://github.com/erebelo/spring-common-lib): Provides shared utilities and features, including:\n  - **Logging**: Log4j2 with ECS (Elastic Common Schema) layout (for non-local environments).\n  - **Http**: Pre-configured HTTP client utilities with customizable RestTemplate configurations for efficient connection management, proxy settings, and basic authentication.\n  - **Utils**: Utility classes for serialization, object mapping, thread context management in asynchronous operations, and configuring asynchronous task execution with `CompletableFuture`.\n\n## Configuring Maven for GitHub Dependencies\n\nTo pull the `spring-common-parent` and `spring-common-lib` dependencies, follow these steps:\n\n1. **Generate a Personal Access Token**:\n\n   Go to your GitHub account -\u003e **Settings** -\u003e **Developer settings** -\u003e **Personal access tokens** -\u003e **Tokens (classic)** -\u003e **Generate new token (classic)**:\n\n   - Fill out the **Note** field: `Pull packages`.\n   - Set the scope:\n     - `read:packages` (to download packages)\n   - Click **Generate token**.\n\n2. **Set Up Maven Authentication**:\n\n   In your local Maven `settings.xml`, define the GitHub repository authentication using the following structure:\n\n   ```xml\n   \u003cservers\u003e\n     \u003cserver\u003e\n       \u003cid\u003egithub-spring-common-parent\u003c/id\u003e\n       \u003cusername\u003eUSERNAME\u003c/username\u003e\n       \u003cpassword\u003eTOKEN\u003c/password\u003e\n     \u003c/server\u003e\n     \u003cserver\u003e\n       \u003cid\u003egithub-spring-common-lib\u003c/id\u003e\n       \u003cusername\u003eUSERNAME\u003c/username\u003e\n       \u003cpassword\u003eTOKEN\u003c/password\u003e\n     \u003c/server\u003e\n   \u003c/servers\u003e\n   ```\n\n   **NOTE**: Replace `USERNAME` with your GitHub username and `TOKEN` with the personal access token you just generated.\n\n## References\n\n- [MongoDB Setup](https://github.com/erebelo/spring-mongodb-demo/blob/main/docs/mongodb-setup.md): Instructions for MongoDB setup and index creation.\n- [Git Hooks Setup](https://github.com/erebelo/spring-mongodb-demo/tree/main/git-hooks): Automated Git hooks to enforce code formatting standards with Maven and the Spotless plugin.\n\n## Run App\n\n### Local Environment\n\n- Run the `SpringMongoDBDemoApplication` class as Java Application.\n\n### Non-Local Environments\n\nFor environments other than local, additional configurations are required:\n\n- **Set Environment Variables**: Set the following environment variables to configure the application: `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USERNAME`, `DB_PASSWORD`, and `DB_SSL_KEYSTORE_PASSWORD`.\n- **Generate Keystore**: Generate a `mongodb-keystore.p12` file and place it in the `/resources` directory. This keystore will store the necessary certificates. For detailed steps on generating the required certificates and creating the keystore file, follow the instructions in the [Enable SSL/TLS on MongoDB Server](https://github.com/erebelo/spring-mongodb-demo/blob/main/docs/ssl-tls-setup.md).\n\n## Collection\n\n[Project Collection](https://github.com/erebelo/spring-mongodb-demo/tree/develop/collection)\n\n## AWS Demo\n\n[Spring MongoDB Demo](https://api.erebelo.com/spring-mongodb-demo/swagger-ui/index.html)\n\n## AWS Deployment\n\nFollow the [AWS Docker](https://github.com/erebelo/aws-docker/tree/main) guide to deploy a **Java App** and **MongoDB** instances and how to set up **Nginx** as a reverse proxy with a valid Wildcard SSL/TLS certificate.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferebelo%2Fspring-mongodb-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferebelo%2Fspring-mongodb-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferebelo%2Fspring-mongodb-demo/lists"}