{"id":25803224,"url":"https://github.com/brenimcode/workshop-spring-mongodb","last_synced_at":"2025-10-16T16:09:00.406Z","repository":{"id":244440911,"uuid":"815247052","full_name":"brenimcode/workshop-spring-mongodb","owner":"brenimcode","description":"MongoDB integration with Spring Boot, focusing on CRUD operations, document-oriented design and object associations. The objective is to demonstrate the differences between document-oriented and relational paradigms, aiming for best practices for MongoDB applications.","archived":false,"fork":false,"pushed_at":"2024-06-21T13:42:07.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-22T09:22:48.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brenimcode.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-06-14T17:12:39.000Z","updated_at":"2024-06-21T13:42:10.000Z","dependencies_parsed_at":"2024-06-16T19:50:58.651Z","dependency_job_id":null,"html_url":"https://github.com/brenimcode/workshop-spring-mongodb","commit_stats":null,"previous_names":["brenimcode/workshop-spring-mongodb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenimcode%2Fworkshop-spring-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenimcode%2Fworkshop-spring-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenimcode%2Fworkshop-spring-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenimcode%2Fworkshop-spring-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brenimcode","download_url":"https://codeload.github.com/brenimcode/workshop-spring-mongodb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241040430,"owners_count":19898865,"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":"2025-02-27T17:44:32.598Z","updated_at":"2025-10-16T16:09:00.321Z","avatar_url":"https://github.com/brenimcode.png","language":"Java","readme":"# MongoDB with Spring Boot Workshop\n![Spring](https://img.shields.io/badge/spring-%236DB33F.svg?style=for-the-badge\u0026logo=spring\u0026logoColor=white) ![Apache Maven](https://img.shields.io/badge/Apache%20Maven-C71A36?style=for-the-badge\u0026logo=Apache%20Maven\u0026logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge\u0026logo=mongodb\u0026logoColor=white)\n## Project Overview\n\nThis project is designed to demonstrate how to use MongoDB with Spring Boot. It aims to provide an in-depth understanding of the document-oriented paradigm and how it differs from the relational model. By implementing CRUD operations and associations between objects, this project highlights the considerations and decisions involved in designing a document-oriented database. The project also showcases querying capabilities using Spring Data and MongoRepository.\n\n## General Objectives\n\n1. **Understand Document-Oriented vs. Relational Paradigms**\n   - Comprehend the core differences between document-oriented databases (such as MongoDB) and traditional relational databases.\n   \n2. **Implement CRUD Operations**\n   - Create, Read, Update, and Delete operations with MongoDB using Spring Boot.\n   \n3. **Design Considerations for Document-Oriented Databases**\n   - Reflect on the design decisions required for a document-oriented database structure.\n   \n4. **Implement Object Associations**\n   - Nested Objects: Understand how to handle nested documents within MongoDB.\n   - References: Implement and manage references between documents.\n\n5. **Perform Queries with Spring Data and MongoRepository**\n   - Utilize the powerful querying capabilities provided by Spring Data MongoDB.\n\n## Project Structure\n\nThe project consists of various components and modules that work together to demonstrate the capabilities and integration of MongoDB with Spring Boot.\n\n### Prerequisites\n\n- Java 17\n- Maven\n- MongoDB 4.0+\n- Spring Boot 3.3.0\n\n### Installation and Setup\n\n1. **Clone the repository:**\n   ```bash\n   git clone https://github.com/brenimcode/workshop-spring-mongodb.git\n   ```\n\n2. **Navigate to the project directory:**\n   ```bash\n   cd workshop-spring-mongodb\n   ```\n\n3. **Build the project:**\n   ```bash\n   mvn clean install\n   ```\n\n4. **Run the application:**\n   ```bash\n   mvn spring-boot:run\n   ```\n\n5. **Access the application:**\n   - The application runs on `http://localhost:8080`.\n\n### Project Components\n\n#### Domain\n\n- **User**: Represents the user entity with basic fields and associations.\n- **Post**: Represents the post entity, demonstrating nested documents and references.\n\n#### Repository\n\n- **UserRepository**: Extends `MongoRepository` for User-related CRUD operations.\n- **PostRepository**: Extends `MongoRepository` for Post-related CRUD operations.\n\n#### Service\n\n- **UserService**: Contains business logic for user operations.\n- **PostService**: Contains business logic for post operations.\n\n#### Resource\n\n- **UserResource**: Defines REST endpoints for user-related operations.\n- **PostResource**: Defines REST endpoints for post-related operations.\n\n### Endpoints\n\n#### User Endpoints\n\n- **Get all users**: `GET /users`\n- **Get user by ID**: `GET /users/{id}`\n- **Create new user**: `POST /users`\n- **Delete user by ID**: `DELETE /users/{id}`\n- **Get posts by user ID**: `GET /users/{id}/posts`\n\n#### Post Endpoints\n\n- **Get all posts**: `GET /posts`\n- **Get post by ID**: `GET /posts/{id}`\n- **Create new post**: `POST /posts`\n- **Delete post by ID**: `DELETE /posts/{id}`\n- **Find posts by title**: `GET /posts/titlesearch?text={text}`\n\n### Query Methods\n\n- **Find posts by title containing text**: \n  ```java\n  List\u003cPost\u003e findByTitleContaining(String text);\n  ```\n\n### Design Considerations\n\n- **Nested Objects vs. References**:\n  - Choose between embedding documents or referencing other documents based on the access patterns and size of the documents.\n  \n- **Query Performance**:\n  - Optimize queries using appropriate indexes and query patterns provided by Spring Data MongoDB.\n\n### Conclusion\n\nThis project provides a comprehensive example of integrating MongoDB with Spring Boot. It covers essential CRUD operations, object associations, and querying capabilities. By following this project, developers can gain a solid understanding of how to effectively design and implement a document-oriented database with Spring Boot and MongoDB.\n\nFor more details, refer to the project repository on [GitHub](https://github.com/brenimcode/workshop-spring-mongodb).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrenimcode%2Fworkshop-spring-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrenimcode%2Fworkshop-spring-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrenimcode%2Fworkshop-spring-mongodb/lists"}