Justice is defined as each part doing its proper function
Rather than defining justice as obeying laws or keeping promises, definitions offered early in the dialogue and quickly complicated, Plato's Socrates argues that justice is a kind of structural harmony: it exists when each part of a whole, whether a city or a soul, performs the function it is naturally suited for and does not overstep into another part's role.
In the city, this means rulers govern, soldiers defend, and producers produce, each class doing its proper work without interfering in the others. In the soul, Plato argues for a threefold division, reason, spirit, and appetite, and claims justice is achieved when reason rules, spirit supports reason's authority, and appetite is kept in its proper, subordinate place rather than seizing control.
This definition reframes justice from something imposed externally, a rule you follow to avoid punishment, into something like psychological and social health, an internal order that is good for its own sake regardless of external reward.
Takeaway: for Plato, justice is less a rule you follow than a condition you're in.