Skip to content
fifdeePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

493 Commits

Folders and files

Repository files navigation

v45

A Django application for creating and processing digital artwork, preparing Etsy listings, and coordinating publishing workflows. The interface combines server-rendered templates with HTMX; computational work is delegated to AWS services and RunPod.

The repository contains the web application, database models and migrations, templates, and integration clients. The remote image-processing workers, cloud infrastructure, and production data are not included. Running the complete product requires those services and deployment-specific configuration.

Contents

Features

Area Implemented capabilities
Image tools Background removal, RunPod-based upscaling, cropping, and image generation through an AWS-hosted Freepik integration.
Design tools Pattern creation and repetition, text/logo composition, and reusable design templates with QR-code options.
Etsy listing creation OAuth shop connections, saved presets, titles and tags, description generation, preview images, digital and physical listing options, variations, personalization, and shipping/processing/return-policy selection.
Bulk workflows Database-backed listing queues, upload frequency settings, ZIP/PSD handling, paid file storage, and queue status/error records.
Pinterest OAuth connection, board selection, and queued pin publishing for Etsy listings.
Shop ideas OpenAI-assisted shop-name suggestions and availability-check workflows.
Accounts and credits Custom Django users, email and social authentication, user credit balances, redeemable credit packs, and per-tool usage costs.
Customizable designs Searchable design gallery, editable text/logo/QR fields, previews, and credit-controlled high-resolution downloads.
Administration Django admin, mailing tools, operational API endpoints, and an experimental Etsy automation interface.

The full-automation interface currently implements the svg_pattern generation path. Other target names appear in the code but do not have equivalent generation implementations.

Architecture

flowchart LR
    Browser[Browser: templates and HTMX] --> Django[Django web application]
    Django --> DB[(PostgreSQL)]
    Django --> Storage[S3 and CloudFront]
    Django --> AWS[AWS Lambda and API Gateway]
    Django --> RunPod[RunPod jobs]
    Django --> Providers[Etsy / Pinterest / OpenAI]
    Workers[External workers and schedulers] --> API[Django REST integration API]
    API --> DB
    API --> Django
Loading

Most image tools share the processing flow in parent/views_processing.py: read inputs and saved options, check credits, invoke a remote processor, and return an HTML result fragment. Authenticated workflows can retain image metadata and reuse earlier uploads. S3 stores file content; PostgreSQL stores users, credits, options, tokens, designs, and queue state.

parent/aws_lambda_generic.py handles direct Lambda invocation and API Gateway requests. parent/runpod_generic.py submits and polls RunPod jobs, handles terminal failures, and can recover results from S3. Its configured limits are 30 seconds per HTTP request, 120 seconds per job, and a 2-second polling interval.

Etsy queues are persisted in the database, but some processing runs in application-process threads. Callback and maintenance endpoints support external orchestration; this repository does not include a standalone queue worker or scheduler service.

Technology stack

Versions below describe the repository's declared dependencies, not a claim of compatibility with newer releases.

  • Python 3.11, as indicated by runtime.txt.
  • Django 5.1.2, Django REST Framework 3.15.2, and django-allauth 0.62.1.
  • PostgreSQL through Psycopg; the supplied settings do not select SQLite.
  • Django templates, HTMX 1.9.6, custom CSS, and browser JavaScript.
  • boto3, aiobotocore, and django-storages for AWS integration.
  • aiohttp, the OpenAI SDK, and RunPod integration code.
  • Hypercorn or Uvicorn for ASGI serving; Sentry for error reporting.

See requirements.txt for the complete dependency list. No Node.js build step is defined; htmx.web-types.json supplies editor metadata.

Repository structure

