Where I would recommend starting is looking through the PostgreSQL code base. It is BSD-licensed, has the features you need, and is well documented/commented. However please keep in mind that each aspect of what you are looking at is a very complex problem.
For example, it's not really possible to use an index to do full text searching of encrypted data. And big issues for full text searching include stemming words (so that if I search for "testing" I also get results for "tester").
To the extent you are able to re-use code, PostgreSQL would also be a good place to start. If you can't, at least looking at the methods for managing on-disk storage, indexing, full text search, etc. may be helpful.
The PostgreSQL site also has documentation introducing the source code's structure and the server's architecture.