Skip to content

amsilveira-ce/bioknowdes-nasa

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BioKnowdes: Mapping NASA’s Life Sciences Knowledge πŸš€

NASA Space Apps Challenge License Python

"A new way of exploring space biology."

BioKnowdes is an integrated platform designed to help researchers, students, and decision-makers navigate, understand, and uncover connections within NASA’s vast collection of life sciences research. By combining Knowledge Graphs, Heatmaps, and Generative AI, we transform unstructured PDFs into a dynamic universe of data.

πŸŽ₯ Watch the Demo Video


🌌 Project Overview

BioKnowdes bridges the gap between complex scientific research and accessible knowledge. The platform ingests 600+ open-access Space Biology publications and allows users to discover patterns that might otherwise remain buried in massive amounts of textual data.

Key Features

1. πŸ•ΈοΈ Interactive Knowledge Graph

The core of BioKnowdes. It represents research papers as nodes and shared concepts as connections.

  • Pipeline: PDF Text Extraction (Apache Tika) β†’ Keyword Extraction (KeyBERT/SciBERT) β†’ Graph Construction (NetworkX).
  • Goal: Visualize how studies relate to one another and identify emerging trends.

2. πŸ”₯ Similarity Heatmap

A high-level view that measures the similarity between top research articles.

  • Visual: Interactive grid highlighting clusters of related work.
  • Utility: Detect gaps in scientific knowledge and understand research concentrations.

3. πŸ€– Lumi - AI Research Agent

Lumi is a conversational agent powered by a RAG (Retrieval-Augmented Generation) system.

  • Retrieve: Searches the database for relevant papers using semantic ranking.
  • Augment: Uses key content from selected papers as context.
  • Generate: Produces clear answers cited directly from NASA sources.
  • Tech Note: While designed to work with local models (Llama 3.1 via Ollama), the production version utilizes the OpenAI API for performance and stability.

πŸ› οΈ Technology Stack

  • Backend: Python, Flask

  • Data Processing: Apache Tika (text extraction), Pandas, NetworkX

  • AI & NLP:

    • LangChain (RAG Workflow)
    • OpenAI API (Production LLM) / Ollama (Local Dev)
    • Sentence-Transformers, KeyBERT, SciBERT
  • Frontend: HTML, CSS, JavaScript, Pyvis Network (Graph), Plotly (Heatmap)


πŸš€ Installation & Configuration

1. Prerequisites

  • Python 3.9+
  • Virtual Environment (recommended)

2. Environment Setup

  1. Clone and install dependencies:

    git clone https://github.com/your-username/bioknow-nasa.git
    cd bioknow-nasa
    python -m venv venv
    source venv/bin/activate  # Windows: venv\Scripts\activate
    pip install -r requirements.txt
  2. Configure Environment Variables: Copy the template and edit with your keys.

    cp env.template .env

    Required variables in .env:

    # OpenAI API (Mandatory for Lumi Agent)
    OPENAI_API_KEY=sk-your-openai-key-here
    
    # Flask Security
    FLASK_SECRET_KEY=your-secret-key-here
    
    # Optional (for future multi-model support)
    ANTHROPIC_API_KEY=...
    GEMINI_API_KEY=...

3. Running the Application

python app.py

Access the application at: http://localhost:5000/


πŸ”§ Environment Variable Configuration

πŸ“‹ Initial Setup

  1. Copy the environment variable template:

    cp env.template .env
  2. Set your API keys in the file .env:

    # Edit the .env file with your real keys
    nano .env
  3. Mandatory variables for production:

    # OpenAI API (mandatory for full functionality)
    OPENAI_API_KEY=sk-your-openai-key-here
    
    # Flask secret key (mandatory for sessions)
    FLASK_SECRET_KEY=your-secret-key-here
    
    # Other APIs (Optional)
    ANTHROPIC_API_KEY=your-anthropic-key-here
    GEMINI_API_KEY=your-gemini-key-here

πŸ”’ Production Security

  • βœ… Never commit the file .env (its already on .gitignore)
  • βœ… Use different keys for development and production
  • βœ… Rotate your keys periodically
  • βœ… Set environment variables on your hosting provider

πŸš€ Production Deployment

For platforms such as Heroku, Railway, or Vercel:

#Configure the environment variables on the provider panel
OPENAI_API_KEY=sk-your-production-key
FLASK_SECRET_KEY=your-production-secret-key
FLASK_ENV=production

βœ… Applied Changes

All of the BioKnowdes routes are now under the prefix /ask-lumi:

πŸ“‹ Route Mapping

Old Route New Route Description
/chat /ask-lumi Main chat page
/articles /ask-lumi/articles Article browser
/settings /ask-lumi/settings AI settings
/upload /ask-lumi/upload Document upload
/documents /ask-lumi/documents List documents
/documents/toggle/:id /ask-lumi/documents/toggle/:id Toggle selection
/documents/delete/:id /ask-lumi/documents/delete/:id Delete document
/clear /ask-lumi/clear Clear session
/external-demo /ask-lumi/external-demo External example

