The Cinema Service Application is designed to manage movie schedules, pricing, and ratings for a cinema specializing in the Fast & Furious franchise. It integrates with the IMDb API to fetch movie details and provides a RESTful interface for managing and retrieving cinema data.
- Java 17+
- Gradle
./gradlew bootRun --args='--imdb.api.apiKey=IMDB_API_KEY'./gradlew test- H2 Console: http://localhost:8080/h2-console
- Swagger: http://localhost:8080/swagger-ui/index.html
- JDBC URL:
jdbc:h2:mem:cinema-db - Username:
sa - Password: (leave blank)
- Flyway ensures the database schema is versioned and consistent. Migration scripts are located in:
- Runs every commit pushed to main branch and pull requests to main branch
- Movie Catalog Management
- Internal endpoints for updating showtimes and prices.
- Support for assigning different prices to the same movie based on showtimes.
- Movie Ratings
- Customers can submit ratings (1-5 stars) for movies they have watched.
- IMDb API Integration
- Fetches movie details:
- Name
- Description
- Release date
- IMDb rating
- Runtime
- Fetches movie details:
- Placeholder Authentication
- A dummy authentication interface is implemented for testing purposes.
- H2 Database
- An in-memory database is used for local development and testing.
- Flyway Integration
- Database schema management is handled using Flyway for consistent migrations across environments.
- A placeholder for authentication is provided, returning dummy user data.
- Future implementations should adhere to specific authentication and authorization requirements.
/self/movies: This endpoint should be secured with roles or permissions to restrict access./movies/{movieId}/addMovieRating: This endpoint should ensure that only authenticated users with valid accounts can add ratings.
- Results from the IMDb API are not cached in this implementation.
- Add caching to improve performance and reduce external API calls, as movie details are unlikely to change frequently.
- The design assumes that each showtime can have a different ticket price.
- This allows cinemas to set higher prices for peak hours while offering discounts during off-peak times.
- Exception handling is minimal in this version.
- Implement proper exception handling to ensure consistent, meaningful error responses.
- The application uses an in-memory H2 database for local testing.
- Flyway is used to manage schema versions and initial data setup.
- No automatic mapping libraries (e.g., MapStruct) are used.
- Manual mapping is implemented for greater control over the transformation process.
- Implement proper authentication and authorization mechanisms.
- Secure endpoints with role-based access control.
- Improve caching for IMDb API responses in ImdbMovieRepository.
- Improve error handling with a consistent exception response mechanism.
- Explore the use of mapping libraries for reducing boilerplate while maintaining control.
- Add environment profiles for better managing env variables
- Add TestContainers in tests
- Improve CI/CD pipeline
- Better env variables management (eg. via aws secret manager)
Although the current database relies on blocking queries, I chose to use suspend functions and coroutines to future-proof the system:
- If we switch to a non-blocking database (e.g., R2DBC) in the future, the architecture will already be compatible. This minimizes the effort required to implement such changes.
- Coroutines allow asynchronous operations to be written in a style that looks like synchronous code, making it easier to read, understand, and maintain.
- Other parts of the system, like external API integrations (e.g., using WebClient), already use non-blocking approaches. Coroutines ensure a consistent architectural style across the application.
This approach ensures flexibility, scalability, and prepares the system for modern, non-blocking technologies without compromising the current implementation.