Skip to content

web-example-basic is a sample project that intended to help Java developers create basic web application using Java based technologies based on MVC (Model View Controller) concept

Notifications You must be signed in to change notification settings

murtidaryandono/example-web-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Web example basic (to-do application)

Table of contents

  1. Version
  2. Description
  3. Technology stack
  4. Architecture
  5. Flow diagram
  6. Sequence diagram
  7. Database design
  8. API producer
  9. API consumer
  10. Project structure
  11. Development steps
  12. Environment properties
  13. Running application
  14. Tools
  15. Author

1. Version

Date Version Author Changelog
2022-02-07 1.0.0 Murti Daryandono Initial release

2. Description

Web example basic (project : example-web-basic) is a sample project that intended to help Java developers create basic web application using Java based technologies based on MVC (Model View Controller) concept. In this sample project, we will create to-do application with some feature will be provided, such as :

  • Page templating
  • Read environment properties
  • Service class based on business logic to-do list
  • Controller class to handle request and response (show, add, remove & update to-do list)
  • Create UI for to-do list
  • Test application

3. Technology stack


4. Architecture

graph TD
A[Web browser] --- |Request/Response| B[Blade - Web framework]
B --- |Server| C[Netty]
B --- |Template| D[Jetbrick]
B --- |AJAX| H
D --- |Page| H
C --- |JVM| F[Java]
B --- |Logging| G[SL4J]
   subgraph Presentation layer
   H[HTML] --- I[Htmx]
   H --- J[Bulma]
   H --- K[Font Awesome]
   end
Loading

5. Flow diagram

TBD


6. Sequence diagram

  1. Index page

    • Path (GET) : /todo
    • Diagram
      sequenceDiagram
      participant Requestor
      participant Controller
      participant Service
      participant Page
      Requestor ->> Controller : HTTP GET request "/todo"
      Controller ->> Service : Process request
      Service ->> Page : Load index.html
      Page -->> Service : Return index.html
      Service -->> Controller : Process response
      Controller -->> Requestor : Render page
      
      Loading
    • Response
      <!DOCTYPE html>
      <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>To-do list application</title>
        <link href="/static/css/bulma.min.css" rel="stylesheet"/>
        <script src="/static/js/htmx.min.js"></script>
      </head>
      <body>
        <div>
            <table>
                <thead>
                    <tr>
                        ...
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <!-- list of to-do here -->
                    </tr>
                </tbody>
            </table>
        </div>
      </body>
  2. Add to-do item on the list

    • Path (POST) : /todo
    • Query param : todoItem
    • Diagram
      sequenceDiagram
      participant Requestor
      participant Controller
      participant Service
      Requestor ->> Controller : HTTP POST request "/todo"
      Controller ->> Service : Add to-do list (query param "todoItem")
      Service -->> Controller : Return to-do list ("<tr>...</tr>")
      Controller -->> Requestor : Render page
      
      Loading
    • Response
      <tr>
         <!-- to-do list -->
      </tr>
  3. Remove to-do item on the list

    • Path (DELETE) : /todo
    • Query param : todoId
    • Diagram
      sequenceDiagram
      participant Requestor
      participant Controller
      participant Service
      Requestor ->> Controller : HTTP DELETE request "/todo"
      Controller ->> Service : Remove to-do list (query param "todoId")
      Service -->> Controller : Return to-do list ("<tr>...</tr>")
      Controller -->> Requestor : Render page
      
      Loading
    • Response
      <tr>
         <!-- to-do list -->
      </tr>
  4. Update to-do item on the list

    • Path (PUT) : /todo
    • Query param : todoId, todoItem
    • Diagram
      sequenceDiagram
      participant Requestor
      participant Controller
      participant Service
      Requestor ->> Controller : HTTP PATCH request "/todo"
      Controller ->> Service : Update to-do list (query param "todoId, todoItem")
      Service -->> Controller : Return to-do list ("<tr>...</tr>")
      Controller -->> Requestor : Render page
      
      Loading
    • Response
      <tr>
         <!-- to-do list -->
      </tr>

7. Database design

N/A


8. API producer

N/A


9. API Consumer

N/A


10. Project structure

TBD


11. Development steps

TBD


12. Environment properties

Environment File properties
Development application.properties
Staging application-stg.properties
Production application-prd.properties

Contents of environment properties are :

# server configuration
server.port=[port value where your application will run]

# application configuration
mvc.statics=[path to static directory]
mvc.statics.show-list=[true if you want to be show via url]

13. Running application

  • Run in development environment
java -jar target/web-example-basic.jar
  • Run in staging environment
java -jar target/web-example-basic.jar --app.env=stg
  • Run in production environment
java -jar target/web-example-basic.jar --app.env=prd

14. Tools

  • Java 8 as main language
  • Maven as dependency manager
  • IntelliJ as Java IDE (Integrated Development Environemnt)
  • Mermaid as markdown plugin for diagram

15. Author

name : Murti Daryandono
email : murti.daryandono@gmail.com
twitter : murti_d
blog : https://daryandono.id

About

web-example-basic is a sample project that intended to help Java developers create basic web application using Java based technologies based on MVC (Model View Controller) concept

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published