# KRUSHNA STORE

A responsive APK marketplace with an APKPure-inspired dark UI, public browsing/search/category filters, APK downloads, and a token-protected admin upload/delete console.

## Hosting recommendation: Cloudflare Workers + static assets + D1 + R2

This is a real backend project, not a localStorage-only mockup:
- Workers serves the site and API.
- D1 stores app listing metadata.
- R2 stores APKs and icons.
- `ADMIN_TOKEN` is a Worker secret; visitors cannot upload/delete without it.

Cloudflare Workers Free currently documents 100,000 requests/day. Pages static assets have a 25 MiB per-file limit, so APK files belong in R2 rather than the website bundle. Check current quotas and terms before public launch. Free quotas/storage are limited and can change.

## Deploy (one-time setup)

You need a Cloudflare account and a computer/terminal with Node.js. The website can be managed from a phone, but the CLI setup is easier on a computer.

1. Install Wrangler:
   `npm install -g wrangler`
2. In this folder, log in:
   `wrangler login`
3. Create the D1 database:
   `wrangler d1 create krushna-store-db`
   Copy the returned `database_id` into `wrangler.toml`.
4. Create the R2 bucket:
   `wrangler r2 bucket create krushna-store-files`
5. Create the table:
   `wrangler d1 execute krushna-store-db --remote --file=./schema.sql`
6. Set a long random admin secret (do not put it in HTML or commit it):
   `wrangler secret put ADMIN_TOKEN`
7. Deploy:
   `wrangler deploy`

After deployment, open the `workers.dev` URL shown by Wrangler. `/admin.html` is the admin console. Paste the secret you set in step 6.

## Important limits and safety

- Upload handler caps APKs at 90 MB. Cloudflare's free request-body limit is 100 MB; multipart overhead means keep files below 90 MB. Very large APKs need a direct-to-R2 signed upload flow.
- Do not share your admin token. If exposed, rotate it with `wrangler secret put ADMIN_TOKEN`.
- Only upload APKs you own or are authorized to distribute. Obtain developer permission, respect licenses, and remove malware or deceptive apps.
- APK files are not vetted by this starter. Before accepting public submissions, add malware scanning, file hashing, package/signature verification, abuse reporting, moderation, rate limiting, privacy policy, and takedown process.
- HTTPS is provided by Cloudflare. A custom domain may cost money; the `workers.dev` subdomain is the free starting address.
- Free quotas are not unlimited. Monitor usage and configure spending limits if you later enable paid services.

## Current project features

- Public app catalogue, live name suggestions and category filters
- Add APK upload button directly on the homepage (admin token required)
- Original APK filename retained for download
- App name, category, version, developer, description, icon
- Admin token authentication
- APK and icon uploads to R2
- D1 metadata persistence
- APK download route
- Delete listing + stored files
- Responsive mobile layout

## Not included yet

User accounts, ratings/reviews, automated APK malware scanning, app update history, analytics, app signing verification, and payment features. Popular-app shortcuts link to Google Play search results; they do not host third-party APKs. Public browsing and downloads work without login; admin actions require the secret token.


## v3.0 additions
- Required uploader/person/company name stored with every listing.
- Optional contact field stored and shown on the public app card.
- Fixed TIMELINE STUDIO STORE watermark branding.
- Smooth card, search, dialog, button and focus animations; respects reduced-motion accessibility preference.

### Database migration from v2
If you already deployed v2, run this once before deploying v3:
`wrangler d1 execute krushna-store-db --remote --file=./migration_v2_to_v3.sql`
For a fresh install, run `schema.sql` instead.

## v4.0 — Discovery and usability upgrade

- Sort listings by newest, name, downloads, and recently updated.
- Save favourites locally on the current browser/device.
- Recently viewed apps list (local to the current browser/device).
- App detail dialog with uploader/contact metadata, date, safety note, and share action.
- Download counter endpoint.
- Installable PWA shell with cached static assets for offline shell access (catalogue/API and APK files still require internet).
- Improved loading/error/empty states, lazy icon loading, mobile toolbar, focus states, and reduced-motion handling.
- 100-feature inventory: see `FEATURES_100.md`; only entries marked Built are in this ZIP.

### Upgrade from v3
Run once:
`wrangler d1 execute krushna-store-db --remote --file=./migration_v3_to_v4.sql`
Then deploy with `wrangler deploy`.

For a brand-new database, `schema.sql` includes `download_count`.
