There is state law and federal law, both can have minimum mandatory sentencing, but beyond that there is usually room for judges discretion as every case is different and there are often mitigating factors. There is also case law ( precedents ) and the accused can have a bench trial ( judge decides ) or a jury trial.
Another note is for federal criminal cases, a grand jury decides whether to indict a person, while in state criminal cases, the prosecutor or District Attorney decides whether to proceed with charges, though some states still use grand juries for some kinds of cases.
That said we have always had a 2 tier justice system, not by design, but in effect, due to financial ability to hire quality representation, a good lawyer is worth his weight in salt as they say, knowledge of case law can be a big factor and knowing how the system works, such as what not to say and what your defendants rights are can make a huge difference.
Also due to politics a person can get a very different sentence in a liberal state than a conservative state and much depending on the type of crime and how it's viewed politically.
Also there plea bargains, negotiated sentences, ect.... such as someone offering to plea to a lesser charge, this is best done through your attorney, so a poor person will get a longer sentence because they can't afford a good lawyer, happens all the time.
As for the laws that lay out what the minimum mandatory sentences will be, that is done through the congress ( house and senate ) and signed into law by the President, In the case of state laws they are passed in the state congress which has it's own house and senate and signed into law by the state Governor.
They are all limited by our Constitution and by judgements by the SCOTUS, so if SCOTUS rules that purple napper dazzlers are in common use and thus constitutionally legal to own, then no state nor the federal government can make any laws banning them.
----------------------
Now if you are charged by a state agency/police you typically go to state court, but if charged by a federal agency or the DOJ then federal court.
This is what happened to Trump during the election, the federal DOJ refused to charge Trump as they saw no crime, but New York DA Alvin Bragg who ran for office on " I WILL GET TRUMP " charged Trump with a past the statute of limitations state book keeping law a misdemeanor and using a " novel legal theory " bootstrapped it into 34 felonies by saying his bookkeeping violation ( recording a perfectly legal NDA payment to Stormy Dainels ) as a business expense rather than a campaign expense was also an act of..... get this..... election interference.
So every letter sent to Dainels, every check sent, every thing they could was charged as related became felony charge of election interference connected to a simple book keeping violation and somehow the jury bought it............
The democrats national Trump Hatred psy opp just might have had something to do with this mostly democrat jury buying the novel legal theory.
Bragg was supposed to select a judge randomly from the local pool, but instead brought in Judge Merchan special who's daughter ran a democrat org. that took in millions when Bragg charged Trump..... Merchan was conflicted.
Tumps rights were denied and he was refused a change of venue even though the jury pool was mostly democrats, some said they hated Trump.
Trump was also gagged by Merchan during his reelection, that was election interference by the state as was the entire kangaroo court perversion of justice.
--------------------
Bottom line is democrats cheat, they " fortify " elections, they use political activist judges to attack Presidential power and now they have opened the pandora's box of political lawfare.
They also lie constantly, accuse others of what they are doing and try to change the meanings of words when the laws don't suit their agenda, then change them back when it does..... democrats are liars, cheaters and monumental hypocrites.
Obama did so much damage to our alphabet agencies and attempted to legislate by having alphabet agencies change existing statutes that carry the weight of law, in effect creating new laws without a vote of congress, thankfully Chevron deference has been ended.