Skip to content

crocy/srcMoviesAndActors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Demo Project

Your final product should be a backend application for movies and actors management via REST API, described in details in the following sections. Keep in mind that application can be used by multiple clients at the same time and all data needs to be persisted somewhere (H2 database will be ok). UI is not part of this demo project.

Tasks

  • implement HTTP cache mechanisms where is needed
  • implement request counter for all REST calls
  • protect services with modern authorization mechanisms
  • implement movies and actor services as at least two independent deployable services
  • support the ability to handle a large number of HTTP GET requests.
  • provide (or describe) mechanism how database objects can be initialized
  • dockerize services
  • provide docker compose file

Movies

Movies have properties as title, year, description, list of actors, some pictures, etc. (as identifier use imdbID).

Implement REST operations to support basic UI requirements:

  • list all movies
  • list movies with pagination support
  • search of movie
  • CRUD operations

Actors

Actors have properties as first name, last name, born date, list of movies, etc.

Implement REST operations to support basic UI requirements:

  • list all actors
  • list actors with pagination support
  • CRUD operations

How to run

Via script

To run the demo (on Linux), run the build_and_run.sh script from the project's root folder

./build_and_run.sh

If you can't run the script, give it execute permissions first (and then rerun it):

chmod +x build_and_run.sh

Manually

The Actor and the Movies service can be run manually from the project's root by running:

(cd actors && ./gradlew bootRun)
(cd movies && ./gradlew bootRun)

URLs

Actors

Login credentials:

  • Username: actors
  • Password: actors

HTTP request:

Movies

Login credentials:

  • Username: movies
  • Password: movies

HTTP request:

Metrics

A lot of various metrics are available on the actuator URL:

Some metrics, such as server requests counts, are available on /actuator/metrics/http.server.requests URLs.

Note that some URLs might not be available if a request for that URL hasn't been made yet.

Movies service

List of all received HTTP server requests: http://localhost:8080/actuator/metrics/http.server.requests

More URLs:

Actors service

List of all received HTTP server requests: http://localhost:8081/actuator/metrics/http.server.requests

More URLs:

Caching

Server side caches can be checked via the /actuator/caches URL.

Testing

Tests can be run by running the following commands from the project's root:

(cd actors && ./gradlew test)
(cd movies && ./gradlew test)

Or for more info:

(cd actors && ./gradlew test -i | grep -E -v "^Executing |^Creating |^Parsing |^Using |^Merging |^Download |^title=Compiling|^AAPT|^future=|^task=|:app:|V/InstrumentationResultParser:")
(cd movies && ./gradlew test -i | grep -E -v "^Executing |^Creating |^Parsing |^Using |^Merging |^Download |^title=Compiling|^AAPT|^future=|^task=|:app:|V/InstrumentationResultParser:")

Improvements

  • Use more secure login credentials for the DB and the app (quick/test ones were used).
  • Actuator endpoints could be narrowed down to just the /actuator/metrics URL to prevent excess data exposure (as a security measure).
  • Lombok's @Data annotation could be replaced with Java's record class.
  • Add more logs to see what's going on in the apps.
  • Move common logic to a common lib and introduce some abstraction layers!
  • CSRF shouldn't be disabled in a production environment (it's disabled for easier testing).
  • If needed, cache headers could be added to HTTP request responses as well.
  • Different profiles could be used for testing, dev and prod environments.
  • Better code documentation.
  • Stricter DB schema (defined in the code) by using @Column(nullable = false) and similar annotations.
  • Better tests, covering various failures like invalid input data and covering the data layer as well.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published