Starfleet
Starfleet is the military and exploration branch of the United Federation of Planets. Originally called the United Earth Space Probe Agency (UESPA), Starfleet was formed following Zefram Cochrane's warp flight in 2063. Trade routes became established with peaceful worlds in nearby star systems, and deep space missions followed. In the 23rd century, the USS Enterprise is the Federation's flagship, its crew "the finest in the fleet."

Starfleet is modelled on the United States Navy. Its ships bear the "USS" prefix, and in Kirk's time, American names such as the Constitution and Yorktown. Terms such as bow, stern, and aft refer to different parts of the ship. Ships move ponderously (fitting for outer space as well as the sea), and are armed with torpedoes. Ranks also follow Navy equivalents, primarily: Ensign, Lieutenant, Commander, and Captain.
Kirk and Spock, and nearly all their fellow officers, are immensely dedicated to the Federation and its ideals, especially the Prime Directive. This is a policy of non-interference in developing worlds, derived from enlightened human and Vulcan ideas. Loyalty and duty are valued characteristics in Starfleet officers, to one another and the mission of peaceful exploration for sentient life.
Starfleet Academy, located in the San Francisco Bay area on Earth, near Starfleet Headquarters, is the training centre for young cadets. Kirk sometimes speaks of his "Academy days" with fondness, although accounts differ as to whether he was roguish or bookish. Spock's enrolment in Starfleet Academy was a significant personal decision, in that his father preferred that he attend the Vulcan Science Academy.
In Star Trek: The Original Series, Starfleet is often portrayed as slow-moving and ineffective in realizing its stated ideals. High-ranking officers are either meddling bureaucrats, like Commissioner Ferris in The Galileo Seven and Ambassador Fox in A Taste of Armageddon; or simply crazy, like Commodore Decker in The Doomsday Machine and Captain Tracey in The Omega Glory. With such unreliable people in charge, it's unsurprising that Kirk often takes matters into his own hands. He carries out his interpretation of the Prime Directive numerous times, as in The Apple and A Piece of the Action.
Kirk's insubordination continues after the original 5-year mission, though he willingly remains within Starfleet his entire life. Spock, on the other hand, chooses to leave after the mission, and takes up study on Vulcan. By The Wrath of Khan, Spock has joined Starfleet once again, ranking Captain and training cadets. In The Undiscovered Country, he becomes an ambassador. In Unification, his work in the Romulan underground takes him outside Starfleet.
Starfleet represents both 1960s idealism and "the establishment", which is why Kirk and Spock push and pull against it. In the end, Spock is not content to work within an institutional framework, even one for which he holds great respect.
