Skip to content

GeetaKrishna/tttTest

Repository files navigation

TttClientTest

This a demo application with Node JS as Backend and Angular as frontEnd that calculates the N most frequently used words in a text file(remote file)

Getting started

Install the dependencies and build the Angular dist folder For working with Client/Angular app $ npm install $ ng build --prod

Initialise a Firebase application in the root folder $firebase init Select the option for hosting and later select the required options for rewriting the app to SPA. This also lets the user detail the application to select the folder to which the command firebase serve to look at.

Select the app name to which we need to deploy the application to.

$firebase deploy

Above command deploys the local application build to firebase.

BackEnd server (Node JS)

code is available at /server folder Run npm start for running node server. Navigate to http://localhost:3000/.

It is currently hosted on Heroku. https://pure-sierra-13501.herokuapp.com

FrontEnd server (Angular 7)

code is available at /client/tttClientTest folder Run ng serve for running the angular server locally. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

It is currently hosted on firebase. https://tttclient-97cf4.firebaseapp.com/ This hosting is done using the Github pipelining feature of Heroku, for every push to the piepelined branch, the Node app gets built and deployed.(Heroku hosting is selected as Firebase charges and doesnot let free trail users use the 3rd party API calls.)

Components

  • Server

    • An API, /api is created with help of express library. This api is responsible to get the frequency details(N) and do all the necessary operations to find the top N most words present in the string generated by accessing given URL
    • The function splitByWords() splits the string(obtained after making remote call to given URL) and returns an array of words .
    • The function createWordMap(N, wordsArray) takes in the frequency number and the array of words, gets the count of each word.
    • After grouping the words with same frequency we use the function getUnique(arr, comp) to remove duplicate entries if any.
    • Later splice the array to send only the top N most words in the text file/string.
  • Client

    • The main app Component loads the selector
    • app.component.ts is responsible for all the logical code.
    • This file has a function apiCall() which inturn has the logic to subscribe HttpClient to access the API /api and send the frequency details (N) to server.
    • the HTTPClient is injected upon importing from angular/common/http
    • app-routing.module.ts contains the route details of each component, it provides a uri to access the component/page.

Libraries and Plugins

  • Angular 7

    • HttpClient
    • Bootstrap
  • Node JS

    • Express
    • body-parser
    • cors
    • request
    • firebase-tools

Tests

  • With Input of 1 With Input of 1

  • With Input of 5 With Input of 10

  • With Input of 10 or any number above the total existing words With Input of 10

  • With Input of 100 or any number above the total existing words With Input of 100 With Input of 100

  • For inputs of negative integers or Zero (0) Unrelatable Inputs Unrelatable Inputs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published