Giter VIP home page Giter VIP logo

cskhserver's Introduction

WedemyServer

Static Badge Maintenance License: MIT Static Badge

(Backend repo). Clone of Udemy, an e-learning platform, built using SpringBoot + Vue 3 + Typescript. With CreditCard and PayPal checkout (both powered by Braintree Payments). Uses Spring Security & Spring Session Redis (via cookies1 or sessionID Headers) for auth, instead of stateless JWT Tokens. CSRF protection is enabled. You can easily customize these settings in SecurityConfig. By default, the app runs on port 9000.

Frontend & Live Demo

Click to view Frontend Repo and live Demo built using Vue 3, Vite and Typescript. However, you can still use any frontend stack with this project. See the API Docs for this project.

Requirements

Environmental Variables

You MUST set these ENV variables on your System or Container before you launch this SpringBoot app. πŸ’‘TIP: During dev/test, you can pass them via args, OR store inside your IDE: e.g. In either Eclipse or IntelliJ IDE, in the top toolbar, find the "Run" menu > Edit/Run Configuration > Environment > Environmental Variables. Add (+) each key and its value, then click Apply. If using Docker CLI, follow this quick official guide.

MYSQL_PASSWORD=
# below are for Google OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# below are for Braintree Payments
BT_MERCHANT_ID=
BT_PUBLIC_KEY=
BT_PRIVATE_KEY=
# For production, you SHOULD include these:
SPRING_PROFILES_ACTIVE=prod
PORT=#(server port for Spring)

Important ⚠

Please examine the files application.yml (default), and application-prod.yml (meant for production). Replace all the necessary Spring Application properties with yours. But for sensitive info (like Passwords or API Keys), DON'T PASTE THEM IN THERE DIRECTLY❌ . It's safer to store them as Environmental Variables instead (see section above), then either declare them as property.name = ${ENV_KEY_NAME}, OR refer them directly in your source code as shown in BraintreeConfig.

Databases Used

MySQL 8.0.x

This is the primary database. All DateTimes are stored and queried in UTC only. (Hint: USE java.time.Instant as Type for all Datetime fields). Handle timezone conversion on your Frontend! For your convenience, I have included a mysqldump file which contains sample data for testing. You may also take a look at the ERD diagram.

  • CREATE new schema called wedemy (any name is OK), with charset utf8mb4.

  • All tables and indexes will be auto-created by SpringBoot on the very-first launch, if missing. (Can be disabled.)

  • To maintain consistent time-zone (UTC) with your Java app, ensure your JDBC connection URL has parameter connectionTimeZone=UTC. See example below. For native @Query's, use UTC_TIMESTAMP() or UTC_DATE().

    spring.datasource.url=jdbc:mysql://localhost:3306/wedemy?connectionTimeZone=UTC
    # OR, set this
    spring.jpa.properties.hibernate.jdbc.time_zone=UTC

Redis v6.0 (or higher)

This project uses Redis for 2 main tasks: Caching, and Storing login sessions. You can download latest Redis (macOS & Linux) from https://redis.io/download. Windows users may download the latest native installer (.msi) from this GitHub repo. Alternatively, you could pull its official Docker image. Another option you could try is Redis Cloud at: https://redis.com/try-free/. Remember to replace Redis credentials inside application.yml (or in your ENV variables).

Tip πŸ’‘ Redis now has an OFFICIAL cross-platform desktop GUI client: RedisInsight. Download it free here

Payments Handling

All payments are securely handled by Braintree Payments (owned by PayPal), which also supports cards, Apple Pay, GooglePay, Venmo and many other methods. This project implements Credit-Card and PayPal Checkout only, in Sandbox (Dev) mode: No actual money is deducted at Checkout. Make sure you obtain a set of 3 API Keys from your own Braintree Dev Account and store them as ENV variables: BT_MERCHANT_ID, BT_PUBLIC_KEY and BT_PRIVATE_KEY. For Braintree tutorials and samples, please check their official docs.

Deploying your App πŸš€

This App can be easily deployed within few minutes, straight from GitHub to your Cloud PaaS of choice. You can either use the Dockerfile provided, or natively as a pure Java app. Popular PaaS with CI/CD for Java include: Heroku, AWS ElasticBeanstalk, Google App Engine, Azure Web Apps. The following may require a Dockerfile: Dokku, Railway, Render.com, Fly.io. Please note, you may also need a separate MySQL & Redis instance!

Disclaimer ⚠

Wedemy is an open-source project developed for learning purposes only. It is NOT associated with or endorsed by Udemy, Inc. Any resemblance to Udemy or its services is purely inspirational.


Footnotes

  1. In production, for Browser clients, ensure both your Backend and Frontend share the same ROOT domain (same-site policy), AND set property session.cookie.Secure=true (strictly https) for Session Cookies to work properly. Learn more at WebDev. Alternatively, you can replace Cookies entirely with special Header X-AUTH-TOKEN (by Spring; expires too). See file SecurityConfig.java. ↩

cskhserver's People

Contributors

dependabot[bot] avatar longwater1234 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.