v45/
├── manage.py                  # Django management entry point
├── requirements.txt           # Python dependencies
├── runtime.txt                # Python runtime hint
├── start_command              # Collected server command examples
├── v45/                       # Settings, root URLs, ASGI/WSGI, middleware, static assets
├── parent/                    # Users, credits, uploads, shared processing and service clients
├── v45_api/                   # REST serializers, callbacks, maintenance endpoints
├── background_remover/        # Background removal
├── image_upscale/             # RunPod image upscaling
├── image_crop/                # Image cropping
├── image_generator/           # Image generation
├── pattern_maker/             # Pattern generation
├── pattern_repeater/          # Repeated pattern output
├── logo/                      # Text/logo composition
├── etsy_uploader/             # Shop connections, presets, listings, queues, paid storage
├── etsy_full_automation/      # Idea-to-listing automation
├── etsy_shop_name_generator/  # Shop-name ideas and availability
├── pinterest/                 # Boards, tokens, queued pins
├── qr/                        # Design templates, gallery, customization, download credits
├── mailing_admin/             # Mailing administration
└── templates/                 # Shared layouts, authentication, and HTMX fragments

Feature applications generally contain their own forms, models, URLs, views, templates, and migrations. v45_api is included by the root URL configuration and uses models from the other applications.

Local setup

1. Prepare Python and PostgreSQL

Clone this repository and open its root directory. Create a fresh Python 3.11 environment rather than reusing another machine's virtual environment.

Windows PowerShell

py -3.11 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt

Linux/macOS

python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

Provision a PostgreSQL database and user for development. There is no Docker Compose definition or database provisioning script in this repository.

2. Create .env

Create .env beside manage.py. The settings load this file through django-environ. The following example includes every environment variable read unconditionally by the supplied settings:

DEBUG=True
SECRET_KEY=replace-with-a-unique-development-secret

# These are read even in debug mode; see the database step below.
PGDATABASE=v45_dev
PGUSER=v45_dev
PGPASSWORD=replace-with-your-local-database-password
PGHOST=127.0.0.1
PGPORT=5432

AWS_S3_USER=replace-with-aws-access-key-id
AWS_S3_SECRET=replace-with-aws-secret-access-key
RUNPOD_API_SECRET=replace-with-runpod-key
OPENAI_API_KEY=replace-with-openai-key
FREEPIKGEN_API_KEY=replace-with-freepik-gateway-key

ETSY_CLIENT_ID=replace-with-etsy-client-id
ETSY_CLIENT_SECRET=replace-with-etsy-client-secret
ETSY_REDIRECT_URI=http://127.0.0.1:8000/listing-creator-for-etsy/auth
PINTEREST_CLIENT_ID=replace-with-pinterest-client-id
PINTEREST_CLIENT_SECRET=replace-with-pinterest-client-secret
PINTEREST_REDIRECT_URI=http://127.0.0.1:8000/pinterest/auth

API_KEY_UPSCALE=replace-me
API_KEY_REMOVE_BACKGROUND=replace-me
API_KEY_REMOVE_BACKGROUND_ISNET=replace-me
API_KEY_UPLOAD_BASE64=replace-me
API_KEY_PATTERN_MAKER=replace-me
API_KEY_PATTERN_REPEATER=replace-me
API_KEY_ETSY_UPLOADER=replace-me
API_KEY_ETSY_UPLOADER2=replace-me
API_KEY_ETSY_UPLOADER3=replace-me
API_KEY_GET_TAGS=replace-me
API_KEY_GET_TAGS_V2=replace-me
API_KEY_GET_TAGS3=replace-me
API_KEY_GET_DESCRIPTION=replace-me
API_KEY_GET_DESCRIPTION2=replace-me
API_KEY_SIZE_CHECK=replace-me
API_KEY_IMAGE_CROP=replace-me
API_KEY_MOCKUP=replace-me
API_KEY_VERIFY_URL=replace-me
API_KEY_QR_DESIGNS_PREVIEW=replace-me

Replace the values for integrations you will exercise. Nonempty placeholders can satisfy settings loading for inspection, but do not enable processing, storage, or publishing. Even legacy service keys remain mandatory because settings read them at startup. The Freepik setting is passed as an API Gateway key by the current client.

The OAuth URLs above illustrate the application's callback paths. Configure redirect URIs that the respective provider accepts and register those exact URIs with your applications.

.env is ignored by Git. The current .gitignore does not exclude virtual environments generally; keep .venv/ out of commits, for example by adding it to your local .git/info/exclude.

3. Point debug mode at your database

