# Setup

Our API is 99% graphql based (the 1% accounts for the auth process involving 0Auth). All the tasks you want to command should be given as either gql queries or mutations.

# Getting Started

It's pretty simple to set up this API. Just sign up using either our frontend app or our graphql mutation.

mutation {
    signUp(new_user: {
        first_name: "Berry"
        last_name: "Allen"
        email: "berry@starlabs.lab"
        password: "ImTheFlash"
        country: "USA" # Optional
        username: "berryallen"
    }) {
        token
    }
}
1
2
3
4
5
6
7
8
9
10
11
12

You can also sign in if you have signed up before.

mutation {
    signIn(email: "berry@starlabs.lab", password: "ImTheFlash") {
        token
    }
}
1
2
3
4
5

!Notice: in both cases the mutation returns the token to be used for talking to our API. you can use this token in the Authorization header of your requests or if your client supports cookies, everything is handled by default for you.

# Installation Advanced

TIP

You can just use our API located at https://toeapi.herokuapp.com/graphql if you don't want to set up your own.

You can also get a copy of this API to run on your local machine or host. To get started:

  • clone the API repository from github.
  • Install redis using apt-get and start it as a service
sudo apt-get install redis-server && sudo service redis-server start
1
  • Install python3.6 using apt-get
 sudo apt-get install python3.6
1
  • run npm install which should install all required dependencies and compile the native node modules.
  • rename .env.sample to .env and fill out the required keys inside the file. for security purposes we can't give out actual keys
  • Finally, run the following command where LIBPYTHON_PATH is an environment variable holding the python sharable object file location and SIMILARITY_SCORE_GENERATOR_PY_FOLDER is the location where the NLP computer python file is located ( you don't need to worry about the second one because it's in /src/native/extra folder by default )
   LIBPYTHON_PATH=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so SIMILARITY_SCORE_GENERATOR_PY_FOLDER=${LOCATION_OF_PROJECT_CLONE}/src/native/extra npm run dev
1
  • Now you should have a gql server and subscription ws running on the same port 😁

# Repository directory structure

. ├── docs (Documentation) ├── src │   ├── auth (Authentication with passport) │   ├── bot (Telegram bot) │   ├── db (Utility methods for db interaction) │   │   ├── db.ts (Main Db connection initializer) │   │   ├── interest_table.ts (Utility methods for interest table) │   │   ├── keyword_table.ts (Utility methods for keyword table) │   │   ├── login_table.ts (Utility methods for login related tasks) │   │   ├── post_table.ts (Utility methods for post table) │   │   ├── token_table.ts (Utility methods for token table) │   ├── graphql (Graphql schema definitions) │   ├── model (Database table schema definitions) │   ├── native (Native modules) │   ├── post_fetchers (Social media scrappers) │   ├── queue (Bull queue definitions and Arena) │   ├── socials (Modules for social-platforms) │   │   ├── facebook.ts (Methods to talk to facebook API) │   │   ├── linkedin.ts (Methods to talk to LinkedIn API) │   │   ├── telegram.ts (Methods to talk to Telegram Bot API) │   │   ├── twitter.ts (Methods to talk to Twitter API) │   ├── README.md │  └── package.json └── Procfile (Heroku configuration) └── requirements.txt (Python dependencies) └── runtime.txt (Python runtime version) └── tsconfig.json (Typescript configuration)

# Profile

Every user in our system has a profile. Whether they are a Bot or an actual user, they will have certain properties that can be linked to them.

As you can see above, The attributes we require from a user when they first sign up are:

input IUser {
        first_name: String!, # first name is required
        middle_name: String,
        last_name: String!, # last name is required
        email: String!, # email is required
        username: String!, # username is required
        phone_number: String,
        country: String,
        last_location: String,
        password: String! # password is required
}
1
2
3
4
5
6
7
8
9
10
11

A user will also be linked with other properties such us Interest and Provider in a later time. You can access your own interests and providers using the me query.

query {
    me {
        first_name
        last_name 
        interests { 
            interest 
            score 
        } 
    }
}
1
2
3
4
5
6
7
8
9
10