A personal POC to implement a basic stock exchange architecture. Tooling wise, the following tools were used
- Kafka: Event driven asynchronous processing and messaging
- FastAPI/Guvicorn: Web API
- Redis: Caching and Zset for sorted items
- MongoDB: General data persistence*
*This is now being converted to MariaDB. Upon further analysis of the use cases, stronger ACID reliability is preferred over the data flexibility and distributed scability that NoSQL offers. That said, if MySQL is good enough for Facebook, it's good enough for a stock exchange
The primarily role of this project will be to see how well asyncio driven python processes, which excel large numbers of small I/O operations, are able to process millions of I/O bound transactions in a short amount of time in a humble docker compose deployment
It also just sounded like a neat thing to slap together. There will be no sensitive data used by this application
- Convert MongoDB to MariaDB
- Implement User Ledger and Account Service
- Implement User Order Service
- Exclusion of user ability to have simultaneous buy and sell orders for the same stock
- Implement Proper Exchange of stocks and account balances in Order Fulfillment Service
- Order Lifecycle introspection and record logging
- Implement ability for a user to request "all or nothing" batch transactions instead of streamed fulfillment
- Nginx proxy in front of all uvicorn hosted localhost web servers
- Front End UI for basic order/user account balance
In order to get started with the provided configuration, docker must be installed, as well as docker-compose. Beyond that, all one needs is to execute the following command
docker-compose up
From then on you may access The Fast API Documentation, available on localhost, to get started