Different front page based on url

I’m working on a project where users can create a book (core functionality). In a simple text field they can connect a domain to this book. This way the book is only accessible via this domain.

For example I have Book A with path node1 and with domain a.book.com. I also have Book B with path node2 and connected to domain b.book.com.

Now with a custom module I set the access to these nodes that Book A is only accessible via a.book.com/node/1 and not via b.book.com/node/1 and vice versa.

What I want now is if a visitor goes to a.book.com the frontpage is node/1.
And if they go to b.book.com the frontpage should be node/2?

I know the Domain Acces module has functionalities like this but I find this module to big and complex for my project.

I want to create a custom module to solve this. Where to start?

Thanks in advance