[π§π· PortuguΓͺs] [π¬π§ English]
End-to-end AI infrastructure transforming unstructured financial data into actionable intelligence for Brazilian REITs (FIIs).
An institutional-grade solution designed to monitor, structure, rank, and interpret signals from Brazilian REITs (FIIs), leveraging financial media, research portals, and investor communities.
Big Data β’ PySpark β’ MapReduce β’ NLPβ’ TF-IDF β’ BM25 β’ Hybrid Retrieval β’ FAISS + Multilingual Embeddings β’ Web Scraping β’ TOFU/MOFU/BOFU β’ CRISP-DM β’ FastAPI β’ Streamlit β’ Responsible AI β’ LGPD β’ EU AI Act Alignment
Institution: Pontifical Catholic University of SΓ£o Paulo (PUC-SP)
School: FACEI β Faculty of Exact Sciences and Informatics
Bachelorβs Program: Human-Centerd AI & Data Science β’ 5th Semester β’ 2026
Course: AI Security, Cybersecurity & Social Engineering
Methodology: CRISP-DM (Cross-Industry Standard Process for Data Mining)
Professors β¨ Carlos Eduardo Paes and β¨ Eduardo Savino Gomes
Project Author: Fabiana β‘οΈ Campanari
Tip
β Explore the Full Course Repository
Warning
This platform is intended exclusively for educational, research, and analytical purposes. It does not constitute financial, investment, legal, or professional advice. Any analyses, insights, or results presented are for academic and informational purposes only.
- Academic Context
- Product Overview
- System Overview
- From Frequency to Decision
- What This Platform Delivers
- Why This Matters
- Architecture and Pipeline
- Executive Notebook Summary
- Notebooks NB00βNB07: Technical Report
- The 3 Core Techniques + FAISS Semantic Layer
- Data Sources β 21 Sources
- Big Data Infrastructure
- Dependencies and requirements.txt
- CRISP-DM Methodology
- Marketing Funnel: TOFU, MOFU, and BOFU in the Project
- RAG Chatbot: Groq + Gemini (Automatic Fallback)
- Governance
- Folder Structure
- Full Documentation (docs/)
- How to Run
- Automated Testing
- Deployment & Automation Workflow
- Which requirements*.txt to Use in Each Scenario
- Makefile β Full Reference
- Expected Outputs
- Technical Glossary
- Project Repository and Links
- References
This project was developed at PUC-SP as part of the courses Cybersecurity, Social Engineering, Data Engineering, Distributed Systems, and Big Data Analytics Applied to Financial Markets. The original assignment focused on demonstrating a distributed Word Count solution using PySpark and the MapReduce paradigm.
Building upon this foundation, the project evolved into a comprehensive financial intelligence platform by incorporating advanced information retrieval and natural language processing techniques, including TF-IDF, BM25, and contextual sentiment analysis. It also integrates a modern serving architecture based on FastAPI and Retrieval-Augmented Generation (RAG), supported by a structured data engineering pipeline designed for FII (Real Estate Investment Funds) market intelligence and decision support.
| Requirement | Implementation |
|---|---|
| Distributed Computing | PySpark Β· RDD MapReduce Β· SparkSession |
| Big Data Architecture | Medallion (Bronze β Silver β Gold) |
| Machine Learning | TF-IDF Β· BM25 Β· Semantic Embeddings Β· Sentiment Analysis |
| Vector Search | FAISS Β· Dense Index Β· Multilingual PT-BR Embeddings |
| NLP | PT-BR Tokenization Β· FII Lexicon Β· Signal Flags |
| Data Governance | LGPD Β· EU AI Act Β· Responsible AI Β· XAI |
| REST API | FastAPI Β· Uvicorn |
| RAG / LLM | Groq (openai/gpt-oss-20b, primary) + Gemini 2.5 Flash (automatic fallback) |
| Visualization | Streamlit Β· Plotly |
| Cybersecurity | Narrative surface analysis Β· Social Engineering awareness |
The Investor Intelligence Platform for Brazilian REITs (FIIs) is an end-to-end Big Data and AI solution designed to transform financial content into actionable market intelligence, behavioral analytics, and investor insights.
By ingesting data from 21 public sources (RSS feeds, financial portals, web scraping channels, and Reddit), the platform applies Brazilian Portuguese (PT-BR) NLP, performs relevance ranking through hybrid information retrieval (TF-IDF + BM25), conducts contextual FII sentiment analysis, and consolidates intelligence metrics into interactive dashboards powered by FastAPI and Streamlit.
* Collects and processes data from
* Organizes information through a scalable Bronze β Silver β Gold Medallion Architecture;
* Enriches financial documents using hybrid retrieval combining TF-IDF, BM25, and FAISS semantic search with multilingual Portuguese embeddings;
* Performs contextual Brazilian Portuguese (PT-BR) sentiment analysis specialized in the Brazilian FII ecosystem;
* Generates explainable marketing intelligence and behavioral indicators to identify trends, investor interests, and engagement signals;
* Provides AI-assisted analysis through FastAPI, Retrieval-Augmented Generation (RAG), Groq LLM, and an interactive Streamlit dashboard.
- Monitoring investor sentiment and market perception across digital financial communities;
- Identifying emerging topics, trends, and relevant discussions within the FII ecosystem;
- Ranking financial content using hybrid retrieval (TF-IDF + BM25 + FAISS semantic search);
- Detecting behavioral patterns and investor engagement signals;
- Supporting data-driven marketing, communication, and investment research strategies;
- Delivering AI-powered question answering through a Retrieval-Augmented Generation (RAG) architecture.
Tip
Beyond a Big Data demonstration, the Investor Intelligence Platform β FIIs Brazil showcases how modern data engineering, Natural Language Processing (NLP), semantic retrieval, and Large Language Models (LLMs) can be integrated into a scalable decision-support system for financial market intelligence.
%%{init:{
'theme':'dark',
'themeVariables':{
'background':'#090d13',
'primaryTextColor':'#F5F7FA',
'lineColor':'#2dd4bf'
}}}%%
graph LR
SRC["21 SOURCES<br/>RSS β’ Scraping β’ Social"]:::setup
PIPE["NLP PIPELINE<br/>PySpark β’ MapReduce<br/>TF-IDF β’ BM25 β’ FAISS"]:::gold
GOLD["GOLD LAYER<br/>Parquet artifacts"]:::bronze
API["FASTAPI<br/>REST + RAG"]:::dash
DASH["STREAMLIT<br/>Analytics Dashboard"]:::dash
LLM["LLM LAYER<br/>Groq + Gemini"]:::llm
SRC --> PIPE --> GOLD
GOLD --> API
GOLD --> DASH
API --> LLM
DASH --> LLM
classDef setup fill:#0d2137,stroke:#00d2ff,color:#F5F7FA,stroke-width:2.5px;
classDef bronze fill:#2a1512,stroke:#a85a4a,color:#F5F7FA,stroke-width:2.5px;
classDef silver fill:#1b2430,stroke:#b0b7c3,color:#F5F7FA,stroke-width:2.5px;
classDef gold fill:#2a2208,stroke:#e6c35a,color:#F5F7FA,stroke-width:2.5px;
classDef dash fill:#06363d,stroke:#2dd4bf,color:#F5F7FA,stroke-width:2.5px;
classDef llm fill:#231433,stroke:#b56cff,color:#F5F7FA,stroke-width:2.5px;
An NLP + Information Retrieval pipeline that transforms unstructured information from the FII market into actionable intelligence β combining MapReduce, TF-IDF, BM25, FAISS + Embeddings, RAG, and Contextual Sentiment Analysis into progressive intelligence layers, each solving a specific structural limitation of the one before it.
| Layer | Question It Answers |
|---|---|
| MapReduce | Is this topic frequently discussed? |
| TF-IDF | Does this term distinguish this document? |
| BM25 | Which document best satisfies the user's query? |
| FAISS + Embeddings | Can different words represent the same concept? |
| RAG | How can retrieved evidence become a reliable answer? |
| Contextual Sentiment | Does the surrounding context indicate opportunity or risk? |
Full framework, with FII-domain examples and the analytical evolution diagram:
FROM_FREQUENCY_TO_MEANING.md
| # | Source | Category | Primary Method | Fallback | Endpoint |
|---|---|---|---|---|---|
| 1 | InfoMoney | Editorial | RSS | β | infomoney.com.br/feed/ |
| 2 | Empiricus | Editorial | RSS | Scraping | empiricus.com.br/feed/ |
| 3 | Money Times | Editorial | RSS | β | moneytimes.com.br/feed/ |
| 4 | Seu Dinheiro | Editorial | RSS | β | seudinheiro.com/feed/ |
| 5 | Exame Invest | Editorial | RSS | β | exame.com/feed/ |
| 6 | CNN Brasil Business | Editorial | RSS | β | cnnbrasil.com.br/feed/ |
| 7 | Suno Research | Editorial | RSS (Secondary) | β | sunoresearch.com.br/feed/ |
| 8 | E-Investidor | Editorial | RSS (Secondary) | β | einvestidor.estadao.com.br/feed |
| 9 | NeoFeed | Editorial | RSS (Secondary) | β | neofeed.com.br/feed/ |
| 10 | Toro Investimentos | Editorial | RSS | Scraping | blog.toroinvestimentos.com.br/feed/ |
| 11 | Funds Explorer | Portal | Scraping | β | fundsexplorer.com.br |
| 12 | Status Invest | Portal | Scraping | β | statusinvest.com.br |
| 13 | Clube FII | Portal | Scraping | β | clubefii.com.br |
| 14 | FIIs.com.br | Portal | Scraping | β | fiis.com.br |
| 15 | Portal do FII | Portal | Scraping | RSS | portaldofii.com.br |
| 16 | Investidor10 | Portal | Scraping | β | investidor10.com.br |
| 17 | Eu Quero Investir | Portal | Scraping | β | euqueroinvestir.com |
| 18 | Bora Investir (B3) | Institutional | Scraping | β | borainvestir.b3.com.br |
| 19 | XP ConteΓΊdos | Institutional | Scraping | β | conteudos.xpi.com.br |
| 20 | Investing Brasil | Portal | Scraping | β | br.investing.com |
| 21 | Reddit / Google News (Fallback) | Social / Behavioral | PRAW (when available) + Google News RSS (fallback) | r/investimentos Β· r/farialimabets Β· news.google.com |
Tip
The original behavioral source uses Reddit subreddits (r/investimentos and r/farialimabets) as a social intelligence and market narrative layer.
Following changes to Redditβs public API policy in April 2023 (HTTP 403 restrictions), the pipeline was redesigned to operate across three levels:
-
Level 1 β PRAW (when
REDDIT_API_AVAILABLE = True)Uses the authenticated Reddit API to collect recent posts from the target subreddits.
-
**Level 2 β Google News RSS PT-BR (fallback)*
- When Level 1 is unavailable (e.g., missing
REDDIT_CLIENT_IDin.envor public API restrictions), NB01 triggerscollect_google_news_rss(), which: - queries Google News in Portuguese using FII-specific search terms,
- filters content using FII-related keywords (
FII_FILTER_TERMS), - stores articles with
source='news.google.com',source_type='reddit',tags='google_news_rss', andingestion_method='feedparser_google_news'.
- When Level 1 is unavailable (e.g., missing
-
Level 3 β Frozen Parquet (Resilient Snapshot)
For reproducible evaluations and operational resilience, Source 21 data can be frozen in
data/external/and reused without issuing new requests.
In the documented reference execution, the Google News RSS fallback generated 351 FII-related articles for Source 21, preserving continuity of the behavioral intelligence layer even when direct access to Redditβs public API was unavailable. [page:46]
%%{init:{
'theme':'dark',
'themeVariables':{
'background':'#090d13',
'primaryTextColor':'#F5F7FA',
'lineColor':'#2dd4bf'
}}}%%
graph TD
A1["20 Financial Portals<br/>RSS Feeds"]:::setup
A2["Reddit (Source #21)<br/>r/investimentos Β· r/farialimabets<br/>Behavioral Layer"]:::setup
BZ["Bronze Layer<br/>data/external/<br/>Raw Parquet, 17 fields<br/>article_id already assigned (SHA-256)"]:::bronze
S1["NB02 β HTML Cleaning<br/>Deduplication Β· Schema Validation"]:::silver
SV["Silver Layer<br/>data/silver/<br/>Clean Parquet, 20 fields"]:::silver
N1["NB03 β Word Count<br/>+ NB04 TF-IDF"]:::gold
N2["NB04 β BM25<br/>(source-level ranking)"]:::gold
N3["NB05 β Sentiment<br/>PT-BR Lexicon"]:::gold
N4["NB03 β Negative Context<br/>Detection"]:::gold
T1["NB04 β FAISS<br/>Semantic Embeddings"]:::gold
GL["Gold Layer<br/>data/gold/<br/>Analytics Parquet"]:::gold
API["FastAPI<br/>Render Β· NB07"]:::dash
DASH["Streamlit Dashboard<br/>Streamlit Cloud Β· NB07"]:::dash
BOT["RAG Chatbot<br/>Groq (primary) β Gemini (fallback)"]:::llm
A1 --> BZ
A2 --> BZ
BZ --> S1 --> SV
SV --> N1 & N2 & N3 & N4 & T1
N1 & N2 & N3 & N4 & T1 --> GL
GL --> API --> DASH --> BOT
GL -.->|local fallback| DASH
classDef setup fill:#0d2137,stroke:#00d2ff,color:#F5F7FA,stroke-width:2.5px;
classDef bronze fill:#2a1512,stroke:#a85a4a,color:#F5F7FA,stroke-width:2.5px;
classDef silver fill:#1b2430,stroke:#b0b7c3,color:#F5F7FA,stroke-width:2.5px;
classDef gold fill:#2a2208,stroke:#e6c35a,color:#F5F7FA,stroke-width:2.5px;
classDef dash fill:#06363d,stroke:#2dd4bf,color:#F5F7FA,stroke-width:2.5px;
classDef llm fill:#231433,stroke:#b56cff,color:#F5F7FA,stroke-width:2.5px;
Tip
Detailed architecture diagram β docs/architecture.md
app/
βββ main.py
βββ api/
β βββ routes.py
βββ services/
β βββ retrieval.py
β βββ embeddings.py
β βββ llm.py
βββ models/
β βββ schemas.py
βββ db/
β βββ vector_store.py
βββ core/
β βββ config.py
from fastapi import FastAPI
from app.api.routes import router
app = FastAPI(
title="Market Intelligence API",
description="RAG-powered financial intelligence system",
version="1.0.0"
)
app.include_router(router)@router.post("/query")
async def query_system(question: str):
context = retrieve_context(question)
answer = generate_answer(question, context)
return {
"question": question,
"context": context,
"answer": answer
}def retrieve_context(query: str, k: int = 5):
query_embedding = embed_query(query)
results = search_vectors(query_embedding, k=k)
return [r["text"] for r in results]from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")
def embed_query(text: str):
return model.encode(text)index = faiss.IndexFlatL2(384)
def search_vectors(query_embedding, k=5):
D, I = index.search(np.array([query_embedding]), k)
return [{"text": f"doc_{i}"} for i in I[0]]def generate_answer(question, context):
prompt = f"""
Context:
{context}
Question:
{question}
Answer:
"""
return call_llm(prompt)11. End-to-End Flow
| Layer | Function |
|---|---|
| π₯ Bronze | Raw ingestion and storage |
| π₯ Silver | Data cleaning and NLP processing |
| π₯ Gold | Signal generation and ranking |
| RAG | Semantic retrieval |
| FastAPI | API interface |
| LLM | Natural language reasoning |
12. Example Query
{
"question": "What is the current investor sentiment on logistics REITs?"
}β Response:
{
"answer": "Recent data indicates a moderately positive sentiment driven by stable dividend yields and occupancy rates."
}This architecture transforms a traditional data pipeline into a full-stack AI intelligence system, enabling:
* semantic search
* investor sentiment
* real-time insights
* natural language interaction
- Python 3.10+ installed - Git installed - (Optional) Python virtual environment (venv) to isolate dependencies
git clone https://github.com/Quantum-Software-Development/5-cybersecurity-social-engineering-fii-marketing-intelligence-platform.git
cd 5-cybersecurity-social-engineering-fii-marketing-intelligence-platform# macOS / Linux
python3 -m venv .venv
source .venv/bin/activate
# Windows (PowerShell)
python -m venv .venv
.\.venv\Scripts\Activate.ps1Note: the
.venv/folder is already ignored in.gitignore, so the virtual environment will not be versioned.
pip install --upgrade pip
pip install -r requirements.txt- Open the notebooks in the
2-FIIs_Finalfolder in Jupyter Notebook, JupyterLab, or VS Code. - Make sure the selected kernel is the
.venvvirtual environment. - Adjust data paths if needed (under the
data/directory). Local data layers such asdata/bronze,data/silver, anddata/goldare git-ignored by default.
pip freeze > requirements.txt
git add requirements.txt
git commit -m "Update project dependencies"- Barocas, S., & Selbst, A. D. (2016). Big Dataβs Disparate Impact. California Law Review, 104(3), 671β732.
- Blei, D. M., Ng, A. Y., & Jordan, M. I. (2003). Latent Dirichlet Allocation. Journal of Machine Learning Research (JMLR), 3, 993β1022.
- Brasil. (2018). Lei nΒΊ 13.709, de 14 de agosto de 2018: Lei Geral de ProteΓ§Γ£o de Dados Pessoais (LGPD).
- Chapman, P., Clinton, J., Kerber, R., Khabaza, T., Reinartz, T., Shearer, C., & Wirth, R. (2000). CRISP-DM 1.0: Step-by-step data mining guide. SPSS.
- European Commission. (2019). Ethics Guidelines for Trustworthy AI. Brussels: High-Level Expert Group on Artificial Intelligence.
- Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press.
- Jurafsky, D., & Martin, J. H. (2025). Speech and Language Processing (3rd ed.). Stanford University.
- Manning, C. D., Raghavan, P., & SchΓΌtze, H. (2008). Introduction to Information Retrieval. Cambridge University Press.
- Mitchell, M., Wu, S., Zaldivar, A., Barnes, P., Vasserman, L., Hutchinson, B., Spitzer, E., Raji, I. D., & Gebru, T. (2019). Model Cards for Model Reporting. In Proceedings of the ACM Conference on Fairness, Accountability, and Transparency (FAccT) (pp. 220β229).
- Molnar, C. (2022). Interpretable Machine Learning (2nd ed.). Lulu.com.
- Robertson, S. E., Walker, S., Jones, S., Hancock-Beaulieu, M., & Gatford, M. (1995). Okapi at TREC-3. In Text REtrieval Conference (TREC-3). NIST.
- Robertson, S. E., & Zaragoza, H. (2009). The Probabilistic Relevance Framework: BM25 and Beyond. Foundations and Trends in Information Retrieval, 3(4), 333β389.
- Russell, S., & Norvig, P. (2021). Artificial Intelligence: A Modern Approach (4th ed.). Pearson.
πΈΰΉ My Contacts Hub
ββββββββββββββ βΉπΰΉ ββββββββββββββ
β£β’β€ Back to Top
Copyright 2026 Quantum Software Development. Code released under the MIT license.