It was a flood of Instagram notifications from fans that led actor Charles Melton to pick up the bestselling novel “The Sun Is Also a Star” two years ago.

The notifications came from a post from the book's author, Nicola Yoon, urging readers to share who they thought would make the perfect hero, Daniel Bae, in the film adaptation of her 2016 novel.

“I was tagged by over 200 fan accounts,” Melton said. “That same day I bought the book and I read the story and I just fell in love with the character.”

“The Sun Is Also a Star,” opening May 17, tells the story of a chance encounter between two teens on what is set to be one of the biggest days of their lives. Natasha Kingsley (Yara Shahidi) has learned that unless she can get a legal intervention, her entire family will be forced to leave the United States by Immigration and Customs Enforcement, while Daniel Bae (Melton) is preparing for a college admission interview.

Yara Shahidi as Natasha Kingsley and Charles Melton as Daniel Bae in Warner Bros. Pictures' and Metro Goldwyn Mayer Pictures' romantic drama "The Sun is Also a Star". Atsushi Nishijima

“There were so many different things to connect to,” said Melton of the script, adding that Natasha’s fight to keep her family from being deported to Jamaica struck a chord. “It really gives a body to the face of immigration.”

After the two are suddenly brought together, Daniel convinces Natasha to make the most of their day together by asking her to go through the 36 questions detailed in a popular 2015 New York Times essay that can lead any couple to fall in love. “I thought it was very unique to see someone almost scientifically prove that falling in love was possible,” Melton said.

But as Natasha navigates the immigration system on her own, both characters learn about the struggles thousands go through to remain in the United States. For Melton, working on the film was also a moment to learn about the lives of undocumented teens and their families.

Though his character does not have to worry about his immigration status, he does have his own internal struggle about his desires versus family expectations. Audiences learn that Daniel wants to break away from the path that was laid out for him from birth of becoming a doctor.

“He’s dealing with the pressures around him. How much is he willing to compromise on as far as what his parents want him to become?” Melton said. “He’s a hopeless romantic, and he has his own passions.”

Melton, 28, isn’t a stranger to that pursuit of passion either: A former athlete turned model turned actor, he has been building up his acting credits since he moved to Los Angeles in 2012, beginning with a small appearance on “Glee.” He later joined the CW’s “Riverdale” in 2017, taking over the role of Reggie Mantle in season 2 from actor Ross Butler.

“The Sun Is Also a Star” is Melton’s first feature film, but it is also special because he got to share the screen briefly with someone close to him: Near the beginning of the film, Daniel is delayed on the subway in a car filled with people as they listen to the conductor explain the delay and the role of fate.

“A lot of people don’t know that my mom’s in that scene,” Melton said. “She’s one of the frustrated commuters. She looks at her FitBit and huffs and puffs and looks around. That was really amazing to see.”

While Melton prepares for season 4 of “Riverdale,” he hopes to carry the lessons of fate, chance and love that he learned on “The Sun Is Also a Star” with him.

“I think you just need to stay open. Things can either make sense in the moment or they can make sense a week from now or two weeks from now,” he said. “You just have to trust the process and be open.”

Follow NBC Asian America on Facebook, Twitter, Instagram and Tumblr.