Bullish - A simple Vue webapp to explore Bhav Copy Data https://bullish.codingcoffee.me
Find a file
Ameya Shenoy dc6e8ca736
fix: date format
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
2021-02-15 00:15:47 +05:30
.assets/images docs: dev architecture 2021-02-12 17:17:51 +05:30
backend fix: cronjob to only run on weekdays 2021-02-14 23:15:00 +05:30
frontend fix: date format 2021-02-15 00:15:47 +05:30
k8s fix: move secrets to a k8s secret 2021-02-13 09:37:06 +05:30
dev.env chore: pick backend settings from env vars 2021-02-11 22:43:00 +05:30
docker-compose.yml feat: productionize images for deploy 2021-02-12 00:58:26 +05:30
LICENSE.txt feat: initial commit with todo and license 2021-02-09 01:37:51 +05:30
prod-build.sh feat: productionize images for deploy 2021-02-12 00:58:26 +05:30
prod-deploy.sh chore: script for deploy 2021-02-12 15:54:29 +05:30
README.md fix: verify date with TDD 2021-02-14 16:59:35 +05:30
TODO.org fix: frontend stock page 2021-02-13 04:05:27 +05:30

License: AGPL v3

Backend: Docker Pulls - Backend Docker Image Size Backend (tag)

Frontend Docker Pulls - Frontend Docker Image Size Frontend (tag)

Usage

  • Local setup is supported via Docker Compose

Development Architecture

docker-compose up -d

Build

  • Build images for dev
docker-compose build
  • Build images for prod
./prod-build.sh

Logging

To get the logs of all containers

docker logs -f

To get the logs of a particular container

docker logs -f container-name

Here container-name can be either of backend, frontend, redis, postgresql, rqworker or rqscheduler.

Debugging

  • To goto Django's shell to debug you may use
docker-compose exec backend python manage.py shell
  • To create migrations
docker-compose exec backend python manage.py makemigrations
  • To run migrate
docker-compose exec backend python manage.py migrate
  • To run unit tests
docker-compose exec backend python manage.py test

Similarly all django commands can be run this way.

Endpoints

There are 5 available endpoints:

  1. Empty Response Endpoint - to intentionally get an empty response from the server
  2. Directly from BSE - fetchs the data directly from the BSE website
  3. Postgres Endpoint - fetches the data from Postgres
  4. Redis Cache and Redis Cache v2 - both fetch data from redis, however there is a slight differece in the way they store data.
    • In the 1st case a LIST is stored maintainig the list of stocks for a given day, and a HASHMAP for every stock is stored
    • In the v2 endpoint, the entire JSON response for a day is stringified and stored The reason for implemnting two different endpoints, was to just check the response times.

Deploy

The recommended way for deploy is on Kubernetes. You can find the related files

Production Architecture

in k8s directory.

Before deploy create a secret.yaml file in k8s/app, with base 64 encoded secrets. A sample file named sample-secret.yaml has been committed listing all the required variables. Change the secrets preset in the file before using it.

  • One time deploy
# Deploy ingress
kubectl apply -f k8s/ingress/ingress-https.yaml

# Deploy secrets
kubectl apply -f k8s/app/secret.yaml

# Deploy Postgres and Redis DB
kubectl apply -f k8s/app/redis.yaml
kubectl apply -f k8s/app/postgres.yaml

# Deploy Backend
kubectl apply -f k8s/app/backend.yaml
kubectl apply -f k8s/app/rqworker.yaml
kubectl apply -f k8s/app/rqscheduler.yaml

# Deploy Frontend
kubectl apply -f k8s/app/frontend.yaml
  • Subsequent deploys can be done by rolloing out a restart since all pods have a imagePullPolicy set to Always
# Push containers to Docker Hub and Deploy to K8s
./prod-deploy.sh

Contribution

Have better suggestions to optimize the image? Found some typos? Go ahead and send in a Pull Request! Contributions of any kind welcome!

License

The code in this repository has been released under the GNU Affero General Public License v3

Attributions