πŸ”Œ API Endpoints

Old Route New Route Method Description
/chat (POST) /ask-lumi/chat POST AI Chat
/api/load-articles /ask-lumi/api/load-articles POST Load articles
/api/articles-list /ask-lumi/api/articles-list GET List articles
/api/search-articles /ask-lumi/api/search-articles POST Search articles
/api/settings /ask-lumi/api/settings GET/POST AI Config

🌐 Original Routes (Kept)

These are the original project routes that were not changed:

  • / - Home with graph
  • /graph - Graph search
  • /heatmap - Thermal analysis
  • /get_graph_data - Graph data
  • /api/keywords - Keywords list

πŸ“ Updated Files

Backend:

  • βœ… app.py - All of the BioKnowdes routes altered
  • βœ… CORS updated to /ask-lumi/api/*

Templates:

  • βœ… templates/index.html - Menu links
  • βœ… templates/chat.html - Navigation links
  • βœ… templates/articles.html - Link "Back to Chat"
  • βœ… templates/settings.html - Link "Back to Chat"

JavaScript:

  • βœ… static/js/bioknowdes.js - All fetch calls
  • βœ… static/js/articles.js - API calls and redirections
  • βœ… static/js/settings.js - API calls and redirections

Outros:

  • βœ… external_button_example.html - API URL and redirect

πŸš€ How to Access

Main Pages:

Home (Graph):        http://localhost:5000/
AI Chat:             http://localhost:5000/ask-lumi
Browse Articles:     http://localhost:5000/ask-lumi/articles
Settings:            http://localhost:5000/ask-lumi/settings
Heatmap:             http://localhost:5000/heatmap

API Endpoints:

# AI Chat
POST http://localhost:5000/ask-lumi/chat
{
  "message": "Your question here"
}

# Load articles
POST http://localhost:5000/ask-lumi/api/load-articles
{
  "filenames": ["article1_text.txt", "article2_text.txt"]
}

# List all articles
GET http://localhost:5000/ask-lumi/api/articles-list

# Settings
GET http://localhost:5000/ask-lumi/api/settings
POST http://localhost:5000/ask-lumi/api/settings
{
  "provider": "openai",
  "openai": {
    "api_key": "...",
    "model": "gpt-4"
  }
}

πŸ§ͺ Testing

Execute the server:

cd /home/jabs/development/personal/Nasa-Space-Apps_25/bioknow-nasa
source venv/bin/activate
python app.py

Test each route:

# Original home
curl http://localhost:5000/

# Chat (must return HTML)
curl http://localhost:5000/ask-lumi

# Articles API
curl http://localhost:5000/ask-lumi/api/articles-list

πŸ“Š Navigation Structure

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Home     β”‚ (Graph - /)
β”‚   (Graph)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚             β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Heatmap   β”‚  β”‚  Ask-Lumi β”‚ (/ask-lumi)
β”‚ (/heatmap)  β”‚  β”‚  (Chat)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚            β”‚              β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Articles  β”‚ β”‚ Settings  β”‚ β”‚  External  β”‚
                β”‚  (/articles)β”‚ β”‚(/settings)β”‚ β”‚   Demo     β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ Workflow

  1. User acess home (/)

    • Sees graph visualization
    • Dropdown menu with all options
  2. Clicks "AI Chat" β†’ Goes to /ask-lumi

    • Can load documents
    • Can go to /ask-lumi/articles or /ask-lumi/settings
  3. Loads articles on /ask-lumi/articles

    • Selects articles
    • Clicks "Load Selected"
    • API: POST /ask-lumi/api/load-articles
    • Redirects to /ask-lumi with session_id
  4. Asks questions on the chat

    • API: POST /ask-lumi/chat
    • AI answers based on documents

🎯 Benefits of the New Structure

βœ… Organization: All BioKnowdes routes grouped under /ask-lumi

βœ… Separation: Clear distinction between:

  • Graph visualization (original)
  • AI and document analysis (BioKnowdes)

βœ… Scalability: Each to add new features under /ask-lumi

βœ… External API: CORS configured to /ask-lumi/api/*

πŸ“ Important Notes

  1. Session ID: Always included in API responses

  2. CORS: Allowed only for /ask-lumi/api/*, for security

  3. Navigation: All templates have updated links

  4. redirects: After loading articles or saving settings, redirects to /ask-lumi

πŸ› Troubleshooting

404 Error in routes

# Verify if its accessing with the correct prefix
# WRONG:  /articles
# CORRECT: /ask-lumi/articles

CORS Error

# Make sure its requisition goes to /ask-lumi/api/*
# CORS is configured only for this prefix

Session not persisting

# Verify if the session_id is being passed correctly
# On the URL after loading articles

Full Update! πŸŽ‰

All routes are now organized under /ask-lumi.

About

Nasa Space Apps 2025

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 36.3%
  • HTML 25.7%
  • JavaScript 19.8%
  • CSS 18.2%