Video Demo: https://youtu.be/dG1vZDgqy1M
This is my CS50 final project - a JavaScript coding challenge app that allows users to tackle coding challenges of varying difficulty, get instant feedback on their solutions, track progress, and earn achievements
A coding challenge app idea popped into my head while I was solving challenges on Codewars and LeetCode. Later, I took the CS50x course, and had a really great time throughout all the lectures. Every time I submitted a new problem set I had to use the check50 command, which ran tests on my code, and I was really intrigued by how it worked. Towards the end of the course, I knew what my final project would be, and I'd even started drawing the UI a while back. My work is finished now, and I'm really proud of it.
- User Registration: Easy sign-up with checks to make sure everything's entered right on both ends
- User Login: Authentication system keeps you logged in safely with secure cookies
- Session Management: Keeps you logged in as you move around the site, no need to keep re-entering your details
- Challenge Browser: Find the right challenge for you, filter by how hard it is or what it's about
- Code Editor: a proper code editor, like the one from VS Code
- Test Runner: Hit "run" and see if your code passes all tests
- Instant Feedback: You'll know right away if your code worked or not, with results in the panel
- Solution Submission: Once you've passed all the tests, you can submit your solution
- User Profile: See all the challenges you've completed and any badges you've earned
- XP System: Get points for every challenge you finish
- Achievements: Unlock special badges when you hit certain milestones
The front-end is built with React NextJS for server-side rendering and API routes. To keep the codebase clean and catch errors early, I chose TypeScript, adding static typing to JavaScript. Styling is handled with Tailwind CSS that lets me quickly create custom and responsive designs using classes
I chose Iron Session over JWT or NextAuth because of its simplicity and security. The cookies are encrypted, so a separate token system isn't needed. I really like this library because it doesn't add unnecessary complexity and making authentication with it was enjoyable. Zod is used to ensure the data I receive, especially user input, is valid and maintains its integrity. For securely storing passwords I used bcryptjs
I was looking for a code editor library and stumbled upon Monaco Editor. I didn't realize the same editor VS Code uses was available, which was a pleasant surprise. Since I love VS Code, I had to go with Monaco
For the database, I chose SQLite. I know it might not sound as fancy as MongoDB or PostgreSQL, but for this project, it's perfect. It's simple, portable, and fast
page.tsx: Main page, changes depending on if you're logged inchallenges/page.tsx: Where you browse challenges, with filterschallenges/[slug]/page.tsx: Details for each challengechallenges/[slug]/editor/page.tsx: The coding areaprofile/page.tsx: Your progress and statslogin/page.tsx®ister/page.tsx: Login and signup pages
ChallengeCard.tsx: Little cards for challenge listingsChallengesFilter.tsx: The controls for sorting challengesEditor.tsx: The code editor, using MonacoEditorInfoPanel.tsx: Shows instructions or resultsResultsInfo.tsx: Tells you if your code passed- UI Components:
ButtonPrimary.tsx,ButtonSecondary.tsx,Input.tsx - Form Components:
LoginForm.tsx,RegisterForm.tsx
The back-end uses Next.js API routes and server actions, with a SQLite database
getSession(): Figures out who's logged inregisterUser(): Creates new users, protects passwordsloginUser(): Lets people log inlogout(): Logs people out
- Handles the database connection
- Manages user info
- Gets challenge info
- Tracks user progress
challenges/route.ts: Gets challenge datarun-code/route.ts: Runs and tests your codelogin/route.ts: Handles login requestsregister/route.ts: Handles register requests
SQLite database with tables for:
- Users (login details, XP, completed challenges)
- Challenges (descriptions, difficulty, tests)
- Achievements (badges you earn)
-
Clone the repository:
git clone https://github.com/wjkba/solve-script.git
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Open http://localhost:3000 in your browser
