Skip to content

dbenusov/CollisionMapper

 
 

Repository files navigation

Collision Mapper

An application continuum style application using Kotlin and Ktor that includes a single web application with two background workers.

The web server will display on a map the top 10 most dangerous intersections based on number of accidents.

Applications:

  • Basic web application
  • Data analyzer
  • Data collector

Technology stack

This codebase is written in a language called Kotlin that is able to run on the JVM with full Java compatibility. It uses the Ktor web framework, and runs on the Netty web server. HTML templates are written using Freemarker. The codebase is tested with JUnit and uses Gradle to build a jarfile.

Docker is used to run the applications and host the databases. Please download Docker and sign in before executing the steps below.

One docker image is built that contains all three applications, but, each application will have its own running container. There is also a postgres container for production, and for local testing a testing database.

Set up

  1. Make sure Docker is installed and running on your machine. Remember to log in!

  2. Clean-up all Docker containers and data. Starting with a clean slate is good!

    docker-compose down --volumes 
  3. Build the applications to place into the Docker container.

    ./gradlew clean build -x test
  4. Build the Docker container.

    docker build . --file Dockerfile --tag collision-mapper
  5. Run docker-compose. This will start all three applications, the databases needed for producation/testing, and perform the needed migrations. It is very important that you wait at least a minute for all of the applications to start running before starting the system tests.

    docker-compose up

    The applications need to wait for the database container to issue a health report before starting. This takes about 30 seconds, please be patient before attempting to access the data pages.

  6. PLEASE WAIT TO RUN THIS, THE DATABASE MUST BE READY. Check the Docker logs and verify the database is accepting connections. Runs the system tests.

    ./gradlew build
  7. Verification of data storage. Open a web browser to

     http://127.0.0.1:8886/view-data
    

    Observe the list of stored elements! If nothing appears please wait a minute or so and refresh the page. Check the Docker logs and make sure that the collector/analyzer have finished processing their data batches.

  8. To view the collision map go to the url below. The red circles are collision hotspots. Click on one to see the number of collisions in that area! Zoom in and out to see the collisions change depending on your view.

     http://127.0.0.1:8888/
    
  9. To view the server metrics go to the curl below. Be sure to execute some queries in the search bar. By default, nothing is displayed! In the target tab you will see the servers being monitored. In the graph tab you can view the scraped data, just make sure to execute a query in the search bar! A good thing to query is requests, which shows the number of requests made to the basic-server API that returns the circle locations. Type requests into the search bar and press execute to see the data! Trying panning around the screen in the map for a while and see it affect the returned values.

     http://127.0.0.1:9090/
    
  10. Clean-up all Docker containers and data.

    docker-compose down --volumes 

The End!

About

kotlin-ktor-starter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 62.0%
  • CSS 25.8%
  • FreeMarker 5.1%
  • JavaScript 4.1%
  • HTML 1.7%
  • Dockerfile 0.9%
  • Shell 0.4%