In continuation of the Learning Spring framework series, I created a Sample question & answer application to continue exploring Spring framework and start working on MongoDB & other tools. This application is posted to github for reference.
This is a two post series, Part 1 & Part 2, in which I will mainly talk about using Spring Framework 3.2 & related dependencies, data modeling & operations in MongoDB and application UI based on Bootstrap.
Configuring Sample question & answer application - Maven & Application Configuration
This post focuses on bootstrapping the Spring application and also provides details about maven dependencies for the Spring Framework, MongoDB Driver, Spring Data, and other dependencies. It also provides configuration details for Spring Framework, Spring Data, and Mongo.
- Many dependencies used in the previous prototype are upgraded to the latest release in the current application.
- Upgraded to the Spring Framework 3.2.0 and related libraries are added for utilizing the core Spring framework capabilities.
- Starting with Spring 3.2, Jackson 2 is supported. Added Jackson 2.1.1 dependencies for using JSON binding & Processing library in the latest prototype.
- For the application security, Spring Security 3.1.0 dependency is added.
- mongo-java-driver & Spring Data MongoDB 1.1.1, dependencies are added for application persistence using MongoDB.
Modeling Sample Question & Answer Application Using MongoDB
This post talks about data modeling in MongoDB and details CRUD operations using MongoTemplate.
- MongoDB stores data in a loosely structured JSON type collection called Document (BSON). Each of the documents can have embedded documents and arrays, and they can link to other documents. Following is a breakdown of different documents created as part of the current application.
- User Document:
- Users are the main actors in the application who create questions, provide answers, comment on the questions/answers, vote on questions/answers, etc,.
- In addition to holding the common attributes like first Name, last Name, etc., User Document embeds a list of Bookmarks documents (References to the question user bookmarked).
- Question Document:
- Question is the main entity in the application and most of the operations in the applications are performed on the Question Document.
- Question Document is mainly a collection of multiple collections/documents. The Question document contains attributes like Subject, Description, Audit information, etc,. and the following list of collections.
- Answers: As the name implies, this provides the answer to the respective question and is associated/nested with a question.
- Comments: Comments nested in the Answers make it a 3rd level nested document showcasing multiple levels of nesting in MongoDB.
- Tag Document:
- Tag organizes different questions into a group and provides ease of access. The Tag document holds information related to various question document references grouped under the tag.
Application UI Mockups
- Bootstrap is mainly used for UI styling.
- Following are some screen mock-ups using Bootstrap.
This prototype application has given me the opportunity to learn, explore and experiment with different tools like MongoDB, Bootstrap UI & Spring Framework, and integrate them all to build an end-to-end scenario.