Skip to content

Commit

Permalink
Update README.md (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan812 committed Aug 26, 2023
1 parent 0553512 commit 561555a
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,59 @@


# GitHub OpenAPI Search

The goal of this project is to provide a robust yet easy way to search Github for Swagger and OpenAPI definitions. Understanding that there is a lot of noise available, that we only care about OpenAPIs that validate, and that the Github API has rate limits that require you to automate the crawling over time. Providing a robust open-source solution that will crawl public Github repositories for machine-readable API definitions.
The project will consist of developing an open-source API that allows you to pass in search parameters and then utilize the GitHub API to perform the search, helping simplify the search interface, make rate limits visible as part of the response, and handle conducting a search in an asynchronous way, allowing the user to make a call to initiate, but then separate calls to receive results over time as results come in, helping show outcomes over time.
The goal of this project is to provide a robust yet easy way to search Github for OpenAPI and Swagger definitions. Understanding that there is a lot of noise available, that we only care about OpenAPIs that validate, and that the Github API has rate limits that require you to automate the crawling over time. Providing a robust open-source solution that will crawl public Github repositories for machine-readable API definitions.
The project will consist of developing an open-source API that allows you to pass in search parameters and then utilize the GitHub API to perform the search, helping simplify the search interface, and handle conducting a search in an asynchronous way, allowing the user to make a call to initiate, but then separate calls to receive results over time as results come in, helping show outcomes over time.

## Tech Stack

- Node JS/Express JS
- Typescript
- Octokit.JS
- Jest
- Jest (For testing)
- Docker
- Python (Scripting)

## Dev Runbook
Dependancies: NodeJS 18, npm, GithubAPIKey
## Dev Runbook
Dependancies: NodeJS 19, npm, Github APIKey
How to get a Github API Key: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

1. Pull the repository to your local setup
## Setting up OpenAPI Search with Docker Compose

1. Clone the repository to your local setup
2. Make sure you have Docker installed locally.
3. Run `docker compose up`
4. Two Containers - Elasticsearch (The database container) and an instance of the server should have started.

## Setting up the server manually

1. Clone the repository to your local setup
2. Run `npm i`
3. Make a `.env` file in the directory and add the variables:
**PORT**= **(port number you want to host the api)**
**GITHUB_API_KEY**= **(Github API key)**
**GITHUB_API_KEY**= **(github API key)**
**ES_HOST**= **(determines location of elasticsearch db)**
4. Run `npm run build:watch` on one terminal.
5. On another terminal, run `npm run start` to start the server on the port specified on.
6. Now the nodejs server should be running! To test it just go to `localhost:{{PORT}}` and the text `TypeScript With Express` should be returned.

## Setting up ElasticSearch Runbook (Dev/Local)
-**docker pull docker.elastic.co/elasticsearch/elasticsearch:8.8.2**
-**docker network create elastic**
-**docker run \
-p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
docker.elastic.co/elasticsearch/elasticsearch:8.8.2**
6. Now the nodejs server should be running! To test it just go to `localhost:{{PORT}}` and then you will be able to see the admin panel through which you can inference with some of the API's
7. Now to load the database with OpenAPI Files, run
`python scripts/seed_script.py` from the root of the folder. (Takes around 2-3hrs)

## Setting up ElasticSearch locally (Manually)
1. docker pull docker.elastic.co/elasticsearch/elasticsearch:8.8.2
2. docker network create elastic
3. docker run \
-p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
docker.elastic.co/elasticsearch/elasticsearch:8.8.2

## Loading Details
Currently, we are only indexing OpenAPI Files from the top 1000 most popular organisations from Github (Based on stars). Although more organisations can be indexed by adding them to the `scripts/assets/organisations.txt` file.


## API Endpoints
[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/19841716-f1801bb7-b189-429b-a875-91b115d349a2?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D19841716-f1801bb7-b189-429b-a875-91b115d349a2%26entityType%3Dcollection%26workspaceId%3D5ebe19fb-61d4-47a7-9cae-de3834853f6b)
- **/search?prompt={{prompt}}** : The active search endpoint. Add the search prompt in the prompt variable in query params.
- **/passive?q={}** : The passive search endpoint. Add the search prompt in the query param (q) to query the database.


🚧Under Construction

0 comments on commit 561555a

Please sign in to comment.