Giter VIP home page Giter VIP logo

rahulaggarwal1016 / bookyard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sathyaish/bookyard

0.0 0.0 0.0 7.12 MB

Bookyard is a trivial client/server application written in the Kotlin programmming language. The user interface displays a list of book recommendations for a logged in user, based on his likes. It is written with the purpose of illustrating how to write a simple application using the Kotlin programming language and then how to secure it using Json Web Tokens (JWT's).

Java 51.41% HTML 0.12% Kotlin 48.47%

bookyard's Introduction

What is Bookyard?

Bookyard is a trivial client/server application written in the Kotlin programmming language. It is written with the purpose of illustrating how to write a simple application using the Kotlin programming language and then how to secure it using Json Web Tokens (JWT's).

What does it do?

The application is meant to return a list of book recommendations for a logged in user, based on his likes. All the data comes from a database server.

What kind of a client and server does Bookyard have?

The application has two parts:

  1. A desktop application; and
  2. A web application that acts as a Web API. The endpoints return Json responses. The web application gets data from a database.

What are the modules in the project and what do they do?

  1. Server: Embodies the HTTP Servlet API and its helper classes.
  2. Client: Embodies the Swing desktop application.
  3. Contracts : Embodies the types used to send and receive data between the client and the server.

What technologies did you use to develop this application?

I am a C# developer so all of this was new to me. In order to localize complexity, I first learnt the Kotlin language over a week or so, then wrote a few trivial programs with it of the order of adding the elements of an array or using companion objects, object declarations, property setters and getters, read-only properties, and the like. Then, I wrote the application in Java first, and then translated each line in Kotlin to arrive at the Kotlin implementation.

The source code for the Java application is in the folder named Java at the project root. The Kotlin folder has the same application written in Kotlin. The db folder has the database script. If you want to run the application, you'll need to feed this database script to a Microsoft SQL Server database.

I wrote the Java version using the Eclipse for Java EE, Mars 2 IDE. With the exception of this, everything else I used to write the Java version was the same as that I used to write the Kotlin version.

Here is a list of tools I used to develop the Kotlin version of this application:

  1. The desktop application is built using the Swing/AWT API (java.swing.*, java.awt.*).
  2. The web application is built using HTTP Servlets (javax.servlets .http.*)
  3. The application server is Apache Tomcat 8.0.x
  4. The database used is Microsoft SQL Server 2012.
  5. JDBC is used for database connectivity.
  6. The programming language is Kotlin.
  7. The IDE used is IntelliJ IDEA Ultimate Edition. I tried building this with Eclipse first. Though there is a Kotlin plug-in for Eclipse, the experience building with that plug-in is not that great. That's because there is little to no intellisense available for Kotlin when using the Eclipse plug-in. And the compilation / build process does not output the .class files to a location that you as a developer know about. It publishes the .class files to an internal folder it uses, which is no good because then you can't set that path as the %CLASSPATH% because you don't know where that location is.
  8. The endpoints on the server return Json responses. The Jackson library is used for serializing and deserializing objects into json string and vice-versa.
  9. The jwtk/jjwt library is used for building and parsing Json Web Tokens (JWT's).

What is the workflow? In other words, what screen appears first and then what button do we click and then what other screen appears, and so on?

The client application provides a login dialog box. The user logs in with the user name Sathyaish and password FooBar.

Since this application was written to illustrate the use of the Kotlin programming language only, its features have been kept to a bare minimum. There is no way to create a new user.

Bookyard login dialog

Upon successful login, the login dialog disappears and a window displaying a list of books recommended for the user based on their likes appears.

Bookyard Recommendations Window

How does it work?

The client application makes a secured Web request, i.e. an HTTPS POST request to the server at the end-point /login. The client packages the user name and password in a Json Web Token (JWT) that is signed with the client's application secret.

In response to a login request, the server send back a Json string with the following object structure (pseudo-code):

OperationResult<User> where:

class User
  public int id;
  public string userName;
  
class OperationResult<T>
  public bool successful;
  public String? errorMessage;
  public T? data;

To be contd...

Known Issues: What are the incomplete or buggy features in this application known to you?

The application was built to facilitate an article that was meant to teach the reader how to develop a secured application using Kotlin. Therefore, in the interest of time, the following compromises were made in feature completion and omission. This list is usually referred to as known issues in software development:

  1. The size of the login dialog box is not fixed, and is a bit awkward.
  2. Book recommendations window needs a scrollbar
  3. Not all text on the book recommedations window is properly visible. The height of the text is less than what is should be.
  4. No way to register a new user.
  5. No way to allow an existing user to change his password.
  6. No way for an existing user to request a password reset in case they forget their password.
  7. No way for a client application to register with the server.

What problems did you face when developing this application?

Being a C# developer, I faced a lot of problems at each step during development. I'd done a bit of Visual J++ back in 1999. That's the Microsoft version of Java, and was also a bit familiar with the Java language. And it was easy to pick up the Kotlin language as well.

Languages are easy. It's the tools and the variety of frameworks and their quirky behavior that takes all of the time and frustration. For instance, learning about the layouts in Swing, or aligning child elements horizontally or vertically within a graphical user interface container, or getting the Java class from a Kotlin KClass, or finding out how to set the %CLASSPATH% or how to set static references to JAR files with each IDE, or how to use an open source Java project that had no JAR files, how to make JAR files from Java source, how to use Maven, etc. These things took me all the time that I took to develop this.

Here is a list of some problems I faced during development, with the solutions:

  1. Could you please explain this piece of code in terms of C# code?
  2. What exactly is a dense array?
  3. Can a covariant type parameter be in an input position in the constructor?
  4. How to create a Java Servlet application in IntelliJ IDEA Community Edition with Java EE 7 and Glassfish 4?
  5. How to create a servlet using Eclipse Version: Mars.1 Release (4.5.1)?
  6. Some questions from a .NET developer about running Java programs in Eclipse
  7. How to have Eclipse intellisense autocomplete member names?
  8. Why don't you have to add an import statement for the java.lang.Runnable interface?
  9. How to rename a variable in Eclipse JEE Mars 2?
  10. What does the percentage sign next to some of the intellisense members in Eclipse mean?
  11. Do JFrame windows in Swing run on their own separate threads?
  12. Doesn't using an anonymous class to add an action listener cause a memory leak?
  13. How do I close a JDialog with the behavior I want?
  14. How do I left align a JLabel inside a JPanel?
  15. What do I have to do to use an external open source library in my Java project?
  16. How do I reference one Eclipse project from another?
  17. How to set up Apache Tomcat 8 to run a servlet application on HTTPS
  18. Unable to connect to SQL Server via JDBC. No suitable driver found for jdbc:sqlserver://
  19. How do I get back my .class files?
  20. java.lang.NoClassDefFoundError for a class within a referenced project
  21. Where in Eclipse do I see a project's build progress?
  22. How to set Run Configuration and Debug Configuration in Eclipse to choose the class that has the main method as the start-up class?
  23. Select matching rows from a table where either one of two columns contain any value from a list of values
  24. Conversion of java.util.Date to java.sql.Date truncates the time part
  25. How to set just the left coordinates and the width of a JPanel?
  26. Does Kotlin provide any implementations of its collection interfaces?
  27. Convert a nullable type to its non-nullable type?
  28. What's the correct syntax for overriding an interface member function with a visibility modifier?
  29. Apache Tomcat 8.0 unable to load servlet class written in Kotlin using Eclipse for Java EE, Mars 2
  30. Where are the .class files?
  31. How do I tell Eclipse to compile my Kotlin source files into .class files without using an external build tool?
  32. Error running an Apache Tomcat servlet written in Kotlin
  33. How to select a different module to run when you click the Run button in IntelliJ IDEA?
  34. What compile-time type must I assign to receieve a return value of java.util.Map<TextAttribute, ?>
  35. How do I get the class name from a type name?

What do I need as a set-up to run this code if I download it?

How do I launch the application?

How can I reach you?

If you find any errors in this application other than the ones listed in the Known Issues section of this document, or you need help setting this application up in your environment, please create a new issue in this repository. If you would like to hire me, please reach me at [email protected].

bookyard's People

Contributors

sathyaish avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.