# Sunolinks

Sunolinks is a URL shortener application built with Flask. It allows users to create short, easy-to-share links and track their usage.

It is currently deployed on Render at go.suno.com (or https://glockenspiel-q184.onrender.com) using a Render managed postgres database.

## Features

- User authentication with Google OAuth
- Create custom short URLs
- Track clicks on shortened URLs
- Delete URLs
- Download URL data as CSV
- Event logging for URL clicks and deletions

## Browser Extension Setup

1. Open Google Chrome and navigate to `chrome://extensions/`.

2. Enable "Developer mode" by toggling the switch in the top right corner.

3. Download the `chrome_extension_v0.zip` file from this subdirectory or from the Releases page in the repo.

4. Drag and drop the `chrome_extension_v0.zip` file onto the Chrome extensions page.

5. The Sunolinks extension should now be installed and visible in your Chrome extensions.

6. Enter a golink into your address bar and hit enter (e.g. go/suno)

You can access the Sunolinks homepage by typing "go" or clicking on the extension icon in the Chrome toolbar


## Local Development

1. Clone the repository:
   ```
   git clone https://github.com/suno-ai/glockenspiel.git
   cd glockenspiel/sunolinks
   ```

2. Create a virtual environment and activate it:
   ```
   python -m venv venv
   source venv/bin/activate
   ```

3. Install the required packages:
   ```
   pip install -r requirements.txt
   ```

4. Set up your environment variables:
   Create a `.env` file in the project root and add the following:
   ```
   SECRET_KEY=your_secret_key
   DATABASE_URI=postgresql://username:password@localhost/sunolinks
   PROD_DATABASE=postgresql://username:password@localhost/sunolinks
   GOOGLE_CLIENT_ID=your_google_client_id
   GOOGLE_CLIENT_SECRET=your_google_client_secret
   GOOGLE_CREDENTIALS_JSON=your_google_credentials_json
   SMTP_SERVER=your_smtp_server
   SMTP_PORT=your_smtp_port
   SMTP_USERNAME=your_smtp_username
   SMTP_PASSWORD=your_smtp_password
   FROM_EMAIL=your_from_email
   ```

5. Initialize the database:
   ```
   flask db upgrade
   ```

6. Running the app:
    ```
    python Flask run
    ```
    The application will be available at `http://localhost:5000`.

## Usage

1. Log in using your Google account.
2. Create short URLs by entering the original URL and an optional custom short code.
3. View your created URLs on the main page.
4. Click on a short URL to be redirected to the original URL.
5. Delete URLs you no longer need.
6. Download backups of data as a CSV file.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
