Skip to content

Commit 2daf503

Browse files
authored
Merge pull request #39 from mongodb-developer/java-server
Added instructions for the java server
2 parents 8cc9460 + 3674e41 commit 2daf503

File tree

7 files changed

+127
-13
lines changed

7 files changed

+127
-13
lines changed

docs/50-demo-app/1-intro.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# 📘 The Library Management System Application
22

3-
Throughout this workshop, you will have the opportunity to interface with the data using the library management system application we've provided you. This application uses an Angular front end and a Node.js back end. The application is already built and deployed to a GitHub codespace, so you won't need to install anything in your local environment. You will be able to access the application from your browser.
3+
Throughout this workshop, you will have the opportunity to interface with the data using the library management system application we've provided you. This application uses an Angular front end and a Node.js or Java Spring Boot back end. The application is already built and deployed to a GitHub codespace, so you won't need to install anything in your local environment. You will be able to access the application from your browser.
44

55
Our library management application leverages the data modeling patterns you'll explore throughout this workshop. As you navigate through the application, you'll witness how these patterns come to life, enhancing both the user experience and the efficiency of the system.
66

7-
Our library application enables users to explore a rich catalog of books, search for specific titles, delve into book details, and even share their thoughts through comments. Users can also reserve books for future reading. Behind the scenes, MongoDB's data modeling patterns play a crucial role in ensuring the application's flexibility, scalability, and performance.
7+
The application enables users to explore a rich catalog of books, search for specific titles, delve into book details, and even share their thoughts through comments. Users can also reserve books for future reading. Behind the scenes, MongoDB's data modeling patterns play a crucial role in ensuring the application's flexibility, scalability, and performance.
88

99
For library employees, an admin panel offers functionalities like managing book checkouts and returns. As we guide you through the application, you'll discover how the various design patterns we've discussed so far are seamlessly integrated to optimize data storage, retrieval, and overall system performance.
1010

docs/50-demo-app/2-start-app.mdx

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
import Screenshot from '@site/src/components/Screenshot';
2+
import Tabs from '@theme/Tabs';
3+
import TabItem from '@theme/TabItem';
24

35
# 👐 Start the Application
46

