Allison Leotta is a former federal prosecutor who specialized in sex crimes. Now she is a full-time novelist who draws on her experiences to infect her writing with a gritty realism in a genre not exactly known for hewing to the laws of literary gravity.

She wrote “Laws of Attraction,” her first legal thriller before heading to court, on weekends and late at night. After having her first child, she dutifully wrote during naps and breaks in parenting. When her publisher asked her to write two more books, she gave up prosecuting to become a writer. Her second book, “Discretion,” was published Tuesday.

Over e-mail, I queried Allison about her time in the District’s U.S. Attorney’s Office, her new book, what compelled her to leave the courtroom and how her former job informs her current one.

You were a Harvard law grad and a federal prosecutor in the District, handling an assortment of crimes from misdemeanors to sexual assaults. What made you try your hand at writing crime fiction? And then take the leap to try it full-time? Do you miss being a prosecutor?

Every day in the U.S. Attorney’s office was fascinating. As a prosecutor, I was immersed in the extremes of human behavior: incredible evil and heartbreaking tragedies, but also great courage and heroism, and moments of pure absurdity. My colleagues and I would often say, “Someone needs to put this in a book.”

When I got pregnant, a weird sort of biological clock went off. I realized that if I was ever going to write that novel, I had to do it now. So I started writing every morning for a couple of hours before work. I wove those fascinating real-life details into the plot of my first book, “Law of Attraction.” It turned out to be a fun and therapeutic way to process what I saw in the courthouse.

I do miss the U.S. Attorney’s Office. I loved my job and intended to keep working there. But when Simon & Schuster asked me to write two more novels, I knew I couldn’t do that, raise my children, and continue as a prosecutor. I decided to focus on writing, and resigned from the USAO last June.

But my love of the job comes through in my stories. It’s incredibly fulfilling to put together a criminal case, help protect your community from predators, and achieve some measure of justice and healing for survivors. I hope “Discretion” will inspire other lawyers to become prosecutors.

Discretion is the second in your Anna Curtis series, which focuses on the life/actions of a young female prosecutor. You obviously drew from your experience in this realm to write the books. But what made you want to continue the series? Why not try something fresh?

I was surprised and thrilled by the reception “Law of Attraction” got from readers and reviewers. They wanted more. I’ve had plenty of judges put a word limit on my briefs, but never before had I been asked to write a sequel! I’m really happy to be writing for such an enthusiastic audience.

Do you get any grief from your old pals in the U.S. Attorneys Office for revealing too many secrets — even if in fiction — like trade secrets, investigative techniques? Did you have to seek guidance from any prosecutors in writing this on technical aspects of the law or investigations that you might not have known about?

I get grief about my sex scenes. I didn’t seek out any guidance in writing them, though I’ve had some volunteers.

I have consulted with colleagues about legal questions and investigative techniques. I’m lucky that my friends constitute a living encyclopedia of law enforcement knowledge. If I want to know anything about trying a homicide case, I call up Glenn Kirschner, the former homicide chief. If I want to know the best way to organize direct-exam questions for a man who’s an escort agency “tester” – testing applicants’ bedroom skills – I call up Kate Connelly, who tried the DC Madam case and whose direct exam of such a “tester” is a matter of public record.

The research is one of the best parts of being a writer. The writing itself can be lonely. Perhaps I included a lot of authentic details in “Discretion” just to have an excuse to call my friends and chat.

Your books involve tangled relationships. Your first book, Law of Attraction, has a complicated love triangle involving Curtis, a public defender and another prosecutor. You are married to a former prosecutor who specialized in public integrity investigations! Is he reading these drafts before they are published? And what is his reaction? Would the Justice Department ever allow a prosecutor to try a case against her boyfriend? As a former prosecutor, can you be investigated by the Justice Department’s Office of Professional Responsibility for just suggesting this?

Ha! I hope not!

My husband, Michael Leotta, does read the drafts; he’s the first person who reads anything I write, and he’s my most important critic. He used to be the Appellate Chief at the Maryland U.S. Attorney’s Office, so he’s very skilled at editing all kinds of writing.

I don’t think the Justice Department would let a prosecutor try a case against her public-defender boyfriend. That’s why Anna (my protagonist) keeps the relationship secret, and part of what made it so fun for me to write. Anna can get away with all sorts of things I would never do. Or, even if she doesn’t get away with them, it’s her fictional bar license on the line, not my real one.

DOJ ethics attorneys did have to vet “Law of Attraction” before I could sell it. They made sure I wasn’t divulging state secrets or violating rules of professional responsibility. They didn’t touch the racy parts of the story. But knowing they’d read them made for some awkward elevator rides.

Now that I’ve resigned, DOJ officials aren’t legally obligated to read “Discretion.” But I hope they will want to!

In “Discretion,” you not only delve into prostitution -- the murder victim (every mystery needs to start with a body) is a call girl tossed from a balcony at the U.S. Capitol and an investigative target is a member of Congress. But you also get into the Speech or Debate clause. Is this the first time a novelist has ever combined prostitution, murder, and the incredibly unsexy Speech or Debate clause? Did you have to visit the law library to get that stuff right? And did you ever investigate a prostitution case like this?

Poor Speech or Debate clause, I won’t tell it you said that.

It may not be sexy, but it’s fascinating to me that courts have interpreted the Constitution to protect congressmen to this extreme. You remember the case where the FBI found $90,000 in bribe money in a congressman’s freezer? He might have gotten away with it if he’d kept the cash on the desk of his Capitol office!

“Discretion” starts with an escort being murdered in a congressman’s Capitol hideaway. The police want a closer look, of course, but the congressman won’t let them inside, asserting his rights under the clause. I’m not aware of a real case, or another book, in which this happened.

I’ve prosecuted dozens of cases involving prostitutes who were sexually assaulted, and in writing “Discretion,” I was inspired by the DC Madam case, but this novel isn’t based on any one real case. The great thing about fiction is that I can weave together the best details from a lot of real cases to make the most interesting story.

Del on Twitter: @delwilber