#
HackerNews Sample Workspace
This tutorial demonstrates how to build a Curiosity Workspace using data from HackerNews. You will learn how to model the data, build a connector, and create a custom interface.
#
Overview
The HackerNews workspace indexes stories, comments, and users. It uses the HackerNews API to fetch real-time data and maps it into a graph structure for advanced exploration and search.
#
Data Model
The workspace uses a graph model to represent relationships between different entities:
- Nodes:
Story: Represents a post (id, title, url, score, time).Comment: Represents a discussion point (text, time).User: Represents a HackerNews contributor (id, karma, created).SubmissionType: Categorizes posts (e.g., AskHN, ShowHN, Job).
- Edges:
Author: ConnectsStoryorCommentto aUser.Parent: Connects aCommentto its parentStoryorComment.
#
Data Connector
The connector is built in C# and follows these steps:
- Fetch: Retrieves top stories from the
/v0/topstoriesendpoint. - Transform: Converts JSON responses into strongly-typed C# objects matching the graph schema.
- Ingest: Uses the Curiosity Library to add or update nodes and relationships in the graph.
Example snippet for creating relationships:
var storyNode = graph.AddOrUpdate(story);
var userNode = await graph.CreateUserAsync(authorId, ...);
graph.AddEdge(storyNode, userNode, "Author");
#
Custom Interface
A custom front-end built with Tesserae allows users to navigate the dataset:
- Sidebar: Custom navigation for top stories and trending users.
- Node Renderers: Custom views for
StoryandCommentnodes to display scores and threaded discussions. - Routing: Deep-linking to specific stories or user profiles.
#
Source Code
You can find the full source code for this sample on GitHub: