# streamlit-fansifter-backoffice-app
Collection of Streamlit apps to handle Fansifter/CRM related background activities. application_family: fansifter


**Development**
* Run `make run_streamlit_locally` to spin up Streamlit app locally in your machine.

* Run `make deploy_dev_streamlit_app` to deploy Streamlit app to your own Snowflake schema. Make sure to use correct schema.

* Run `make drop_dev_streamlit_app` to drop Streamlit app from your own Snowflake schema and also drop related stage.

* Run `make qa_deploy_streamlit_app` to deploy Streamlit app to the shared QA schema.

* Run `make vendor` to re-download vendored Python packages into `app/vendor/`. These are packages not available in Snowflake's Anaconda channel that are bundled directly with the app. Run this after upgrading any vendored package version in the Makefile.


**Running locally:**
- for local run, Streamlit will try to connect to Snowflake using Snowpark and connection defined in connections.json file.
- When Streamlit has been deployed to Snowflake then Snowflake itself will take or Snowpark connection creation.

**Deploying to DEV/QA:**
- When you run `make deploy_dev_streamlit_app`, Streamlit app will be stored in your schema. The connection should be defined in the file that Snowflake CLI can access. Read more from here: https://docs.snowflake.com/en/developer-guide/snowflake-cli/connecting/configure-cli

**Deploying to PROD:**
- When you merge PR then Jenkins pipeline will be triggered that will use Snow CLI to 
replace Streamlit app in the FANSIFTER_APP_REPORTING.PROD_FANSIFTER_BACKOFFICE_STREAMLIT schema.

**Git hooks**
- Run `git config core.hooksPath .githooks` once after cloning to activate the pre-push hook.
- The hook runs `make fmt` and `make lint` before every push. If the formatter modifies files, the push is blocked — stage the changes and re-push.

**Testing**
- Calls to Snowflake are implemented using Snowflake's Local testing framework: https://docs.snowflake.com/en/developer-guide/snowpark/python/testing-locally

**Visual reprsentation of deployment options**

![Deployment Options](deployments.png)

**User permissions**
- data/permissions.csv contains list of Snowflake usernames and access to 
specific Streamlit page in this app:
  - CCPA
  - FAN_LOOKUP
  - BULK_DELETE

****Vibe coding****
- Snowflake Cortex was used to implement CCPA page, Fan lookup page and bulk delete page. For that initial 
instruction was provided in the files in the objectives folder.
