Skip to content

deancochran/cadence

Repository files navigation

Cadence

A full-stack endurance athletics focused Software as a Service (SaaS) web application built with SvelteKit, incorporating various technologies such as Stripe for subscriptions, Lucia for authentication, Prisma ORM for database interactions, Svelte Superforms form handling, Zod for validation, and enhanced with Skeleton UI and Lucide icons.

Table of Contents

Introduction

This SaaS implements modern standards for building web applications with a focus on endurance athleteics. It integrates powerful tools and libraries to handle essential aspects like user authentication, subscription management, form handling, and more.

Features

  • User authentication using Lucia
  • Subscription management with Stripe
  • Stripe Webhook integration and handling
  • Database interactions with Prisma ORM
  • Form handling with Svelte Superforms and Zod
  • UI styling with Skeleton UI
  • Iconography with Lucide

Technologies Used

Getting Started

  1. Clone the repository:

    git clone https://github.com/deancochran/skauth.git
  2. Install dependencies:

    pnpm install

Configuration

Stripe Setup

To enable subscription handling, sign up for a Stripe account and obtain your test API keys. To develop and test locally, you'll need to download and login to stripe through the CLI tool. https://stripe.com/docs/stripe-cli

Creating a Stripe Subscription Product in Test Mode

To set up a subscription product for testing purposes, you can follow these steps on your Stripe dashboard:

  1. Navigate to the "Products" section in the Dashboard.
  2. Click the "Create product" button. Fill in the product details, including a name, description, and pricing information.

NOTICE: It is imperative for the application that your add a TIER tag to the product you configure.

drawing

The different tags that you can specify are found in the prisma/schema.prisma file. So changing these will alter the business logic of the application.

enum UserRole {
  PRO
  BASE
}
  1. Inside the product, click the "Add pricing plan" button. Configure the plan details, such as the billing interval, currency, and amount.
  2. Go to the "Developers" section and find your API keys. Use the test publishable and secret keys for your integration.
  3. Implement Stripe into your application using the Stripe API library. Use the test API keys to update the corresponding values in the .env file:
~/.env

STRIPE_SECRET_KEY=XXXXXX
STRIPE_PUBLIC_KEY=XXXXXX

Lucia Authentication

Configure Lucia authentication by updating the authentication configuration in src/lib/auth.js.

Database (Prisma)

Create a .env file with your database connection URL:

DATABASE_URL="postgresql://user:password@localhost:5432/dbname"

Apply database migrations:

prisma migrate dev

Database (Prisma)

Run the SvelteKit application:

pnpm run dev

In a separate terminal start the webhook listener:

pnpm run stripe-webhook
# or
stripe listen --forward-to localhost:5173/stripe/webhook