## Technologies and Tools
- Python: The primary programming language used throughout the repository
- Flask: Web application framework used to build the CAS interface
- Google Cloud Platform (GCP): Cloud provider used for hosting, storage, and computing services
- REDCap: Research Electronic Data Capture system integrated for data management
- Firebase: Realtime database used for managing permissions, tasks, and links
- OAuth2: Authentication mechanism using Google and Microsoft OAuth
- HTML/CSS: Used for building the web interface templates
- JavaScript: Used for client-side interactivity and HTMX for dynamic page updates
## Functionality
- METRC Reports Gateway: A comprehensive Flask-based web application for managing and generating reports and data exports related to the METRC system
- Key features include secure user authentication, REDCap data export and caching, generation of analytic datasets and raw data exports, SQL query execution, invoice and payment tracking, study management, asynchronous task execution, Google Sheets integration, and secure file sharing
- The application utilizes GCP services such as Compute Engine, Cloud Storage, and Sheets API for efficient data processing and storage
## Relevant Skills
- Integration of multiple technologies and services (Flask, GCP, REDCap, Firebase)
- Implementation of secure user authentication and authorization using OAuth2 and role-based access control (RBAC)
- Efficient data retrieval and caching mechanisms for improved performance
- Asynchronous task execution using Compute Engine instances for long-running tasks
- Seamless integration with Google Sheets API for data storage and retrieval
- Generation of secure, expiring download links for file sharing
- Utilization of websockets for real-time updates in the user interface
## Example Code
- Secure user authentication using Google OAuth:
```python
def start_login(session, provider='google'):
if provider == 'microsoft':
microsoft = OAuth2Session(ms_client_id, scope=ms_scope, redirect_uri=ms_redirect_uri)
authorization_url, state = microsoft.authorization_url(ms_authorization_base_url, access_type="offline", prompt="select_account")
else:
google = OAuth2Session(client_id, scope=scope, redirect_uri=redirect_uri)
authorization_url, state = google.authorization_url(authorization_base_url, access_type="offline", prompt="consent")
session['oauth_state'] = state
return authorization_url
```
- Asynchronous task execution using Compute Engine instances:
```python
def add_task(data, empty_arg_str_to_none=False, page=None, study=None):
# ...
data['estimated_seconds_taken'] = get_task_estimate(data)
if "status" not in data.keys():
data['status'] = "Waiting for Compute Engine to come online..."
utc = pytz.utc
eastern = pytz.timezone('America/New_York')
now_utc = datetime.datetime.now(utc)
now_eastern = now_utc.astimezone(eastern)
now_str = now_eastern.strftime('%B %d, %Y %I:%M:%S %p %Z')
data["request_time"] = now_str
# ...
res = db.reference('tasks').push(data)
return res.key
```
## Notable Achievements
- Developed a comprehensive and scalable web application for managing METRC reports and data exports
- Implemented secure user authentication and authorization using industry-standard OAuth2 and RBAC
- Integrated multiple external services (GCP, REDCap, Google Sheets) seamlessly into the application
- Utilized asynchronous task execution and caching mechanisms for efficient data processing
- Designed an intuitive user interface with real-time updates using websockets and HTMX
- Contributed to the METRC project by providing a robust and secure solution for report generation and data management
Overall, the METRC Reports Gateway repository demonstrates strong skills in web application development, integration of multiple technologies, secure user authentication and authorization, efficient data processing, and user-friendly interface design. The project showcases the ability to build a comprehensive and scalable solution for managing research data and generating reports in a secure and efficient manner.