Git Product home page Git Product logo

populationmanagementsystem's Introduction

PopulationManagementSystem

CircleCI Maintainability Test Coverage

This is an poplutation management api that enables one add locations and the number of residents in each location distributed by gender. This application is built using NodeJS, Express, Typescript and MongoDB

Requirements

In order to run this project locally you would need to have:

  • Node (Best to install v10.4.0). You can use NVM to install and manage node versions on your machine
  • MongoDB (For this project I used a docker image of mongoDB.)
  • Docker (if you plan to setup mongoDB to run in a docker image)
  • Yarn - After installing node install Yarn globally by running
npm -g install yarn

Setting up MongoDB to run in docker

You can run a docker image of mongo DB using docker run -p 27017:27017 mongo:3.4.20-jessie This command will download the specified mongo image if it does not exist locally and run the image. For this case am running the image mongo:3.4.20-jessie but you can get a list of mongo images here. The -p 27017:27017 specifies that the running image is being exposed on port 27017

Setup

  1. Clone the repository
    git clone https://github.com/malmike/PopulationManagementSystem.git
    
  2. Enter the directory and install the project dependencies
    cd PopulationManagementSystem
    yarn install
    
  3. Rename sample.env to .env
    mv sample.env .env
    
  4. Start mongodb service.
    • If you install mongodb locally run
      mongod
      
      If you require authentication
      sudo mongod
      
    • If you setup mongodb to run in docker then just ensure that the image is running
      docker container ls
      
      If the image is not running then run the command
      docker run -p 27017:27017  mongo:3.4.20-jessie
      
    Ensure that the .env file contains the value DB_URI=mongodb://localhost:27017/population_management_system
  5. Starting the application
    yarn start-dev
    
    The development environment is setup to allow live reloading using nodemon
  6. You can access the application in the browser
    http://localhost:1337
    
    The API uses swagger for documentation and this can be accessed at
    http://localhost:1337/api-docs/
    

Testing

To execute the applications tests run

yarn test

To execute tests with coverage run

yarn test-coverage

Endpoints

TYPE API ENDPOINT DESCRIPTION HEADERS PAYLOAD
POST /registerUser Creates a user or signs in a existing user content-type: applicaton/json
      {
        "email": "string",
        "password": "string
      }
      
GET /getUser Gets logged in user content-type: applicaton/json
x-access-token: token
POST /addLocation Add location content-type: applicaton/json
x-access-token: token
      {
        "name": "string",
      }
      
GET /getLocations Gets all locations content-type: applicaton/json
x-access-token: token
GET /getLocation?name="test" Gets location test content-type: applicaton/json
x-access-token: token
PUT /addSubLocation?name="test" Add sublocation to location test content-type: applicaton/json
x-access-token: token
      {
        "sub_location_name": "string"
      }
      
PUT /deleteSubLocation?name="test" Delete sublocation from location test content-type: applicaton/json
x-access-token: token
      {
        "sub_location_name": "string"
      }
      
POST /addPopulationSize?name="test" Add population size to location test content-type: applicaton/json
x-access-token: token
      {
        "males": 0,
        "females": 0
      }
      
GET /getPopulationSize?name="test" Get population size from location test content-type: applicaton/json
x-access-token: token
PUT /updatePopulationSize="test" Update population size of location test content-type: applicaton/json
x-access-token: token
      {
        "males": 0,
        "females": 0
      }
      

populationmanagementsystem's People

Contributors

malmike avatar

Watchers

 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.