[π§π· PortuguΓͺs] [π¬π§ English]
An institutional-grade intelligence platform for monitoring, structuring, ranking, and interpreting Brazilian Real Estate Investment Fund (FII) signals from financial media, research portals, and investor communities.
Big Data β’ PySpark β’ MapReduce Word Count β’ NLP β’ TF-IDF β’ BM25 Ranking β’ Hybrid Retrieval β’ FAISS + Multilingual Embeddings β’ Web Scraping β’ TOFU/MOFU/BOFU β’ CRISP-DM β’ FastAPI β’ Streamlit β’ Docker β’ 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)
A scalable platform combining Big Data, PySpark, MapReduce, Word Count, NLP, TF-IDF, BM25, FAISS, pMultilingual Embeddings, Web Scraping, Hybrid RAG and AI-Assisted Analytics to transform large-scale financial discussions into actionable insights for FIIs.
Warning
- Academic Context
- Overview
- System Overview
- What This Platform Delivers
- Why This Matters
- Architecture and Pipeline
- Notebooks Executive 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
- How to Run
- Deployment & Automation Workflow
- Which requirements*.txt to Use in Each Scenario
- Makefile β Full Reference
- Expected Outputs
- Technical Glossary
- Repository and Project Links
- References
This project was developed at PUC-SP in the courses of cybersecurity, social engineering, data engineering and Big Data analytics applied to financial markets. The original requirement focused on demonstrating a distributed word count solution using PySpark and the MapReduce paradigm.
From this starting point, the repository was extended to incorporate more advanced analytical techniques (TF-IDF, BM25, contextual sentiment), a serving architecture with FastAPI + RAG and a structured pipeline oriented towards FII marketing intelligence.
| 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 π§π· FIIs Brazil is not just an academic Big Data exercise. It is an investor intelligence platform for Brazilian Real Estate Investment Funds (FIIs), designed to transform fragmented public financial discussions into structured, searchable, explainable and decision-oriented market intelligence.
Instead of being a simple dashboard, the system operates as an end-to-end analytical environment that:
- collects data from 21 sources (RSS Β· scraping Β· Reddit)
-organizes them in a Bronze/Silver/Gold architecture
- enriches them with hybrid retrieval (TF-IDF + BM25 + FAISS semantic search with multilingual PT-BR embeddings), FII PT-BR sentiment and explainable marketing intelligence signals
- exposes results via FastAPI + RAG + Groq chatbot + Streamlit
%%{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;
- Complete end-to-end pipeline β from ingestion to analytical output.
- Distributed processing + NLP β PySpark MapReduce combined with TF-IDF, BM25 and contextual sentiment.
- RAG over FII corpus β hybrid retrieval via TF-IDF, BM25 and FAISS-backed multilingual PT-BR embeddings, followed by contextual generation via Groq.
- Cybersecurity and Social Engineering β security perspective in interpreting channels and narratives.
- Asset and fund managers who monitor investor perception
- Financial analysts who track market narratives
- Marketing teams interested in FII visibility and engagement
- Academic evaluators assessing Big Data, Spark, NLP and RAG
- Recruiters and technical portfolio reviewers
Analysts, managers and financial communication teams face:
- information dispersed across dozens of portals and communities
- high noise-to-signal ratio in market discussions
- difficulty tracking how sentiment and narratives evolvev
- lack of transparent tools aligned with LGPD and the EU AI Act
Tip
This platform addresses this gap with 21 monitored sources, a Bronze/Silver/Gold pipeline and reproducible, interpretable analytics.
The platform monitors a curated set of editorial and behavioral sources relevant to the Brazilian FII ecosystem. Instead of treating all inputs as an undifferentiated corpus, the project distinguishes:
- Editorial RSS sources β collected via structured feeds >
- Editorial portals via scraping β controlled extraction of public metadata >
- Behavioral social sources β Reddit as a community sentiment layer
Important
Detailed documentation per source: docs/data_sources.md
When available, RSS is preferred: lower extraction cost, native structured metadata, no risk of breakage due to HTML layout changes, reliable scheduling.
When RSS is unavailable or unstable, controlled HTML extraction of public pages. It does not simulate human navigation β it collects observable metadata (titles, links, timestamps, categories, excerpts).
Reddit follows a separate logical path because it represents conversational and community-based data. It is treated as a behavioral and discursive input layer that complements editorial coverage with public sentiment and emerging narratives.
| Level | Method | Requires |
|---|---|---|
| 1 | PRAW (Python Reddit API Wrapper) | REDDIT_CLIENT_ID + REDDIT_CLIENT_SECRET |
| 2 | Public API /new.json + /hot.json |
None |
| 3 | Committed frozen Parquet | None |
| # | 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
NB00["NB00<br/>21 DATA SOURCES<br/>RSS β’ Scraping β’ Reddit"]:::bronze
NB01["BRONZE LAYER<br/>Ingestion<br/>feedparser β’ BS4 β’ PRAW"]:::bronze
NB02["SILVER LAYER<br/>Cleaning & Normalization<br/>Quality Gates"]:::silver
NB03["SILVER LAYER<br/>MapReduce Word Count"]:::silver
NB04["GOLD LAYER<br/>TF-IDF + BM25<br/>Retrieval Index"]:::gold
NB05["GOLD LAYER<br/>Sentiment Analysis<br/>PT-BR Lexicon"]:::gold
NB06["GOLD LAYER<br/>Marketing Intelligence<br/>Signals β’ Funnel β’ Insights"]:::gold
NB07["SERVING LAYER<br/>Dashboard Dataset"]:::dash
API["FASTAPI<br/>Serving Layer<br/>REST API"]:::dash
ST["STREAMLIT<br/>Serving Layer<br/>Dashboard"]:::dash
BOT["GROQ CHATBOT<br/>LLM Layer<br/>GPT-OSS-20B"]:::llm
NB00 --> NB01 --> NB02
NB02 --> NB03
NB02 --> NB04
NB02 --> NB05
NB03 --> NB06
NB04 --> NB06
NB05 --> NB06
NB06 --> NB07
NB07 --> API
NB07 --> ST
API --> BOT
ST --> BOT
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.