Coder Social home page Coder Social logo

kyrcha / npm-miner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from authecesofteng/npm-miner

3.0 2.0 0.0 833 KB

Static code analysis of the npm registry

Home Page: http://npm-miner.com

License: MIT License

HTML 1.04% CSS 0.09% JavaScript 97.22% R 0.34% Dockerfile 1.31%
npm mining-software-repositories nodejs reactjs expressjs express mongodb docker docker-compose quality-metrics static-code-analysis javascript nginx

npm-miner's Introduction

npm-miner

Static code analysis of the npm registry.

npm-miner is maintained on the fork: https://github.com/kyrcha/npm-miner.

The docker-compose.yml contains the services needed by the npm-miner to work. These are:

  • nginx for a web server
  • rabbitmq for a worker queue
  • mongodb and mongo-express for the database and a web client for it

The developed services include:

  • the front-end in react
  • the back-end in node
  • the workers in node:
    • the crawler
    • the analyzers

The workers above are handled with pm2 module.

Architecture and data-flow

Front-facing there is Nginx that handles the web traffic and serves the React.js built Single Page Application (SPA). The SPA sends REST API requests to the node.js-express back-end server. The back-end server on its turn queries the MongoDB for the requested data and sends them back to the front-end for viewing.

On the mining side, the Crawler through a cron job, every ten minutes requests a random page of 100 packages from the CouchDB of the npm-registry. Immediatelly it sends 100 messages with the package.json files of the packages to the RabbitMQ to be consumed by the workers. The workers request metadata from GitHub and the analysis of npms.io and then download the tarball from the link provided in the latest package.json file and perform the static code analysis, storing the results in the MongoDB.

Deploy

Local for development

Make sure: back-end/.env, front-end/.env are set

The application runs in three shells:

  1. Run: docker-compose --file docker-compose-dev.yml up --force-recreate
  2. cd back-end && npm run dev
  3. cd front-end && npm start

Check localhost:3000

Test Locally the Docker compose deployment

Make sure: .env is set in the root folder of the project and run

docker-compose -f docker-compose-stage.yml up --build --force-recreate

Check localhost:8080

Production Deployment

In the production server, pull the latest code and run:

docker-compose up --build -d

Check npm-miner.com

Mongo dump and restore

In production:

  1. docker exec npm-miner-mongo mongodump --uri="mongodb://<username>:<password>@mongodb:27017/npmminer?authSource=admin" --collection=packages
  2. docker exec -it ac00db5fb263 bash and tar the dump dir (tar -cf dump.tar dump/)
  3. docker cp ac00db5fb263:/dump.tar .
  4. docker exec -it ac00db5fb263 bash and delete the tarfile and the dump dir

then scp in development

In development:

  1. docker cp dump.tar npm-miner_mongo_1:/tmp/
  2. docker exec -it npm-miner_mongo_1 bash and untar (tar -xvf /tmp/dump.tar)
  3. docker exec npm-miner_mongo_1 mongorestore /dump --uri="mongodb://<username>:<password>@localhost:27017/npmminer?authSource=admin"
  4. Delete the dump directory and the tar file

npm-miner's People

Contributors

kyrcha avatar

Stargazers

Zeng Jia avatar  avatar  avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.