Skip to content

Connected userCli and SearchCli into App#11

Merged
DennSel merged 1 commit into
mainfrom
features/cli
Jan 12, 2026
Merged

Connected userCli and SearchCli into App#11
DennSel merged 1 commit into
mainfrom
features/cli

Conversation

@DennSel

@DennSel DennSel commented Jan 12, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Application now features a menu-driven interface with login-aware navigation options
    • Structured initialization and termination workflow for improved application stability
  • Improvements

    • Search functionality refined with streamlined menu integration
    • Enhanced user interface labels and prompts for improved clarity

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 12, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The pull request refactors the application architecture to introduce structured initialization and dependency management. It moves from direct EntityManager boilerplate to a centralized startup sequence that constructs UserRepository, UserService, UserCLI, and SearchCli, then runs a persistent application loop. SearchCli is refactored to accept dependencies via constructor rather than managing them internally.

Changes

Cohort / File(s) Change Summary
Application Initialization & Lifecycle
src/main/java/org/example/App.java
Added initialize() method to construct dependencies (UserRepository, UserService, UserCLI, SearchCli). Replaced transactional code boilerplate with application loop that renders login-aware menus. Added terminate() method for cleanup. Introduced appRunning flag and structured startup sequence. Logging suppression for Hibernate added.
Search CLI Refactoring
src/main/java/org/example/SearchCli.java
Refactored to accept Scanner and EntityManager via constructor instead of creating/closing them internally. Extracted interactive flow into public bookSearchCli() method. Updated menu label for back option ("Tillbaka"). EntityManager lifecycle management removed from this class.

Sequence Diagram

sequenceDiagram
    participant App
    participant EMF as EntityManagerFactory
    participant UserRepo as UserRepository
    participant UserSvc as UserService
    participant UserCLI
    participant SearchCli
    participant Scanner

    App->>App: initialize()
    App->>EMF: Create & warmup
    App->>UserRepo: Construct with EntityManager
    App->>UserSvc: Construct with UserRepository
    App->>UserCLI: Construct with dependencies
    App->>SearchCli: Construct with Scanner & EntityManager

    loop appRunning
        App->>App: Render login-aware menu
        App->>Scanner: Read user input
        alt User logged in
            App->>UserCLI: Handle user action
            App->>SearchCli: bookSearchCli()
        else User not logged in
            App->>UserCLI: Show login/register
        end
    end

    App->>App: terminate()
    App->>EMF: Close factory
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #6: Modifies App.java initialization and EntityManager/EntityManagerFactory lifecycle management during startup sequence
  • PR #9: Refactors SearchCli class structure, including constructor changes and search CLI control flow modifications

Poem

🐰 Hop, hop—dependencies align!
From chaos springs a startup design.
Initialize, loop, and terminate with grace,
The CLI finds its proper place!

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2419914 and 33cc626.

📒 Files selected for processing (2)
  • src/main/java/org/example/App.java
  • src/main/java/org/example/SearchCli.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@DennSel
DennSel merged commit 84f6fdf into main Jan 12, 2026
1 of 2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant