The Historical Event Connector is a web application that allows users to explore relationships between historical events, figures, and locations using a knowledge graph powered by Graph RAG (Retrieval-Augmented Generation). It leverages Pinecone for vector storage and retrieval, and DBpedia (structured data from Wikipedia) as the primary data source for historical information. The application provides a user-friendly interface for querying historical connections and viewing summarized results, making it an educational tool for historians, students, and history enthusiasts.
- Frontend: React, Tailwind CSS
- Backend: Hono (lightweight web framework), Pinecone (vector database), Axios (HTTP requests), Zod (input validation)
- Data Source: DBpedia (structured Wikipedia data via SPARQL queries)
- Node.js (v18+)
- npm or yarn
- A Pinecone account (sign up at pinecone.io)
git clone https://github.com/your-repo/historical-event-connector.git
cd historical-event-connector/backend
npm install
- Create a Pinecone project and obtain your API key.
- Create an index named
historical-connector
with:- Dimension: 768
- Metric: Cosine similarity
Create a .env
file in the backend directory with the following:
PINECONE_API_KEY=your-pinecone-api-key
PORT=3000
CORS_ORIGIN=http://localhost:3000 # Update to your frontend URL in production
node index.js
- Node.js (v18+)
- npm or yarn
cd ../frontend
npm install
npm start
- Open your browser and navigate to http://localhost:3000.
- Enter a query in the search bar, such as:
- "What were the key events leading up to World War II?"
- "Who were the main figures in the French Revolution?"
- View the summarized results and connections displayed on the page, including events, figures, locations, and descriptions.
- Push your backend code to a Git repository.
- Import the repository into Vercel.
- Set the Framework Preset to Node.js.
- Add the following environment variables in Vercel's dashboard:
PINECONE_API_KEY=your-pinecone-api-key
CORS_ORIGIN=https://your-frontend-url.com
(replace with your frontend's production URL)
- Deploy the project.
-
Install the wrangler CLI:
npm install -g wrangler
-
Configure
wrangler.toml
with your Pinecone API key and other settings. -
Deploy using:
wrangler deploy
-
Build the React application:
npm run build
-
Host the contents of the
build
folder on a static site host such as Netlify, Vercel, or GitHub Pages. -
Update the backend's
CORS_ORIGIN
environment variable to match the deployed frontend URL.
The backend exposes the following APIs:
Check if the server is running.
Response:
{ "status": "ok" }
Retrieve a list of trending or suggested queries.
Response:
["Key events of World War II", "French Revolution connections", "American Civil War figures", "Renaissance key figures"]
Submit a query to retrieve historical connections.
Request Body:
{ "query": "your query here" }
Response:
{
"summary": "Summary of the query results",
"connections": [
{
"event": "Event name",
"figure": "Associated figure",
"location": "Location",
"year": "Year",
"description": "Brief description"
}
// ...
]
}
- The embedding function in the backend is mocked for simplicity and should be replaced with a real embedding model (e.g., Hugging Face's sentence-transformers) for production use.
- Data fetching is currently limited to World War II-related events for demonstration purposes. To expand coverage, modify the SPARQL query in the backend to include additional historical topics or use broader data sources like Wikidata.
This project is licensed under the MIT License. See the LICENSE file for details.