Setting PGHOST and the other PG* variables alone does not configure the debug database. In v45/settings.py, DEBUG=True selects a hard-coded DATABASES['debug'] connection. Update that block locally to use your development database, for example:

'debug': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': env('PGDATABASE'),
    'USER': env('PGUSER'),
    'PASSWORD': env('PGPASSWORD'),
    'HOST': env('PGHOST'),
    'PORT': env('PGPORT'),
},

Keep the existing DATABASES['default'] selection below the dictionary. A local db.sqlite3 file is not used by these settings.

4. Configure storage and remote services

Both default file storage and static-file storage use S3, including in debug mode. Before testing uploads or running collectstatic, configure resources you control:

  • Replace bucket names, the temporary-storage CDN, and related storage settings in v45/settings.py.
  • Review additional bucket references in parent/runpod_generic.py, and service URLs/function names in each application's aws_lambda.py and runpod.py.
  • Provision the corresponding Lambda/API Gateway services and RunPod workers, or obtain authorized access to compatible deployments. Their implementations are outside this repository.
  • Configure S3 permissions and browser-upload CORS for your chosen origins. The application also constructs an accelerated S3 client; confirm the target bucket supports the upload path you use.

For UI-only development, Django's local filesystem/static storage backends can be configured in a separate settings override. Such an override does not replace the explicit S3 clients or remote processing calls.

5. Initialize and start Django

After configuring a development database:

python manage.py check
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Open http://127.0.0.1:8000/. The configured admin URL is http://127.0.0.1:8000/private/admin781603/.

6. Add initial application data

Migrations create the schema, but no seed fixture or data migration for tool prices is supplied. In Django admin:

  1. Set the Sites record with ID 1 to your development host. Configure allauth Social applications for Google/Facebook if you intend to use social login.
  2. Create one UsageCost record per enabled shared-processing tool. Relevant names are background_remover, image_upscale, image_crop, image_generator, pattern_maker, pattern_repeater, logo, and etsy_uploader. Choose your own integer credit costs.
  3. Give your development user's UserProfile a credit balance. Profiles are created when users are saved; their default balance is zero.
  4. Create DesignTemplate/Design records and any required DesignCredits for the customizable-design gallery and downloads.
  5. Connect an Etsy shop through the interface before exercising listing workflows. Default Etsy presets are created by the connected-shop flow.

Debug mode sends account email to the console. Production mode uses SES SMTP.

Configuration reference

v45/settings.py is the configuration source of truth.

Group Variables Purpose
Django DEBUG, SECRET_KEY Debug behavior and Django signing. DEBUG defaults to false.
PostgreSQL PGDATABASE, PGUSER, PGPASSWORD, PGHOST, PGPORT Production database connection; also required at startup in debug mode.
AWS AWS_S3_USER, AWS_S3_SECRET Explicit credentials used for S3 and Lambda clients.
Processing All API_KEY_* entries in the example, FREEPIKGEN_API_KEY, RUNPOD_API_SECRET Remote processing and listing-service credentials.
OpenAI OPENAI_API_KEY Shop-name and automation idea generation.
Etsy ETSY_CLIENT_ID, ETSY_CLIENT_SECRET, ETSY_REDIRECT_URI Etsy application/OAuth configuration.
Pinterest PINTEREST_CLIENT_ID, PINTEREST_CLIENT_SECRET, PINTEREST_REDIRECT_URI Pinterest application/OAuth configuration.
Production hosts DOMAIN_NAME, DOMAIN_NAME_RAILWAY, DOMAIN_NAME_CLOUDFRONT, SUBDOMAINS Entries appended to ALLOWED_HOSTS when debug is disabled. Each is a single value, not a comma-separated list.
Production CSRF TRUSTED_ORIGIN, TRUSTED_ORIGIN_RAILWAY, TRUSTED_ORIGIN_WWW, TRUSTED_ORIGIN_CLOUDFRONT Trusted origins including the scheme. Values must be defined in production; unused entries can be empty.
Production email EMAIL_USER_SES, EMAIL_PASSWORD_SES SES SMTP credentials.

With DEBUG=False, all production-only variables above must be defined. SUBDOMAINS is also used to construct a wildcard HTTPS trusted origin; review the resulting host/origin values for your deployment.

