DEV Community

Roberto de Vargas Neto
Roberto de Vargas Neto

Posted on • Edited on

Series Roadmap: Building a Stock Brokerage Simulator with Microservices

Welcome to the official index for the My Broker B3 series. This post serves as a central hub where I organize all the articles about this financial ecosystem's development in the ideal reading order.

This project is a hands-on lab where I apply software engineering, distributed systems, and messaging to simulate the integration between a Brokerage and the Stock Exchange.


🚀 Series Articles

  1. Project Overview

    • Introduction to the My Broker B3 project: a microservices ecosystem POC simulating a brokerage integrated with B3. Overview of 9 services, communication strategy (REST, Kafka, RabbitMQ), persistence decisions (MySQL, PostgreSQL, MongoDB, Redis) and the complete end-to-end order flow.
  2. Infrastructure with Docker Compose

    • How to bring up 12 containers with a single command using Docker Compose: domain data isolation with multiple MySQL instances, PostgreSQL, two independent Redis, MongoDB, Kafka in KRaft mode, RabbitMQ and observability with Prometheus + Grafana from day one.
  3. Market Data: The Python, MongoDB, and Kafka Integrator

    • The real B3 data ingester: Python service that fetches quotes for 50 assets from the Brapi API every 30 minutes, persists history in MongoDB and publishes events to Kafka. Decisions on scheduling, rate limiting, per-run Kafka producer and token protection.
  4. Tooling Tips: MongoDB Compass and Offset Explorer

    • Essential tools for visualizing data in an asynchronous pipeline: MongoDB Compass for inspecting collections, Offset Explorer for seeing Kafka messages in real time and RabbitMQ Management UI for monitoring queues and exchanges.
  5. From Stream to Database: Processing Market Data with Spring Boot, Redis, and Flyway

    • From stream to database: Spring Boot service that consumes quotes from Kafka, upserts to MySQL with Flyway and maintains a Redis cache with TTL. Decisions on real market timestamp, JPA status filter queries and why to rethrow exceptions in the Kafka consumer.
  6. Syncing the Real Market: Consuming Brapi and Feeding Redis with Spring Boot

    • Syncing real Brapi prices to Redis with Spring Boot: scheduler with trading hours guard using explicit ZonedDateTime, custom deserializer for Unix epoch timestamps, 5-minute TTL and REST endpoint for cache observability.
  7. The Heart of B3: Building the Matching Engine with RabbitMQ, Redis and Spring Boot

    • The execution engine that simulates B3: consumes orders via RabbitMQ, looks up the current price in Redis to decide between FILLED and REJECTED, persists the result in PostgreSQL with transactional guarantee and returns feedback to the broker — including Dead Letter Queue for failed messages.
  8. Financial Custody: Managing Balance and Portfolio with Eventual Consistency

    • Financial custody with eventual consistency: service that reacts to Kafka order lifecycle events to block balance (PENDING), settle (FILLED) or refund (REJECTED). Weighted average price calculation, idempotency with database constraint and the concept of blocked vs available balance.
  9. The Ecosystem Conductor: Orchestrating Market Orders with Kafka, RabbitMQ and Spring Boot

    • The ecosystem conductor: orchestrates the complete order lifecycle by validating balance via Feign, persisting as PENDING, sending to B3 via RabbitMQ and publishing two Kafka events — one on creation and one on final status. Why exchange over direct queue and the executedPrice nullable decision.

... more articles will be added as the development progresses!


Connect with me:

Top comments (0)