The B3 Playground System is a robust platform designed to interact with financial data from the B3 Stock Exchange.
I divided the project into two fronts, very inspired by CQRS.
1- data population.
a) Option 1: - use the ORM used in the framework.
- Blocking was that it does not accept bulk.
b) Option 2 (chosen):
- use direct connection to Mongo.
b.1) read file and send. (Very slow)
b.2) Play in a queue and process (Very slow).
b.3) Use batch operation, calibrating the machine's memory. (chosen)
b.4) Batch merge with queue (unnecessary complexity for POC)
b.5) parallel processing (greater complexity and machine requirement)
2- Data Acquisition:
To query data, I used the ORM available in the framework used. Could have inserted into another table during the data loading process, optimizing the query and following CQRS
Follow these steps to set up the project locally:
-
Clone the Repository:
-
Navigate to your project directory:
-
In the assets folder, we have the files in .zip format, which will need to be extracted.
-
Environment Variables:
- Copy the example environment file:
cp .env.example .env - Set the
DATABASE_URIin the.envfile to your MongoDB URI.
- Docker Compose (Optional):
- If you're using local MongoDB, start the service:
docker-compose up -d in .env exemple set DATABASE_URI=mongodb://root:test@localhost:27017/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
- Install Dependencies:
yarn
- Seed the Database:
- Run the following command to seed initial data into the database:
yarn seed - The seed script creates your first admin user with the following credentials:
- Email: [email protected]
- Password: test
-
Start the Development Server:
-
Access the Admin Panel:
- Open your browser and navigate to:
http://localhost:3000/admin
Run the following command to execute tests:
yarn test
The system provides two endpoints to access stock information:
-
Get Maximum Range Value:
- URL:
http://localhost:3000/api/stocks/:stock/max-range-value - Method:
GET
- URL:
-
Get Maximum Daily Volume:
- URL:
http://localhost:3000/api/stocks/:stock/max-daily-volume - Method:
GET
- URL:
- Yarn Seed: The
yarn seedcommand is used to populate the database with initial data. It's essential for setting up the first admin user and basic data structures.
The system also includes a Doc API that provides detailed documentation for various functionalities. To access the Doc API, follow these steps:
Start the Development Server:
-
**Access the Doc API:
-
**Open your browser and navigate to:
http://localhost:3000/api-docs