# YOUTUBE-AUDITS

![](https://img.shields.io/badge/Python-3.12-blue)

App for Orchard's Rights Management team to audit client YouTube channels.

The app is built with a Vue.js front-end and a FastAPI back-end. Vue.js is 
used in UMD mode, so no front-end specific build process is required. The 
reason for this is to keep the front-end and back-end in a single instance 
using the Python runtime.

Connection to this app requires Orchard's VPN.

***

#### This app is under construction.

_(This documentation will be updated as the app is developed)_

***


## Technologies

### Front-end

The front-end is a Single Page Application (SPA) built with **Vue.js** and **Quasar Framework**.
Here are the main technologies used in the front-end:

- [Vue.js](https://vuejs.org/)
- [Vue Router](https://router.vuejs.org/)
- [Quasar Framework](https://quasar.dev/) (UMD mode)
- [FastAPI](https://fastapi.tiangolo.com/) (For serving the front-end)

Additional UMD libraries used are defined in the `home.html` file.

Vanilla JS is used. Code formatting is done with `prettier.js`.

### Back-end

The back-end is built with async Python and FastAPI.

- [FastAPI](https://fastapi.tiangolo.com/) (For serving the app, both front-end and back-end)
- Check the `requirements.txt` file for the Python packages used in the back-end


Code formatting is done with `black`.\
Unit tests are written with `pytest` and `pytest-asyncio`.


Pre-commit hooks are used to perform certain actions before committing code,
namely, running `flake8`, `black`, and `isort`. If any fail, the commit is aborted.


### Database

The app uses a MySQL database, the schema of which is defined in the `db.sql` file.
Connection to it is done with `pymysql`.

The app also requires access to SME Snowflake, using `snowflake-connector-python`. 
Authentication is via a service account and using a private key.


### Security

- [Auth0](https://auth0.com/) (For JWT authentication and authorization)


### APIs

- [Youtube Content ID API](https://developers.google.com/youtube/partner) (For fetching YouTube Rights Management data). Accessed using a service account with a private key.


***

## Development

1. Clone the repository.


2. To use a local MySQL database for development, use the default connection settings in the `environment_vars.py` file. Run `db.sql` to create the database and tables.


3. **Make sure you provide all mandatory environment variables** in the `environment_vars.py` file, including YouTube CMS API credentials, Snowflake credentials, and Auth0 credentials.


4. For accessing the app via UI: make sure you have an Auth0 user for authentication. You don't need to manually create your app user linked to that Auth0 user in the MySQL `Users` table. Your app user will be created in the database automatically the first time you login in the app from the frontend.
