Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ojhaujjwal/sws-test
https://github.com/ojhaujjwal/sws-test
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ojhaujjwal/sws-test
- Owner: ojhaujjwal
- Created: 2021-07-31T12:46:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T22:38:50.000Z (8 months ago)
- Last Synced: 2024-03-26T23:38:50.282Z (8 months ago)
- Language: TypeScript
- Size: 966 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![backend-test](https://github.com/ojhaujjwal/sws-test/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/ojhaujjwal/sws-test/actions/workflows/test.yaml)
## Description
SWS API Test.## Installation
### Using Docker
1. Copy .env.dist to .env and modify appropriate values```bash
docker-compose build# Starts the app onn nwatch mode
docker-compose up -d
```### Without using Docker
It's recommended to use nvm to setup the same node version. If not, any node on v14.* should work.```bash
$ nvm use$ npm install
$ npm run start:dev
```## Running the app
```bash
# development
$ npm run start# watch mode
$ npm run start:dev# production mode
$ npm run start:prod
```## Test
```bash
# e2e tests
$ npm run test:e2e
```## Areas for Improvement
### Performance#### HTTP caching
- Using a reverse proxy in front to cache API response and reduce the load on the API server
- Use `Cache-Control` headers to tell clients to cache API response too.
- Need to be careful on not using too long caching time as we can't invalidate the cache without asking the users to explicitly remove the site cache in web browser.#### price-timeline endpoint
Optimize the SELECT query with composite index (companyId, date). Need to verify with explain analyze though.#### paginated companies endpoint
1. Paginated queries with LIMIT x,y can be slower on the later pages due to having to skip lots of rows. A more efficient method is keyset pagination, but the downside is that it doesn't offer random page access.
2. Create appropriate index for the popular querying fields based on the user's access pattern#### Elastic search instead of Views in Postgres
- Adopt [CQRS](https://barryosull.com/blog/projection-building-blocks-what-you-ll-need-to-build-projections/) to populate data in read-optimized database (like elastic search) for the specific reading use-cases (like searching)### Deployment
1. Use DB migration setup to do database changes including index creation, views creation etc.
2. Build Docker Image and Push to Container Registry
3. Deploy docker image to [cloud run](https://cloud.google.com/run)