Coder Social home page Coder Social logo

zipcode-project's Introduction

Setup:

locally

Node version: 12 (it may work in the most recent versions)

Install dependencies:

npm ci                     # install dependencies

Database setup:

docker compose up -d       # start the database
npm run migrate:deploy     # apply pending migrations to database
npm run db-script          # populate database

GraphQL server:

npm run dev                # run in dev mode

Aditionally, the project contains two main unit tests (when zipcode exists and when zipcode does not exist). To run the tests, execute:

npm run test

Usage:

Query:

query  {
  getZipCodeInfo(zipCode: "20710") {
    city
    county
  }
}

Result example:

{
  "data": {
    "getZipCodeInfo": {
      "city": "Bladensburg",
      "county": "Prince George's County"
    }
  }
}

Notes:

Data

  • For convenience, I used an online tool to convert from CSV format to JSON. This data is stored in data/zipCode.ts. Then, I created the script src/db-script.ts to populate data into the database (Postgres).

Improvements:

Security

Authentication: To prevent any service abuse, we can require users to authenticate. For each user, we can implement a throttling mechanism so each one has a limited amount of resources (number of requests, server time, query complexity, etc.)

Testing

Integration testing: Test the endpoint with a real connection to the database. This will ensure the database has the correct data and there is communication between GraphQL server and database.

CI/CD

CI: run post commit webhooks (static analysis, unit test, code formatting)

CD: implement Continuous Deployment (eg. with Github Actions, Jenkins, etc)

Performance

Cache Layer: Avoid requests to the database by using an in-memory cache (eg. Redis)

zipcode-project's People

Contributors

keyvhinng avatar

Stargazers

Roman 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.