Nowadays the amount of knowledge and inference needed to understand investment has drastically increased, when dealing with options to address heritage management the stock market could be one of multiple options to rely on, however the knowledge frontier is high and the amount of time unreachable.
Finalytics is a financial analyzer for U.S. stock companies that synthesizes the last five years of annual reports into a concise summary with plots and a short natural-language explanation. The system uses a Large Language Model (LLM) contextualized with Retrieval-Augmented Generation (RAG) to reduce hallucinations and provide more accurate and helpful responses.
Integrates Model View Controller software architecture (MVC) with Docker using the principles of microservices to isolate each component in a different container to provide more scalability for more users using cloud platforms.
Each container has QoS policies in which Docker Compose tries within a certain time (less than 60 seconds) a health query to check if the container is up. When the number of tries runs out, the Process ID (PID) is taken down and Docker itself redeploys the container again.
Finalytics.mp4
The proposed architecture to intend the problem was using MVC (Model View Controller) architecture in which they follow the next rules:
- Model: Process the business logic and application.
- View: Display the data from the model.
- Controller: Communicates the view and the controller, manages the input and updates the view and model.
Docker helps to create isolated virtual environments to prevent problem dependencies, easier quality of life at software development and enrich the services with quality of service policies, the proposed program was divided according microservices architecture, which every single service has its own environment, thus making changes and maintenance only affects the single service and not the whole product.
Using the MVC architecture the containers were divided in the next approach:
- Model: RAG and embed system (Hugging Face and Deepseek).
- View: Flet.
- Controller: Database (MongoDB).
Note
The communication between containers is done using FastAPI and in a Docker bridge communication network this means is done locally and Docker itself integrates a DNS to solve the IP requests, the coordination between containers is archive by docker compose.
Finalytics works in the following steps:
-
$${\color{orange} 1.-}$$ Queries and extracts the information from SEC-API (Section 7 of 10-K) Alpha Vantage. -
$${\color{orange} 2.-}$$ Information is allocated in cache memory to avoid more query usage at a local MongoDB database. -
$${\color{orange} 3.-}$$ Feature extraction is done and then sent to Retrieval-Augmented Generation Deepseek with an automatic prompt to give the best answer without compromising efficiency.-
$${\color{lightskyblue} 3.1.-}$$ Divides the text into affordable chunks to avoid collapsing memory, similar concept to batch size in artificial intelligence frameworks. -
$${\color{lightskyblue} 3.2.-}$$ Each embedding represents a number that is stored in FAISS. -
$${\color{lightskyblue} 3.3.-}$$ The response is given by the closest numbers that match with the FAISS.
-
-
$${\color{orange} 4.-}$$ The containers communicate with each other to bring their information and finally display it at the entrypoint container view.-
$${\color{lightskyblue} 4.1.-}$$ Containers every 60 seconds as a second process will do a health check using their loopback address (127.0.0.1 for IPv4, ::1 for IPv6) to try to ping themselves several times; if it is not possible, it takes down the process ID (PID) 1 and Docker Compose redeploys the container, notifying their health state.
-
Finalytics.mp4
Caution
The current version does not include the API Keys to make the query to the local and SEC-api database.