Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Reorganize repository structure for better organization and cleaner root directory

Murtaza Nasird139393c7764
diff --git a/Dockerfile b/Dockerfile
index f765b4d3..bd88f252 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -25,7 +25,7 @@ ENV SQLALCHEMY_DATABASE_URI=sqlite:////data/instance/transcriptions.db
ENV UPLOAD_FOLDER=/data/uploads
# Add entrypoint script
-COPY docker-entrypoint.sh /usr/local/bin/
+COPY scripts/docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose the port
diff --git a/README.md b/README.md
index c51f1f2f..e22688f5 100644
--- a/README.md
+++ b/README.md
@@ -292,10 +292,10 @@ Follow these steps if you want to modify the code or build the Docker image your
cd speakr
```
2. **Create Configuration Files:**
- Copy the example files. Use `env.whisper.example` for the standard API method or `env.asr.example` for the ASR webservice method.
+ Copy the example files. Use `config/env.whisper.example` for the standard API method or `config/env.asr.example` for the ASR webservice method.
```bash
cp docker-compose.example.yml docker-compose.yml
- cp env.whisper.example .env # Or cp env.asr.example .env
+ cp config/env.whisper.example .env # Or cp config/env.asr.example .env
```
Edit the `.env` file with your custom settings and API keys.
diff --git a/env.asr.example b/config/env.asr.example
similarity index 100%
rename from env.asr.example
rename to config/env.asr.example
diff --git a/env.whisper.example b/config/env.whisper.example
similarity index 100%
rename from env.whisper.example
rename to config/env.whisper.example
diff --git a/deployment/setup.sh b/deployment/setup.sh
index 38b484ee..5a469f4f 100755
--- a/deployment/setup.sh
+++ b/deployment/setup.sh
@@ -10,8 +10,8 @@ sudo chown $USER:$USER /opt/transcription-app
cp app.py /opt/transcription-app/
cp -r templates /opt/transcription-app/
cp requirements.txt /opt/transcription-app/
-cp reset_db.py /opt/transcription-app/
-cp create_admin.py /opt/transcription-app/
+cp scripts/reset_db.py /opt/transcription-app/
+cp scripts/create_admin.py /opt/transcription-app/
cp .env /opt/transcription-app/ # Copy the .env file with API keys
# Add SECRET_KEY to .env file if it doesn't exist
diff --git a/docker-compose.example.yml b/docker-compose.example.yml
index 96506d50..1533f0aa 100644
--- a/docker-compose.example.yml
+++ b/docker-compose.example.yml
@@ -14,10 +14,10 @@ services:
# 2. Copy the corresponding example file to .env:
#
# For standard Whisper API:
- # cp env.whisper.example .env
+ # cp config/env.whisper.example .env
#
# For a custom ASR endpoint:
- # cp env.asr.example .env
+ # cp config/env.asr.example .env
#
# 3. Edit the .env file to add your API keys and settings.
env_file:
diff --git a/DEPLOYMENT_GUIDE.md b/docs/DEPLOYMENT_GUIDE.md
similarity index 100%
rename from DEPLOYMENT_GUIDE.md
rename to docs/DEPLOYMENT_GUIDE.md
diff --git a/create_docs.py b/docs/create_docs.py
similarity index 100%
rename from create_docs.py
rename to docs/create_docs.py
diff --git a/create_admin.py b/scripts/create_admin.py
similarity index 96%
rename from create_admin.py
rename to scripts/create_admin.py
index 1db4a075..3ff374de 100644
--- a/create_admin.py
+++ b/scripts/create_admin.py
@@ -5,6 +5,9 @@ import sys
import getpass
from email_validator import validate_email, EmailNotValidError
+# Add parent directory to path for imports
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
# Try to import from app context
try:
from flask import current_app
diff --git a/docker-entrypoint.sh b/scripts/docker-entrypoint.sh
similarity index 93%
rename from docker-entrypoint.sh
rename to scripts/docker-entrypoint.sh
index 683169d5..decda695 100644
--- a/docker-entrypoint.sh
+++ b/scripts/docker-entrypoint.sh
@@ -18,7 +18,7 @@ fi
# Check if we need to create an admin user (regardless of whether the database exists)
if [ -n "$ADMIN_USERNAME" ] && [ -n "$ADMIN_EMAIL" ] && [ -n "$ADMIN_PASSWORD" ]; then
echo "Creating admin user using environment variables..."
- python docker_create_admin.py
+ cd /app && python scripts/docker_create_admin.py
fi
# Start the application
diff --git a/docker_create_admin.py b/scripts/docker_create_admin.py
similarity index 96%
rename from docker_create_admin.py
rename to scripts/docker_create_admin.py
index b071fc45..fcfba548 100644
--- a/docker_create_admin.py
+++ b/scripts/docker_create_admin.py
@@ -4,6 +4,9 @@ import os
import sys
from email_validator import validate_email, EmailNotValidError
+# Add parent directory to path for imports
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
# Try to import from app context
try:
from flask import current_app
diff --git a/migrate_docker.sh b/scripts/migrate_docker.sh
similarity index 100%
rename from migrate_docker.sh
rename to scripts/migrate_docker.sh
diff --git a/migrate_existing_recordings.py b/scripts/migrate_existing_recordings.py
similarity index 100%
rename from migrate_existing_recordings.py
rename to scripts/migrate_existing_recordings.py
diff --git a/parse_asr_json.py b/scripts/parse_asr_json.py
similarity index 100%
rename from parse_asr_json.py
rename to scripts/parse_asr_json.py
diff --git a/reset_db.py b/scripts/reset_db.py
similarity index 98%
rename from reset_db.py
rename to scripts/reset_db.py
index e7a2db77..08f72e61 100644
--- a/reset_db.py
+++ b/scripts/reset_db.py
@@ -5,7 +5,7 @@ import os
import sys
import shutil
# Add project root to path if necessary for 'app' import
-# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
# Load environment variables in case DB path relies on them (optional here)
# from dotenv import load_dotenv
diff --git a/resize_logo.py b/scripts/resize_logo.py
similarity index 100%
rename from resize_logo.py
rename to scripts/resize_logo.py
diff --git a/resize_logo.sh b/scripts/resize_logo.sh
similarity index 100%
rename from resize_logo.sh
rename to scripts/resize_logo.sh
diff --git a/update_version.py b/scripts/update_version.py
similarity index 100%
rename from update_version.py
rename to scripts/update_version.py
diff --git a/test_inquire_mode.py b/tests/test_inquire_mode.py
similarity index 100%
rename from test_inquire_mode.py
rename to tests/test_inquire_mode.py
diff --git a/test_json_fix.py b/tests/test_json_fix.py
similarity index 100%
rename from test_json_fix.py
rename to tests/test_json_fix.py
diff --git a/test_json_preprocessing.py b/tests/test_json_preprocessing.py
similarity index 100%
rename from test_json_preprocessing.py
rename to tests/test_json_preprocessing.py
diff --git a/test_json_standalone.py b/tests/test_json_standalone.py
similarity index 100%
rename from test_json_standalone.py
rename to tests/test_json_standalone.py