This project is a complete, event-driven data pipeline that automatically tracks new AI research papers from arXiv, enriches them using an AI (Ollama) embedding model, and stores them in a queryable PostgreSQL database.
- The topic will be given by the users.
- New paper will be discovered.
This project is built as a decoupled, event-driven system using Kafka as a message bus. This separates concerns, making the system resilient and scalable.
- Airflow
arxiv_producer_dag: Runs on a schedule (e.g., hourly) and queries the arXiv API for new papers matching our criteria (e.g.,cat:cs.AI). - Producer (Python): Publishes the metadata for each new paper as a JSON message into the
raw_papersKafka topic. - ML Consumer (
ml_consumer.py):- Reads new messages from the
raw_paperstopic in batches. - Makes an API call to a local Ollama service (running
nomic-embed-text) to get a 768-dimension vector embedding for each paper's abstract. - Calculates cosine similarity scores against a predefined list of user topics (e.g., "AI Agents").
- Publishes a new, enriched JSON message (containing the original data + the embedding + the scores) to the
analyzed_paperstopic.
- Reads new messages from the
- Sink Consumer (
consumer-sink.py):- Reads from the
analyzed_paperstopic. - Parses the enriched JSON and writes the data to four separate tables in PostgreSQL in a single atomic transaction.
- Reads from the
- Airflow (Monitoring):
pipeline_health_check_dag: A sensor runs every 15 minutes to ensure new papers are arriving in the database.db_cleanup_dag: Runs daily to delete data older than 90 days.
- Orchestration: Apache Airflow
- Message Bus: Apache Kafka
- Database: PostgreSQL +
pgvector(for vector similarity search) - AI/ML: Ollama (
nomic-embed-text) - Producers/Consumers: Python (
kafka-python,ollama,psycopg2) - Containerization: Docker & Docker Compose
- Testing:
pytest&pytest-mock
- Docker Desktop installed and running.
- Ollama installed and running on your host machine.
- Pull the
nomic-embed-textmodel:ollama pull nomic-embed-text
This project does not require any API keys, as it runs 100% locally.
# Clone the repository
git clone [https://github.com/YOUR_USERNAME/ai_research_radar.git](https://github.com/YOUR_USERNAME/ai_research_radar.git)
cd ai_research_radarThis command will build the custom Airflow and Python images, then start all services (Kafka, Postgres, Airflow, and our two consumers) in the background.
docker-compose up -d --buildThe pipeline is now running, but no data will be produced until the Airflow DAG runs.
- Open the Airflow UI at
http://localhost:8080(login:admin/admin). - In the Admin -> Connections tab, create a new connection:
- Conn Id:
ai_radar_db - Conn Type:
Postgres - Host:
postgres - Schema:
ai_radar - Login:
admin - Password:
password - Port:
5432
- Conn Id:
- On the main "DAGs" page, un-pause (toggle) the
arxiv_producer_dag. - To get your first batch of data, click the "Play" (
▶️ ) button on thearxiv_producer_dagto trigger a manual run.
You can now query the enriched data directly from the Postgres container.
# 1. Connect to psql
docker-compose exec postgres psql -U admin -d ai_radar
# 2. Run the "Money Shot" query
# See the most relevant papers for your topics:
SELECT
p.title,
t.name AS topic,
pr.relevance_score
FROM papers p
JOIN paper_relevance pr ON p.id = pr.paper_id
JOIN topics t ON pr.topic_id = t.id
ORDER BY pr.relevance_score DESC
LIMIT 10;To run the unit tests, use this command from the project root:
docker-compose run --rm consumer-sink pytest