5-
Go to the [GitHub repository](https://github.com/mongodb-developer/library-management-system) for the demo application. From there, you have two options to start the application.
7+
You have two options to start the application.
68

79
## Option 1: Run in a codespace
810

9-
:::info
10-
11-
🚀 __Express start: [Click here](https://github.com/codespaces/new/mongodb-developer/library-management-system?quickstart=1) to start a new codespace or resume your last one!__
12-
13-
:::
14-
1511
By far, the easiest way to start the application is to run it in a codespace. A codespace is a cloud-hosted, containerized development environment that you can connect to from Visual Studio Code. It comes pre-configured with all the tools you need to build and run the application.
1612

1713
In the case of this application, you can even use the online IDE to edit the code and see the changes reflected in the running application.
1814

15+
<Tabs groupId="server">
16+
<TabItem value="node" label="🚀 NodeJS/Express">
17+
18+
Open the [repository on the `main` branch](https://github.com/mongodb-developer/library-management-system).
19+
1920
To start the application in a codespace, click "Code." Then, look for the *Codespaces* tab. Click "Create Codespace on main." This will create a new codespace for you and start the application.
2021

2122
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/1-codespace.png" alt="Create codespace button" />
2223

24+
</TabItem>
25+
26+
<TabItem value="java" label="☕️ Java Spring Boot">
27+
28+
Open the [repository on the `java-server` branch](https://github.com/mongodb-developer/library-management-system/tree/java-server).
29+
30+
To start the Java application in a codespace, check that you are in the `java-server` branch and then click "Code." Then, look for the *Codespaces* tab. Click "Create Codespace on java-server." This will create a new codespace for you and start the application.
31+
32+
<Screenshot url="https://github.com/mongodb-developer/library-management-system/tree/java-server" src="img/screenshots/50-demo-app/2-start-app/1-codespace-java.png" alt="Create codespace button" />
33+
34+
</TabItem>
35+
</Tabs>
36+
37+
38+
2339
Let it run for a few seconds as it prepares your environment. It will clone the repository, prepare the containers, and run the installation scripts. Once it's ready, you'll see an IDE, with a preview window that shows the running application.
2440

2541
:::note
@@ -28,6 +44,21 @@ Again, this might take a few minutes. It's a great time to grab a coffee. ☕️
2844

2945
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/2-start-app/2-codespace.png" alt="The codespace" />
3046

47+
:::warning
48+
Right now, you should see a big error message in the console, as we haven't configured the app yet. Don't worry, you'll get it up and running in a few minutes.
49+
50+
```
51+
####### ###### ###### ####### ######
52+
# # # # # # # # #
53+
# # # # # # # # #
54+
##### ###### ###### # # ######
55+
# # # # # # # # #
56+
# # # # # # # # #
57+
####### # # # # ####### # #
58+
```
59+
:::
60+
61+
3162
### Expose the server port
3263

3364
To get the application working in that environment, there is one small change you need to make to the codespace. You need to expose the port where the server is running.
@@ -66,6 +97,9 @@ Then, change to the `library-management-system` directory.
6697
cd library-management-system
6798
```
6899

100+
<Tabs groupId="server">
101+
<TabItem value="node" label="🚀 NodeJS/Express">
102+
69103
Now, go to each of the `client` and `server` directories and install the dependencies.
70104

71105
```bash
@@ -88,4 +122,32 @@ cd client
88122
npm start
89123
```
90124

125+
</TabItem>
126+
127+
<TabItem value="java" label="☕️ Java Spring Boot">
128+
129+
You need to have a local JDK 17+ and Maven installed.
130+
131+
```bash
132+
cd client
133+
npm install
134+
```
135+
136+
Start the server application.
137+
138+
```bash
139+
cd java-server
140+
mvn spring-boot:start
141+
```
142+
143+
And, in another terminal window, start the client application.
144+
145+
```bash
146+
cd client
147+
npm start
148+
```
149+
150+
</TabItem>
151+
</Tabs>
152+
91153
You now have the client running on http://localhost:4200 and the server running on http://localhost:5000.

docs/50-demo-app/3-configure.mdx

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,65 @@
11
import Screenshot from "@site/src/components/Screenshot";
2+
import Tabs from '@theme/Tabs';
3+
import TabItem from '@theme/TabItem';
24

35
# 👐 Configure the Application
46

57
Now that your environment is set up, you can configure the application.
68

7-
There should already be a file open in the IDE. If not, look in the file explorer on the left, and open the file `server/.env`. This file contains the configuration for the application.
9+
There should already be a file open in the IDE. If not, look in the file explorer on the left, and open the file `.env`. This file contains the configuration for the application.
810

9-
The file should look like this:
11+
<Tabs groupId="server">
12+
<TabItem value="node" label="🚀 NodeJS/Express">
1013

11-
```bash
14+
File: `server/.env`
15+
16+
17+
```
1218
PORT=5000
1319
DATABASE_URI="mongodb+srv://user:password@serverurl"
1420
DATABASE_NAME="library"
1521
SECRET="secret"
1622
```
23+
</TabItem>
24+
25+
<TabItem value="java" label="☕️ Java Spring Boot">
26+
27+
File: `/java-server/src/main/resources/.env`
28+
29+
```
30+
DATABASE_NAME=library
31+
# Add here the MongoDB URI of your database cluster
32+
DATABASE_URI=
33+
```
34+
</TabItem>
35+
</Tabs>
36+
37+
38+
1739

1840
You'll need to change the `DATABASE_URI` parameter to match your connection string. That's the same one you used to import the data.
1941

2042
:::tip
2143
Don't remember how to get your connection string? Check out the [Import Data](/docs/importing-data/import-data) section.
2244
:::
2345

24-
Copy and paste your connection string into the `DATABASE_URI` parameter. The file will automatically save, and the server will restart.
46+
Copy and paste your connection string into the `DATABASE_URI` parameter.
47+
48+
<Tabs groupId="server">
49+
<TabItem value="node" label="🚀 NodeJS/Express">
50+
The file will automatically save, and the server will restart.
51+
</TabItem>
52+
53+
<TabItem value="java" label="☕️ Java Spring Boot">
54+
You need to start the server. Click on the terminal window and type:
55+
56+
```shell
57+
$ mvn spring-boot:run
58+
```
59+
60+
</TabItem>
61+
</Tabs>
62+
2563

2664
In the *Terminal* tab at the bottom, look for the `Server is running on port: 5000` line. If you see it, you're good to go!
2765

@@ -36,3 +74,9 @@ In the upper right panel, click the refresh icon to reload the client.
3674
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/3-configure/2-reload.png" alt="The refresh icon" />
3775

3876
Clicking this will reload the client, which should now be connected to the database. You should see the application with some books listed now.
77+
78+
## Open the client in a new window
79+
80+
If you accidentally close the Client or want to open it in a separate tab/window go to the Ports tab, hover over Client and a world icon should appear. Click it and the client will open in a new tab.
81+
82+
<Screenshot url="https://github.com/mongodb-developer/library-management-system" src="img/screenshots/50-demo-app/3-configure/open-client.png" alt="Click to open the client app" />

docs/60-schema-validation/2-validate-users.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
In this exercise, you will explore the pre-written JSON validation schema for the `users` collection, run a script to apply it to the collection, and test the schema validation by inserting a document that does not match the schema.
44

5+
:::info
6+
Note for Java users: schema validation rules are typically applied via a Javascript script! Although there's nothing stopping us to write this code in Java, this is usually a DB Admin task.
7+
:::
8+
59
## Database user permissions
610

711
To update the validator for any database collection, your database user must have admin privileges. Follow these steps to ensure your user has the correct permissions:

docs/70-indexing/1-create-compound-index.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 👐 Build a compound index following the ESR rule
22

3+
:::info
4+
Note for Java users: we will create indexes via a Javascript script! Although there's nothing stopping us to write this code in Java, this is usually a DB Admin task.
5+
:::
6+
37
In this exercise, you will build a compound index following the ESR rule, compare the query explain plans before and after creating the index, and analyze them.
48

59
## Explore the code
Loading
Loading

0 commit comments

Comments
 (0)