2021-02-12 10:48:08 +00:00
< div align = "center" >
2021-03-09 17:20:29 +00:00
< img src = "./frontend/src/assets/logo.png" width = "250" >
< h1 >
Bullish
< / h1 >
< h4 > A simple webapp to explore Bhav Copy Equity data< / h4 >
2021-02-12 10:48:08 +00:00
< / div >
[](https://www.gnu.org/licenses/agpl-3.0)
Backend:
[](https://hub.docker.com/r/codingcoffee/bullish-backend)
[](https://hub.docker.com/r/codingcoffee/bullish-backend/tags?name=latest)
Frontend
[](https://hub.docker.com/r/codingcoffee/bullish-frontend)
[](https://hub.docker.com/r/codingcoffee/bullish-frontend/tags?name=latest)
## Usage
- Local setup is supported via Docker Compose
2021-02-12 11:47:51 +00:00

2021-02-12 10:48:08 +00:00
```sh
docker-compose up -d
```
### Build
- Build images for dev
```sh
docker-compose build
```
- Build images for prod
```sh
./prod-build.sh
```
### Logging
To get the logs of all containers
```sh
docker logs -f
```
To get the logs of a particular container
```sh
docker logs -f container-name
```
Here `container-name` can be either of `backend` , `frontend` , `redis` ,
`postgresql` , `rqworker` or `rqscheduler` .
2021-02-12 20:38:40 +00:00
### Debugging
- To goto Django's shell to debug you may use
```sh
docker-compose exec backend python manage.py shell
```
- To create migrations
```sh
docker-compose exec backend python manage.py makemigrations
```
- To run migrate
```sh
docker-compose exec backend python manage.py migrate
```
2021-02-14 11:29:35 +00:00
- To run unit tests
```sh
docker-compose exec backend python manage.py test
```
2021-02-12 20:38:40 +00:00
Similarly all django commands can be run this way.
2021-02-13 05:23:05 +00:00
## 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.
2021-02-12 10:48:08 +00:00
## Deploy
2021-02-12 11:47:51 +00:00
The recommended way for deploy is on Kubernetes. You can find the related files
2021-02-12 11:27:49 +00:00
2021-02-12 11:47:51 +00:00

2021-02-12 11:27:49 +00:00
2021-02-12 10:48:08 +00:00
in `k8s` directory.
2021-02-13 04:05:34 +00:00
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.
2021-02-12 10:48:08 +00:00
- One time deploy
```sh
# Deploy ingress
kubectl apply -f k8s/ingress/ingress-https.yaml
2021-02-13 04:05:34 +00:00
# Deploy secrets
kubectl apply -f k8s/app/secret.yaml
2021-02-12 10:48:08 +00:00
# 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
```
2021-02-13 04:05:34 +00:00
- Subsequent deploys can be done by rolloing out a restart since all pods have a `imagePullPolicy` set to `Always`
2021-02-12 10:48:08 +00:00
```sh
# Push containers to Docker Hub and Deploy to K8s
./prod-deploy.sh
```
2021-02-12 11:58:32 +00:00
## Contribution
Have better suggestions to optimize the image? Found some typos? Go ahead and send in a Pull Request! Contributions of any kind welcome!
2021-02-12 10:48:08 +00:00
## License
The code in this repository has been released under the [GNU Affero General Public License v3 ](https://www.gnu.org/licenses/agpl-3.0.en.html )
## Attributions
2021-02-14 19:10:25 +00:00
- [Bullish icon ](https://www.flaticon.com/free-icon/bull-side-view-black-animal-shape_30480 ) made by [Freepik ](https://www.freepik.com ) from [Flaticon ](https://www.flaticon.com )
2021-02-12 10:48:08 +00:00