# Media Sharing App

This is a self-hosted media sharing and indexing platform designed for secure and flexible file sharing. Originally created to serve specific community needs, it is now made available for general use under an open-source license. The application supports file access via time-limited secret links, metadata indexing, and transcription-based search.

## Features

- **Secret Link Sharing**  
  Share folders via unique URLs with expiration dates. Two levels of sharing:
  - **Primary Folders (Secret Links):** Centralized configuration with full admin control. Suitable for public events.
  - **Subfolders (Token Links):** Can be shared ad hoc, without central admin access. Ideal for limited-audience events.

- **Transcription and Search**  
  - Local transcription of audio files
  - Full-text search through transcripts
  - Daily indexing for search via cron job required

- **Caching and Performance**  
  - Data is fetched from a remote network storage via SSH
  - Server side caching for fast repeat access
  - Automatic cache invalidation for unused files

- **Privacy-Aware Analytics**  
  - Anonymous access logging (no IP address storage)

## Requirements

- **Domain/Subdomain** for app access  
- **Dynamic DNS** for local network tunnel access  
- **Local Network Storage** (Linux server or NAS with SSH and NFS support)  
- **Virtual Private Server (VPS)** with:
  - Docker
  - SSH
  - NFS
  - Cron

## System Architecture

```plaintext
                         ┌───────────────────────────┐
                         │       Web Browser         │
                         │  (User / Admin Interface) │
                         └────────────┬──────────────┘
                                      │
                         ┌────────────▼──────────────┐
                         │    HTTPS (Secret Link)    │
                         │        (Traefik)          │
                         └────────────┬──────────────┘
                                      │
                         ┌────────────▼──────────────┐
                         │      Flask App (VPS)      │
                         │       Routing Layer       │
                         └────────────┬──────────────┘
                                      │
                         ┌────────────▼─────────────┐
                         │                          │
                ┌────────▼────────┐        ┌────────▼─────────┐
                │  User Views /   │        │ Admin Interface  │
                │   Token Logic   │        │  (Protected Link)│
                └────────┬────────┘        └────────┬─────────┘
                         │                          │
                 ┌───────▼──────────────────────────▼──────┐
                 │      Link Validation & Expiry Logic     │
                 └───────────────────┬─────────────────────┘
                                     │
                       ┌─────────────▼──────────────┐
                       │        Caching Layer       │
                       │     (Local file cache)     │
                       └─────────────┬──────────────┘
                                     │
                       ┌─────────────▼──────────────┐
                       │   SSH Tunnel to Storage    │
                       │   (NAS or Linux Server)    │
                       └─────────────┬──────────────┘
                                     │
                       ┌─────────────▼──────────────┐      ┌─────────────────────────────┐
                       │    Local File System       │◄─────┤ Media File Transcriber (PC) │
                       └─────────────┬──────────────┘      └─────────────────────────────┘
                                     │
                       ┌─────────────▼──────────────┐      
                       │ Daily Cron Service         │
                       │   - Index Filesystem       │      
                       │   - Index Transcription    │
                       └─────────────┬──────────────┘
                                     │
                           ┌─────────▼──────────┐
                           │   Search Engine    │
                           └────────────────────┘
```

- Files are served over an SSH tunnel from NAS to the VPS.
- Caching and indexing are performed on the VPS for performance.
- Admin and user features are activated via special access links.

## Setup Instructions

### 1. Clone the Repository to your VPS

```bash
git clone https://gitea.centx.de/lelo/bethaus-app
cd your-app
```

### 2. Configure Your Environment

Copy example config files and customize them for your setup:

```bash
cd your-app
cd example_config_files
cp * ../
```

### 3. Change Configurations

- `.env`  
  Used by Docker Compose to manage environment variables.

- `app_config.json`  
  General settings including search, link expiration, and admin key.  
  **Important:** Replace default keys with strong random strings and keep them secret.

- `folder_mount_config.json`  
  Used if you set up `cron` to auto-mount folders.

- `folder_secret_config.json`  
  Contains paths and secrets to the shared folders.  
  Add your first entry manually, then use the admin UI for further setup.

- `transcription_config.yml`  
  Required for local transcription. Adjust based on your tools and resources.

### 4. Launch the App

```bash
docker compose up -d
```

### 5. Admin Access

To unlock administrative controls on your device, use the dedicated admin access link.

## Contribution

This app is under active development and contributions are welcome.
If you'd like to adapt it for your own community or project, feel free to fork the repo and reach out for setup help.
