Building large scale applications with Jooby


Jooby a modular micro framework

Overview

Jooby is a modular micro-framework for building web applications in Java and Kotlin. If this is first time you heard about Jooby? Checkout my previous article on why you should choose Jooby.

Micro-frameworks are ideal for building small applications, but are they good for medium or complex applications?

In this article we’ll learn what options Jooby offers to build large scale web applications and keep the source code organized and maintainable.

Initial application development

Let’s say you want to build a HTTP API for users. An initial application might looks like:

https://medium.com/media/414a444f81c89dffdb08322caf93b7cc/href

Done! Your application is ready. It looks clean and easy to understand. Simplicity is one the Jooby goals.

Large scale application development

Suppose you want to extend your application with:

  • A HTTP API for blogs.
  • A HTTP API for comments.
  • UI for users, blogs and comments.

We can keep what we did before and extend the number of lines in our App.java. It is perfectly fine to do that, after all you own the application 🙂

But what if you want to better organize your source code? How can you? This is missing feature for most micro-frameworks but not in Jooby.

Jooby provides some features and patterns that let you compose and organize your application.

MVC routes (a.k.a. Controller)

This is well-known pattern in Java frameworks were you annotated methods and make them accessible via HTTP:

https://medium.com/media/e3237e64ff1f3a220bc32123baa4b9cb/href

We can replace the script routes with our new controller so now our application looks like:

https://medium.com/media/d827b063f161f9573d05c98a8f39d81a/href

You can apply the same pattern for blogs, comments and UI controllers:

https://medium.com/media/ef03785f106a91d93a808421a1cc9049/href

This is how you usually split an application into multiple components using controller classes and annotations.

Wouldn’t be nice if we can keep the script routes and keep source code organized?

Embedded applications

This pattern let you compose one or more applications into one big application.

It’s perfect if you love script routes and want to keep them organized.

We split our application into 4 components, like we did before with controllers. But this time each component is an application by itself:

https://medium.com/media/ce335d12bff9c38a0ec13945105985ea/href

Time to embedded it as we as we did in the controller example:

https://medium.com/media/834b810b6efd329297d745d593df99b4/href

This approach let you build standalone applications that can be easily embedded into a major application.

Conclusion

In this article we illustrated how to build large scale applications with Jooby using MVC or script routes.

Some users prefer MVC routes over script routes, but the truth is that you can use both or mix them together. Jooby just make sure to give you the right tools. Like always, decision is yours.

That’s all for now. Thank you for reading! If you are not yet convinced about Jooby here is nice article on why you should give it a try:


Building large scale applications with Jooby was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.

Comments

comments

What's Your Reaction?

hate hate
0
hate
confused confused
0
confused
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
lol lol
0
lol
omg omg
0
omg
win win
0
win

Building large scale applications with Jooby

log in

Captcha!
Don't have an account?
sign up

reset password

Back to
log in

sign up

Captcha!
Back to
log in
Open

Close
Choose A Format
Personality quiz
Trivia quiz
Poll
Story
List
Open List
Ranked List
Meme
Video
Audio
Image