Coder Social home page Coder Social logo

course-platform's Introduction

Course Platform

CleanShot 2021-10-26 at 17 32 13@2x

๐Ÿ‘‰ I go over the details of why and how I built this demo during my talk, presented at Next.js conf 2021.

โš ๏ธ This repo + README are a work in progress. I plan to maintain this example and add more features over time. If you see any room for improvement, feel free to submit a PR ๐Ÿ˜„

Live demo: https://epic-course-platform.vercel.app/

Tech Stack

Course Platform template built using the following tools:

  • Next.js (fullstack React framework)
  • next-mdx-remote (Add support for MDX when using Next.js)
  • next-auth (authentication for Next.js apps)
  • Prisma (Next-gen ORM for Node.js & TypeScript)
  • PlanetScale (Serverless MySQL Database)
  • TailwindCSS (Styling)
  • Vercel (Deployment)
  • SendGrid (Sending emails)
  • TypeScript

Why this stack

This stack is awesome for the following reasons:

  • Make fewer errors when using TypeScript and you also get zer-cost type-safe database access when using Prisma
  • All tools offer fantastic developer experience
  • All of the tools have great developer communities
  • All of these tools allow you to easily scale (Vercel + PlanetScale)

Setting up the project

To set up the project locally, run the following commands:

git clone https://github.com/m-abdelwahab/course-platform.git

cd course-platform

npm install

npm run dev

This will install the project and start a local development server at localhost:3000.

โ—๏ธ Make sure your rename the .env.example to .env

Setting up the database

To set up a database on PlanetScale, check out this detailed guide, which goes over how to work with PlanetScale and Prisma.

Setting up an email sending service

I'm using SendGrid. Hee's what you need to do to get started:

First, create an account and setup a sender email for testing your integration.

creae account on sendgrid

After that, go to the Integration Guide in the Email API dropdown on the left sidebar. Next, pick SMTP relay

Picking SMTP as the integration

Finally, create an API key and add the following variables to your .env file

EMAIL_SERVER_USER= 'apikey'
EMAIL_SERVER_PASSWORD= 'YOUR_PASSWORD'
EMAIL_SERVER_HOST= 'smtp.sendgrid.net'
EMAIL_SERVER_PORT= '587'
EMAIL_FROM = '[email protected]'

CleanShot 2021-10-26 at 12 07 05@2x

Setting up Stripe Checkout

Creating an account at stripe.com and login into your dashboard. Next, go to the products tab and add a product

Add product

After that, go to the product details page by clicking on the product from the product list and grab the API ID from the pricing section and include it in the /api/checkout file

pick PriceId from product settings

Finally, to add support for webhooks, go to the "Developers tab" and click "add endpoint".

Webhooks

You can test in a local environment using Stripe's CLI by forwarding events to your webhooks and triggering a charge.succeeded event.

Setting up a webhook endpoint

stripe listen --forward-to localhost:3000/api/webhook

stripe trigger charge.succeeded

If you followed all the previous steps correctly, you should see a newly added user in your database, while listening to the charge.succeeded event.

For production, you need to set the endpoint URL to domain-of-your-deployment/api/webhook and select the charge.succeeded event. Finally, you need to grab the signing secret, which will be set to the STRIPE_WEBHOOK_SECRET when deploying to Vercel.

Webhook secret

Credits

course-platform's People

Contributors

m-abdelwahab avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.