GitHub is the site you're on right now! It has an API which you can use to get data about almost anything GitHub.
This is a rich source of interconnected data that we can store in TypeDB and query elegantly with TypeQL.
- Checkout this repository:
git clone https://github.com/vaticle/typedb-driver-examples && cd typedb-driver-examples
- Start the TypeDB Server.
- Build the project:
bazel build //software/github/...
- Run the application:
bazel run //software/github:github-bin-{YOUR_OS}-{YOOUR ARCH}
whereYOUR_OS
iswindows
,mac
orlinux
andYOUR ARCH
isx86_64
orarm64
.
Now you can use the application to explore any GitHub repository. If you don't want to set up GitHub access tokens,
explore an example repository by entering vaticle/typedb
into the prompt.
You can also use TypeDB Studio to explore the data. Connect to
localhost:1729
and open the github
database in TypeDB studio. See the example queries below for ideas.
For this short example, we create and import a stripped down version of a repository. An abbreviated example of the data model is shown below.
{
"repo": {
"id": 63110867,
"name": "typedb",
"description": "TypeDB: a strongly-typed database",
"author": "vaticle"
},
"users": [
{
"name": "vaticle"
},
{
"name": "jmsfltchr"
},
{
"name": "flyingsilverfin"
}
],
"commits": [
{
"author": "jmsfltchr",
"hash": "d51dca7bb0dd2839ea804eb0531bbf18834c3f90",
"date": "Mon Jun 13 16:13:16 BST 2022",
"files": [
"reasoner/controller/ConcludableController.java",
"reasoner/controller/ConclusionController.java",
"reasoner/controller/ConditionController.java",
"reasoner/controller/DisjunctionController.java",
"...",
]
},
{
"author": "jmsfltchr",
"hash": "91013b15c94b6804361ad9c7b6fe5f16977d7b48",
"date": "Mon Jun 13 09:20:31 BST 2022",
"files": [
"..."
]
},
{"..."}
],
"files": [
"common/iterator/sorted/SortedIterators.java",
"common/exception/ErrorMessage.java",
"traversal/procedure/ProcedureVertex.java",
"traversal/procedure/CombinationProcedure.java",
"reasoner/processor/AbstractRequest.java",
"reasoner/processor/AbstractProcessor.java",
"..."
]
}
All of these queries are available through github.state.Explorer and the compose-jb application.
match $file isa file, has file-name "FILE_NAME_HERE";
$file-collaborator(file: $file, collaborator: $c) isa file-collaborator;
$c has user-name $x;
get $x;
match $user isa user, has user_name "USER_NAME_HERE";
$commit_author(commit: $commit, author: $user) isa commit_author;
$commit_file(file: $file, commit: $commit) isa commit_file;
$file has file_name $x;
get $x;
match $repo isa repo, has repo_name "REPO_NAME_HERE";
$commit_repo(commit: $commit, repo: $repo) isa commit_repo;
$commit_author(commit: $commit, author: $author) isa commit_author;
$author has user_name $x;
get $x;
match $user isa user, has user_name "USER_NAME_HERE";
$commit_author(commit: $commit, author: $user) isa commit_author;
$commit_repo(repo: $repo, commit: $commit) isa commit_repo;
$repo has repo_name $x;
get $x;
match $commit isa commit, has commit_hash "COMMIT_HASH_HERE";
$commit_file(commit: $commit, file: $file) isa commit_file;
$commit_file2(commit: $commit2, file: $file) isa commit_file;
$commit_author(commit: $commit2, author: $author) isa commit_author;
$author has user_name $x;
get $x;
match $file isa file, has file_name "FILE_NAME_HERE";
$commit_file(commit: $commit, file: $file) isa commit_file;
$commit_file2(commit: $commit2, file: $file) isa commit_file;
not {$commit_file is $commit_file2;};
get $commit_file; count;