This repository contains the expanded version of the Human Phenotype Project (HPP) documentation for researchers, featuring an interactive AI chatbot with AWS Lambda backend.
Serverless architecture with AWS Lambda backend (Development Environment)
GitHub Pages (Frontend) β AWS Lambda Function URL β OpenRouter API β S3 (Logs)
Components:
- Frontend: GitHub Pages (static site with chatbot widget)
- Backend: AWS Lambda Function (Development Environment)
- API: OpenRouter (Claude 3.5 Sonnet)
- Storage: AWS S3 (conversation logs)
- Security: API keys in Lambda environment variables, CORS-protected
- Quarto - Install Quarto
- Python dependencies:
pip install -r requirements.txt
- Copy environment file:
cp env.example .env - Edit
.envand setBACKEND_URLto your Lambda Function URL:BACKEND_URL="https://your-lambda-url.lambda-url.region.on.aws/api/chat"
π Security: .env is gitignored. API keys are stored in Lambda environment variables.
The chatbot answers questions based on the knowledge base context file.
-
Edit source documentation files:
- Main files:
pheno_knowledge_base_expanded/*.mdand*.qmd - Dataset files:
pheno_knowledge_base_expanded/datasets/*.ipynb
- Main files:
-
Regenerate knowledge base:
./create-knowledge-base.sh
This creates:
pheno_knowledge_base_expanded/knowledge-base-context.txt -
Update Lambda (if context changed):
cd lambda ./package_lambda.sh aws lambda update-function-code \ --function-name pheno-chatbot-backend \ --zip-file fileb://lambda-deployment.zip
The create-knowledge-base.sh script combines:
about.qmd- Project overviewparticipant_journey.md- Participant informationfaq.md- Frequently asked questionsdata_format.qmd- Data format documentationdatasets_description.md- Dataset descriptionsplatform_tutorial.md- Platform tutorialpheno_utils.md- Utility documentation
./deploy.shWhat this does:
- Creates knowledge base context
- Injects
BACKEND_URLfrom.envinto chatbot widget - Builds Quarto site to
docs/folder - Restores placeholder (safe to commit)
Main files to edit:
pheno_knowledge_base_expanded/_quarto.yml- Site configurationpheno_knowledge_base_expanded/chatbot-widget-simple.html- Chatbot UIpheno_knowledge_base_expanded/*.md/*.qmd- Content pages
After editing:
./deploy.sh # Rebuilds with changescd docs
python3 -m http.server 8000
# Visit http://localhost:8000-
Start backend (if testing locally):
cd backend python3 app.py # Backend runs on http://localhost:5000
-
Update
.envfor local testing:BACKEND_URL="http://localhost:5000/api/chat" -
Build and preview:
./deploy.sh cd docs python3 -m http.server 8000 -
Test chatbot:
- Visit
http://localhost:8000 - Click chatbot button (bottom right)
- Ask a question
- Check browser console (F12) for errors
- Visit
# Test health endpoint
curl https://your-lambda-url.lambda-url.region.on.aws/api/health
# Test chat endpoint
curl -X POST https://your-lambda-url.lambda-url.region.on.aws/api/chat \
-H "Content-Type: application/json" \
-d '{"question": "What is the population dataset?"}'- Build:
./deploy.sh - Commit and push:
git add docs/ && git commit && git push - Wait 1-2 minutes for GitHub Pages to rebuild
- Visit your GitHub Pages URL
- Test chatbot functionality
- Build:
./deploy.sh - Configure GitHub Pages:
- Repository β Settings β Pages
- Source: Deploy from branch
- Branch:
main(or your branch) - Folder:
/docs
- Push:
git add docs/ && git commit && git push
cd lambda
./package_lambda.sh
aws lambda update-function-code \
--function-name pheno-chatbot-backend \
--zip-file fileb://lambda-deployment.zippheno-docs-expanded/
βββ pheno_knowledge_base_expanded/ # Quarto site source
β βββ datasets/ # Dataset documentation
β βββ _quarto.yml # Site configuration
β βββ chatbot-widget-simple.html # Chatbot widget
β βββ knowledge-base-context.txt # Generated context
βββ lambda/ # AWS Lambda backend
β βββ lambda_function.py # Lambda handler
β βββ package_lambda.sh # Packaging script
β βββ requirements.txt # Lambda dependencies
βββ deploy.sh # Deployment script
βββ create-knowledge-base.sh # Context generator
βββ docs/ # Built site (GitHub Pages)
.env- Backend URL (gitignored)lambda/lambda_function.py- Backend logic and system promptpheno_knowledge_base_expanded/_quarto.yml- Site config (enable/disable chatbot)create-knowledge-base.sh- Controls what content goes into context
- Update context when documentation changes:
./create-knowledge-base.sh - Rebuild frontend after editing:
./deploy.sh - Test locally before deploying to GitHub Pages
- Check Lambda logs in AWS CloudWatch for debugging
- Updates via PR
- Separate commits for source changes vs. builds