Several deployment choices are hard-coded rather than environment-driven: AWS region and buckets, worker endpoints, Sentry configuration, email sender, and domain redirects. Changing .env alone does not fully retarget the application.

Using the application

Artwork to Etsy listing

  1. Sign in, ensure your profile has credits, and upload or generate artwork.
  2. Use the background remover, upscaler, cropper, or pattern tools as needed. Authenticated users can reuse stored results across tools.
  3. Open /listing-creator-for-etsy/, connect a shop, and choose a listing preset.
  4. Configure listing information, previews, files, and applicable shop policies. Review generated text and publishing options.
  5. Submit a listing or add work to the bulk queue. Inspect queue status and errors in the interface/admin.
  6. Connect Pinterest and choose a board if using the pin workflow. External orchestration must invoke the queue-publishing endpoint to publish pending pins.

Main routes

Route Purpose
/ Main interface
/background-remover/, /image-upscale/, /image-crop/ Image processing tools
/image-generator/ Image generation
/pattern-maker/, /pattern-repeater/, /logo/ Design tools
/listing-creator-for-etsy/ Etsy listing interface
/etsy-shop-name-generator/ Shop-name suggestions
/etsy-full-automation/ Experimental automation interface; content view requires an administrator
/qr/ Customizable design gallery
/user-profile/ Account and credit interface
/accounts/ django-allauth routes
/api/ REST integration routes

Pinterest's connection UI is served through /pinterest/app-content/; its OAuth callback is /pinterest/auth. See v45/urls.py and the application URL modules for individual HTMX actions.

Integration API

The REST API supports workers and operational integrations. Most endpoints require a key managed by djangorestframework-api-key:

Authorization: Api-Key <your-issued-key>

Create a key through Django admin and retain the issued value. This inbound key is separate from the outbound AWS API Gateway keys in .env.

Endpoint under /api/ Method(s) Purpose
credits-pack/ Router-generated CRUD routes Credit-pack records; API key or admin user.
design-credits/ Router-generated CRUD routes Design download credits; API key or admin user.
paid-storage-file/ Router-generated CRUD routes Paid-storage file records; API key.
uploaded-image/ Router-generated CRUD routes Uploaded-image records; API key or authenticated user.
charge-for-paid-storage/ POST Deduct storage charges from user balances.
get-shop-ids/ GET Return connected Etsy shop IDs.
verify-emails/ POST Verify submitted email addresses.
remove-queue-element/ POST Remove an Etsy queue item and continue processing.
queue-check/ POST Attempt to advance users' Etsy queues.
add-pin-queue-element/ POST Store a pending Pinterest post.
publish-pins-from-queue/ POST Publish eligible pins after checking Etsy listing state.
add-runpod-result/ POST Store a worker result by job ID.
get-runpod-result/ POST Retrieve a stored result by job ID.
give-back-credits/ POST Refund credits to a user.

All custom action endpoints in this table require an API key. Inspect v45_api/serializers.py and v45_api/views.py for exact request fields and behavior. Router registration does not guarantee every CRUD operation is fully implemented by the custom serializers.

Some endpoints return HTTP 200 with an error field on failure, so integrations must inspect response bodies. Charging and refund endpoints have no request-level deduplication: repeating a successful request can change a balance again. Schedule and retry these operations deliberately.

The uploaded-image viewset uses an unfiltered queryset and permits authenticated users. Review object-level access before exposing this API to untrusted clients.

Deployment

Deployment requires an application host, PostgreSQL, configured storage, remote processors, and any external scheduler/callback infrastructure used by your workflows.

  1. Install the Python dependencies and configure production environment variables.

  2. Replace deployment-specific domains, buckets, worker endpoints, OAuth callbacks, and email settings.

  3. Review both backend Sentry initialization in v45/settings.py and the browser SDK in templates/base_head.html. The backend enables default PII reporting when debug is disabled.

  4. Apply migrations and prepare static assets:

    python manage.py migrate
    python manage.py collectstatic --noinput
    python manage.py check --deploy

    With the supplied storage configuration, collectstatic writes to S3.

  5. Start an ASGI server. For example, on a POSIX host providing PORT:

    hypercorn --bind "0.0.0.0:${PORT:-8000}" --workers 1 --keep-alive 120 v45.asgi:application
  6. Configure HTTPS and a trusted reverse proxy to match the forwarded-host/protocol settings. Arrange external queue checks, storage charging, pin publishing, and worker callbacks as required.

