If your looking for example of how exchanges work you could look at the following projects.
Please not DO NOT USE IN PRODUTION ENVIRO as the code bases may have backdoor's or other holes that may be security issues.
1. Peatio
Was released open source but is no longer being developed it is build on Ruby and Rails which is a change from the usual PHP exchanges out there.
https://github.com/peatio/peatioFeatures :
- Designed as high performance crypto currency exchange.
Built-in high performance matching-engine.
Built-in Proof of Solvency Audit.
Built-in ticket system for customer support.
Usability and scalibility.
Websocket API and high frequency trading support.
Support multiple digital currencies (eg. Bitcoin, Litecoin, Dogecoin etc.).
Easy customization of payment processing for both fiat and digital currencies.
SMS and Google Two-Factor authenticaton.
KYC Verification.
Powerful admin dashboard and management tools.
Highly configurable and extendable.
Industry standard security out of box.
Active community behind.
Free and open-source.
Created and maintained by Peatio open-source group.
2. RubyKube (Fork of Peatio)
RubyKube is a updated version of Peatio build again in the Ruby enviro it's worth a look at this version
https://github.com/rubykubehttps://rubykube.io/3. Binance
Binance have most of there code available online for your to look over.
https://github.com/binance-exchange4. CCXT
A PHP lib for around 110 crypto exchnages worth looking at.
https://github.com/kornrunner/ccxtAs for the DB I think a lot still use MYSQL db thought redis and postgres both are used in the wild.