Skip to content

Udemy Clone. (Backend) Springboot, Java 11+, Spring Session, Braintree Payments, PayPal, MySQL 8, Hibernate, Redis, Google OAuth

License

Notifications You must be signed in to change notification settings

CodeZens/WedemyServer

 
 

Repository files navigation

WedemyServer

Maintenance License: MIT

(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 and session cookies1 (or Header tokens) 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.

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. Please note that Wedemy does not offer any certifications or guarantees similar to those provided by Udemy Inc.

Frontend & Live Demo

Click to view Frontend Repo and demo built using Vue 3 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.

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 set these:
SPRING_PROFILES_ACTIVE=prod
PORT={#depends on your Cloud/local host}

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

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 data_wedemy.sql which contains sample data for testing. Also, take a look at the ERD diagram of this DB.

  • CREATE new database called wedemy (any name is OK), with charset utf8mb4.
  • 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 get its Docker image. Another option, you could try Redis Cloud at: https://redis.com/try-free/. Remember to replace redis credentials inside application.yml (or ENV variables) to match your running Redis instance.

Tip 💡 Redis now has an OFFICIAL cross-platform desktop GUI client: RedisInsight. Download it free from 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 payment info is stored locally, except transactionID. 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!


Footnotes

  1. In production, for Browser clients, ensure both your Backend and Frontend share the same ROOT domain (same-site policy), AND set 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.

About

Udemy Clone. (Backend) Springboot, Java 11+, Spring Session, Braintree Payments, PayPal, MySQL 8, Hibernate, Redis, Google OAuth

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 99.0%
  • Other 1.0%