Check out the working demo here!
A clone of Leetcode written in Go and SvelteKit. I wanted to see if I could reverse-engineer a popular web app with complicated internals. The goal of this side project was to learn how to use Go for backend development, SvelteKit and TailwindCSS for scaffolding the frontend, learn a new database, and understand how Docker and Docker Compose works.
There are four services: frontend
, backend
, coderunner
, and database
.
frontend
service renders these pages:
backend
service is an API server that handles user requests from the frontend and then responds with a corresponding JSON.
main.go
handles incoming requests and relays them to the corresponding controller function in controllers.go
. It is also responsible for loading the .env
file and connecting to the database.auth.go
holds the functions necessary for user authentication, which includes handling CORS requests, generating JWTs, handling user sign ins and logins, and handling silent refreshes.controllers.go
holds all the controller functions.middlewares.go
holds the middlewares that wraps certain controller functions.models.go
holds structs that mirror the database schema.coderunner
service is responsible for running user code and testing it against numerous test cases.
main.go
handles incoming requests and relays them to the corresponding controller function in controllers.go
. It is also responsible for connecting to the database.controllers.go
holds all the controller functions./cpp
, /java
, /js
, /py
are directories that hold the user code written in those specific langauges. It also holds the test results. The user code file and test result file share the same UUID, which the service uses to differentiate between different users' code.lang
holds code for language support. This mainly includes methods responsible for generating and compiling user code files.models.go
holds structs that mirror the database schema.utils.go
holds utility functions.database
service holds the PostgreSQL database that stores all the data for the web app.
uuid
package.