https://starbounder.org/LoreYou can find Codex's all over the place in game. NPC villages have quite a lot of them I've found. You can also find them in dungeons, and other biomes. They are usually in bookcases, but can also be found in chests and other containers. The first one I found I believe was in the main story mission where you have to go to the Erchius Mining Facility to get the parts to repair your ship. This area has a few Codices that tell you what happen in the Mine.
Simply pick one up, use it, and its contents will be added to your Codex Library, and this will unlock.