start_command is a collection of command experiments, not an executable deployment script. Some examples mention servers absent from requirements.txt or enable reload. The Hypercorn command above uses a declared dependency and omits reload.

The ASGI entry point starts a memory-trimming thread that loads libc.so.6 above its memory threshold. That code assumes a glibc-based Linux runtime; it needs adaptation for Windows, macOS, or other C libraries. manage.py runserver avoids that custom ASGI entry point for local development.

Development and verification

After configuring an isolated development database and services:

python manage.py check
python manage.py showmigrations
python manage.py makemigrations --check --dry-run
python manage.py test

The existing tests.py modules are Django-generated placeholders, so test discovery currently provides no meaningful application coverage. There is no checked-in CI workflow. Database migrations, provider calls, uploads, and publishing need separate verification against development resources.

During preparation of this README, Django's system check passed using the existing Python 3.11.9 / Django 5.1.2 environment and placeholder configuration. This check did not validate a fresh dependency installation, database connectivity, migrations, cloud access, or end-to-end workflows.

Maintenance commands

Command Effect
python manage.py update_crop_field Sets crop=False on every Etsy preset.
python manage.py update_shop_name <username> <shop_name> Changes the shop name on that user's bulk queue items.
python manage.py send_discount_emails --batch-size 20 --delay 1 Sends a promotional campaign to active users with nonempty email addresses.

These commands change data or send email and are not setup steps. The discount command contains a campaign link and expiry text from 2024; inspect its recipient query and content before use.

Troubleshooting

Symptom What to check
ImproperlyConfigured names an environment variable Define every unconditionally loaded variable, including unused service keys and PG* values. Check that .env is beside manage.py.
Database connection targets an unexpected host DEBUG=True selects the hard-coded debug connection until you update it.
UsageCost matching query does not exist Add the required tool's UsageCost row with its exact application name.
Processing requests ask for credits New profiles start with zero credits; assign a development balance or redeem a credit pack.
Missing styles, failed uploads, or S3 access errors Static/media storage defaults to S3. Check bucket names, credentials, permissions, browser CORS, and CDN settings.
OAuth redirect mismatch Check the registered provider URI against the configured URI and callback path, including the absence of a trailing slash on /auth.
RunPod authentication, timeout, or missing-result errors Check the key, hard-coded endpoint, worker availability, response contract, and S3 result paths.
Listings or pins remain queued Check shop tokens, queue errors, callback delivery, and the external queue-check/publishing schedule.
DisallowedHost or CSRF failures in production Check host values, trusted origins, SUBDOMAINS, HTTPS, and proxy headers.
ASGI memory-trimming thread fails outside Linux Adapt the libc.so.6 logic or use the development server for local inspection.

Known limitations

  • External infrastructure is required. Lambda handlers, RunPod worker implementations, infrastructure definitions, scheduler configuration, and production seed data are not supplied.
  • Configuration is deployment-specific. Changing credentials alone is insufficient to migrate every bucket, URL, callback, domain, and monitoring destination.
  • Dependencies are not fully locked. The requirements mix pinned and unpinned packages. Reproducibility and dependency compatibility need validation when preparing a fresh environment.
  • Background execution needs operational care. Process-local threads do not provide durable execution across application restarts, despite the queues being stored in PostgreSQL.
  • API behavior needs hardening for broader use. Global querysets, inconsistent error statuses, and repeatable balance mutations are relevant integration constraints.
  • Automation is partial. The full-automation generation function implements only svg_pattern.
  • Repository hygiene is incomplete. Python bytecode and editor files are tracked, and the ignore file does not generally exclude virtual environments. Avoid committing local environments, credentials, or database exports.
  • Automated regression coverage is absent. The existing test stubs do not establish functional correctness.

License

No LICENSE file is included in this repository. Licensing terms have not been specified here.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages