Avatarbitofbreeze

Avatarbitofbreeze/git-sell

โšก๏ธ The free-to-host stack that's also fast and easy on the environment ๐ŸŒฒ
ariakitcloudflarecloudflare-pagesdrizzle-ormlibsqlpartykitreactreact-routerremixremix-runsqlitestripestripe-connecttursotypescript
$179.001.083 MBRepo updated 3 months ago
  • TypeScript
  • CSS
  • HTML

gitsell: A Remix-Vite web app on Cloudflare Pages

๐Ÿ’š Credo

Core principles of this repo:

  1. Run on any range of devices and at any network speed
  2. Be free to host and easily migratable in case a provider shuts down
  3. Be easy on the environment by not running when not in use and using the most efficient resources available when running
  4. Be secure

Some key ways we've achieved the above:

  • Use SQLite over PostgreSQL for its ability to quickly scale to 0 and back up, and use Turso specifically for its guarantee to continue offering a free tier due to its minimal cost
  • Use serverless Cloudflare, which has publicly reaffirmed its commitment to its free tier and its ability to offer it given its efficiency, instead of serverful containers that always run (costing money and energy)
  • Use minimal 3rd-party dependencies to minimize vulnerability surface area and bundle size transmitted over the network
  • Use HTML and CSS over JS for its network and CPU efficiency as well as its improved responsiveness and accessibility
  • Use purely additive WebSocket functionality via PartyKit which is owned by Cloudflare and has a generous free tier since using durable objects (required for event-driven SSE or WS) directly requires being on the paid tier. App core experience continues working perfectly even without WebSocket.

๐Ÿ“– Resources

๐Ÿง‘โ€๐Ÿ’ป Development setup

  1. Install turso CLI and log in
  2. Create a new GitHub OAuth App
    • Application name: Something (Development)
    • Homepage URL: http://localhost:5173
    • Authorization callback URL: http://localhost:5173/login/github
  3. Set GITHUB_CLIENT_ID in wrangler.toml
  4. Generate a new client secret in the GitHub App settings and set GITHUB_CLIENT_SECRET in .dev.vars
  5. Create a new GitHub App
    • GitHub App name: Something (Development)
    • Homepage URL: http://localhost:5173
    • Callback URL: http://localhost:5173/sell/sync/github
    • Webhook URL: [ngrok domain]/webhook/github
    • Permissions:
      • Administration: read and write
      • Contents: read only
      • Webhooks: read and write
  6. Set:
    • GITHUB_APP_ID in wrangler.toml
    • GITHUB_APP_CLIENT_ID in wrangler.toml
    • GITHUB_APP_URL in wrangler.toml
    • GITHUB_APP_CLIENT_SECRET in .dev.vars
    • GITHUB_APP_PRIVATE_KEY in .dev.vars
    • GITHUB_APP_SECRET_TOKEN in .dev.vars
  7. Create a Stripe account following the prerequisites here
  8. Set:
    • STRIPE_SECRET_KEY in .dev.vars
    • STRIPE_WEBHOOK_SIGNING_SECRET in .dev.vars
  9. Install bun
  10. bun i to install dependencies
  11. In Terminal tab 1, turso dev to run the database in memory. No environment variables are needed since the database is running locally on its default port
  12. In another Terminal tab, bun run build:db to apply migrations to the running database
  13. In Terminal tab 2, bun --cwd apps/git-sell ngrok http 5173 --domain=[your static domain]
  14. In Terminal tab 3, bun run dev
  15. In Terminal tab 4, bunx partykit dev if you want to use purely additive websocket functionality

๐Ÿค– CI/CD

  1. If using WebSocket, https://docs.partykit.io/guides/setting-up-ci-cd-with-github-actions/
  2. For app, create Cloudflare API token like https://developers.cloudflare.com/workers/wrangler/ci-cd/#api-token but add "Cloudflare Pages โ€” Edit" permission
  3. Disable automatic deployments in Cloudflare Pages settings

๐Ÿ“ฆ Deployment

First, build your app for production:

bun run build

Then, deploy your app to Cloudflare Pages:

bun run deploy

To deploy websocket,

  • bunx partykit env add WEBSOCKET_SECRET
  • bun run deploy:ws

๐Ÿ“Š Comparison (as of 15 May 2024)

Let's compare gitsell to another popular boilerplate.

gitsellshipfa.st
Landing page size242 kB4.3 MB
In-app page size251 kB1.6 MB
Landing page Lighthouse scorealt textalt text

Reviews

No reviews yet

16 commits in the last year

JanFebMarAprMayJunJulAugSepOctNovDecJan