Simple Node.js/MongoDb and Vue.js app which scrapes and analyze instagram(IG) professional accounts.
To run this locally, you need Node.js > 9, a mongoDB cloud instance using atlas and a google service account.
-
PS: For testing purpose, the app is currently created with a test instance I made. If you don't wish to create an instance, you can just use the already configure one.
-
If you wish to creat your own instance then continue with the steps below:
-
Set MongoDB atlas instance from here:
-
get a database user's name and password and insert those on the
./config/config.ts
file in the variablesdb_user
anddb_password
respectively.
-
The purpose of the google service account is to be able to access google vision API, which advises against using an API key instead of a service account.
-
Please follow the link below and perform ONLY steps (1) and (2):
-
Also enable the Google Vision API for the google project you created.
-
Remember that step (2), ONLY works in the current session of the terminal. That is, if you set the google application credentials on terminal window and later close that particular terminal window, you will need to run it again in the new terminal window inorder to access the API.
Navigate to a chosen folder:
- Clone the repository:
git clone https://github.com/giresse19/modash.git
Back-end:
cd modash/server
$ npm install
$ npm run server
-
App should be exposed at http://localhost:3000 and connected with mongoDB(via mongoDB atlas)
-
windows users, if you're getting this annoying npm error: openssl config failed: error:02001002:system library:fopen:No such file or directory
Please check the link below for a fix:
Purpose | URL |
---|---|
404 page | http://localhost:3000/anypage |
Posting instagram user to server | http://localhost:3000/analyze/username (you may use postman to perform this action setting body to "raw") |
Get all instgram accounts in DB | http://localhost:3000/api/v1/all |
Get specific profile details | http://localhost:3000/api/v1/profile?name="username" |
File | Comment |
---|---|
.editorconfig |
IDE styler (see http://editorconfig.org/) |
.eslintrc.ts |
ESLint Rules, including ES6 and some best practices |
.gitignore |
Ignoring node_modules |
tsconfig.json |
typescript config file |
Readme.md |
This file |
package.json |
NPM data including node and npm engine versions |
- Main entrance point, also defined as this on
package.json
- Catches all exceptions and logs, preventing errors to crash process
- Shows stack traces of exceptions in development env.
- Uses
process.env.PORT
to define listen port, fallbacks to3000
- listens to
./app.js
- Isolated Express App (without the server).
- It has only one custom middleware that
- Sets response header for JSON
- Creates a function to return APIs in
{status:200, data: ...}
format
- It sets
Access-Control-Allow-Origin
to*
to avoid CORS issues. - It has 3 public API which uses
services folder
. - The 3 services accepts usernames via http POST, provides endpoints to access all users in DB, provide specific user profile in DB.
- instantiate a mongoDB connection.
- It has a fallback route for 404.
- It has an Error route to catch uncaught errors.
- Mongoose connection starts here
- Mongoose models and their schemas are defined and exported here
- Uses
src/models
to get Mongoose Models - Connects to mongoDB atlas (https://cloud.mongodb.com/v2/5ea07fec9dae766e6eb7205f#metrics/replicaSet/5ea08375d1169842708bdf44/explorer)
- Config for mongoDB atlas is found here
- Contains all global configurations and variables used in the App here too.
- get a database user's name and password and insert in the variables
db_user
anddb_password
respectively.
- Utility methods to fetch data from instagram with instagram
username
, get insights with media gotten from fetched instagram user from google vision API is located here. - All subroutines are seperated as functions including Checks and Data conversions
- Utility methods to scrape the media data returned from instagram API and prepare it in the correct format inorder to get image insights from google API.
- Has utility methods to parse media comments by
#
and@
inorder for them to be stored in a suitable data structure in the DB.
- Contains endpoint for accepting HTTP POST IG
username
and calls theservice.profile
method in the servie inorder to store user profile to DB. - Validate's username entered and return an error is name is missing in query params.
- Main App logic is here
- Contains 3 exported services (see
module.exports =
) - All subroutines are seperated as functions including Checks and Data conversions and handled in
helper
folder - Saves user information to MongoDB.
front-end:
cd modash/client/modash
$ npm install
$ npm run serve
- Navigate to: http://localhost:8080 to view app
File | Comment |
---|---|
.babel.config.js |
babel configurations defined here. |
.gitignore |
Ignoring node_modules |
package.json |
NPM data including node and npm engine versions |
- Logic, template and style for header component is found here.
- Header component is found on every other page.
- Template and style for
users list
is found here. - Displays a message when no User has been added in the DB.
- Imports user list state from store.
- Fires
fetchUsers
action upon creation.
- Logic, template and style for an
user
profile is found here. - Displays an SVG loading animation when data is being fetched.
- Displays an error message to the UI, upon failure, while fetching a
user
. - Fires an action to fetch an
user
when mounted to DOM.
- Logic for fetching
users list
is found here. - Contains user list state, action creators
- Entry point of view app.
- Contains configurations used by the app, such as store and routing
- Has route definitions defined to be use in(only in)
App.vue
- Wrapper component for other components.
- Contains default styling used in app.
- Imports other components to be rendered here.
- Contains images used in the app.
- Has SVG file used as a loading animation during fetching of data from API.
- Single HTML file used in the app.
- Contains the div
ID
used by the application to render different views.