You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// apps/backend-api/src/container/container.tsimport{PrismaUserRepository}from'../infrastructure/database/repositories/PrismaUserRepository';import{PrismaProblemRepository}from'../infrastructure/database/repositories/PrismaProblemRepository';import{PrismaSubmissionRepository}from'../infrastructure/database/repositories/PrismaSubmissionRepository';import{PrismaTestCaseRepository}from'../infrastructure/database/repositories/PrismaTestCaseRepository';import{JoseAuthTokenService}from'../infrastructure/auth/JoseAuthTokenService';import{Argon2PasswordService}from'../infrastructure/auth/Argon2PasswordService';import{BullMQQueueService}from'../infrastructure/queue/BullMQQueueService';import{RedisCacheService}from'../infrastructure/cache/RedisCacheService';import{SocketIOService}from'../infrastructure/websocket/SocketIOService';// Use Casesimport{RegisterUser}from'../application/use-cases/auth/RegisterUser';import{LoginUser}from'../application/use-cases/auth/LoginUser';import{GetProblems}from'../application/use-cases/problem/GetProblems';import{SubmitSolution}from'../application/use-cases/submission/SubmitSolution';// ... more use casesimport{prisma}from'../config/database';import{redis}from'../config/redis';// --- Instantiate Infrastructure ---constuserRepository=newPrismaUserRepository(prisma);constproblemRepository=newPrismaProblemRepository(prisma);constsubmissionRepository=newPrismaSubmissionRepository(prisma);consttestCaseRepository=newPrismaTestCaseRepository(prisma);constauthTokenService=newJoseAuthTokenService();constpasswordService=newArgon2PasswordService();constqueueService=newBullMQQueueService(redis);constcacheService=newRedisCacheService(redis);constnotificationService=newSocketIOService();// --- Instantiate Use Cases ---exportconstregisterUser=newRegisterUser(userRepository,passwordService,authTokenService);exportconstloginUser=newLoginUser(userRepository,passwordService,authTokenService);exportconstgetProblems=newGetProblems(problemRepository,cacheService);exportconstsubmitSolution=newSubmitSolution(submissionRepository,queueService,notificationService);// ... more use cases// --- Export for Controllers ---exportconstcontainer={// Repositories (if controllers need direct access)
userRepository,
problemRepository,
submissionRepository,// Use Cases
registerUser,
loginUser,
getProblems,
submitSolution,// Services (for middleware)
authTokenService,
notificationService,};
Composite indexes on (userId, problemId) for fast submission lookups
Soft publish via isPublished flag (problems aren't visible until admin publishes)
OAuth support with nullable password and githubId fields
Streak tracking built into User model
Tags array on Problem for flexible filtering
DailyChallenge table for the gamification feature
solvedCount/attemptCount on Problem for displaying stats without joins
Cascade deletes to maintain referential integrity
Removed MongoDB from categories — using TYPESCRIPT instead (resolves the contradiction)
Output field on SubmissionResult to show stdout to users
6. Sprint 1 — Foundation (Week 1–2)
Goal: "A user can register, log in, and browse problems with filtering."
Tasks
Week 1: Setup & Backend Foundation
Day 1–2: Project Setup
- [x] Initialize monorepo with Turborepo
- [x] Setup apps/frontend (Next.js with App Router)
- [x] Setup apps/backend-api (Express + TypeScript)
- [x] Setup packages/shared-types
- [x] Configure ESLint, Prettier, tsconfig across all packages
- [ ] Setup husky + lint-staged for pre-commit hooks
- [x] Create .env.example with all required variables
- [x] Setup docker-compose.yml for PostgreSQL + Redis (local dev)
- [x] Create initial GitHub repository with README
Day 3–4: Database & Domain Layer
- [x] Create Prisma schema (all models from Section 5)
- [ ] Run initial migration
- [ ] Write seed script with 15+ real JavaScript interview problems
- [ ] Create domain entities (User, Problem, TestCase, Submission)
- [ ] Create value objects (Email, Slug, Difficulty, SubmissionStatus)
- [x] Create domain errors (NotFound, Validation, Auth, Conflict)
- [x] Create port interfaces (IUserRepository, IProblemRepository, etc.)
Day 5: Infrastructure Layer
- [ ] Implement PrismaUserRepository
- [ ] Implement PrismaProblemRepository
- [ ] Implement Argon2PasswordService
- [ ] Implement JoseAuthTokenService
- [x] Setup pino logger
- [x] Create env.ts with Zod validation
Week 2: Auth + Problem Listing
Day 6–7: Auth Module (Backend)
- [x] Create RegisterUser use case
- [x] Create LoginUser use case
- [ ] Create RefreshToken use case
- [ ] Create AuthController
- [ ] Create authenticate middleware (JWT verification)
- [ ] Create authorize middleware (role-based)
- [x] Create validate-request middleware (Zod)
- [x] Create error-handler middleware
- [ ] Create rate-limiter middleware
- [ ] Setup auth routes
- [ ] Write unit tests for RegisterUser and LoginUser use cases
Day 8–9: Problem Listing (Backend + Frontend)
- [x] Create GetProblems use case (with filters, search, pagination)
- [ ] Create GetProblemBySlug use case
- [ ] Create ProblemController
- [ ] Setup problem routes
- [ ] Write unit tests for GetProblems use case
Day 9–10: Frontend Auth + Problem Pages
- [ ] Setup shadcn/ui
- [ ] Create root layout with providers (Query, Theme, Auth)
- [ ] Create login page with form validation
- [ ] Create register page with form validation
- [ ] Create auth service (API calls)
- [ ] Create auth hooks (useLogin, useRegister, useCurrentUser)
- [ ] Create auth guard component
- [ ] Create problem listing page
- [ ] Create ProblemCard component
- [ ] Create ProblemFilters component (category, difficulty, search)
- [ ] Create sidebar layout with navigation
- [ ] Setup dark/light theme toggle
- [ ] Create DifficultyBadge component
Day 10: CI + First Deploy
- [ ] Create GitHub Actions CI workflow (lint → typecheck → test → build)
- [ ] Deploy frontend to Vercel (preview)
- [ ] Test full auth flow end-to-end
Sprint 1 Deliverable
A deployed app where a user can:
✅ Register with email/password
✅ Log in and receive JWT tokens
✅ Browse problems with category/difficulty filters
✅ Search problems by title
✅ See difficulty badges (Easy/Medium/Hard)
✅ Dark/light theme toggle
✅ CI pipeline runs on every push
7. Sprint 2 — Core Engine (Week 3–4)
Goal: "A user can write code, submit, and see real-time execution results."
Tasks
Week 3: Editor + Submission + Queue
Day 11–12: Problem Workspace
- [ ] Create split-pane layout (description | editor)
- [ ] Integrate Monaco Editor with starter code loading
- [ ] Create editor toolbar (Run, Submit, Reset buttons)
- [ ] Create theme selector for editor
- [ ] Create output panel (tabbed: test cases | results)
- [ ] Implement keyboard shortcuts (Ctrl+Enter = submit, Ctrl+S = save)
- [ ] Create problem description renderer (react-markdown)
Day 13–14: Submission System (Backend)
- [x] Create SubmitSolution use case
- [ ] Create RunCode use case (playground mode — run without saving)
- [ ] Create GetSubmissions use case
- [ ] Create GetSubmissionResult use case
- [ ] Create SubmissionController
- [ ] Setup submission routes
- [ ] Install and configure BullMQ
- [ ] Create BullMQQueueService (implements IQueueService)
- [ ] Write unit tests for SubmitSolution use case
Week 4: Judge Worker + Real-Time
Day 15–17: Judge Worker Service
- [ ] Setup apps/judge-worker project
- [ ] Create Docker runner image (node:22-slim based)
- [ ] Create JavaScript executor
- [ ] Generate solution.js from user code
- [ ] Generate runner.js with test case injection
- [ ] Execute inside Docker container via dockerode
- [ ] Capture stdout, stderr, exit code
- [ ] Enforce resource limits (memory: 256MB, CPU: 1, timeout: 10s)
- [ ] Parse and compare outputs
- [ ] Create BullMQ worker that processes submission jobs
- [ ] Update submission status in database (PENDING → PROCESSING → result)
- [ ] Write unit tests for executor (at least 10 test scenarios)
Day 18–19: WebSocket + Real-Time Updates
- [ ] Setup Socket.io on backend
- [ ] Create SocketIOService (implements INotificationService)
- [ ] Authenticate WebSocket connections (JWT)
- [ ] Emit status updates: PENDING → PROCESSING → ACCEPTED/WRONG_ANSWER/etc.
- [ ] Create useSubmissionStatus hook (frontend WebSocket listener)
- [ ] Update output panel with real-time status
- [ ] Show animated processing indicator
Day 20: Integration Testing
- [ ] Test full submission flow: write code → submit → queue → execute → result
- [ ] Test edge cases: runtime error, timeout, compilation error
- [ ] Write 3+ E2E tests with Playwright for submission flow
Sprint 2 Deliverable
A user can:
✅ Open a problem and see description + code editor side by side
✅ Write JavaScript code in Monaco Editor
✅ Run code against visible test cases (playground mode)
✅ Submit solution for evaluation against hidden test cases
✅ See real-time status updates (Processing → Result)
✅ View pass/fail for each test case
✅ See runtime and memory usage
8. Sprint 3 — Polish & Admin (Week 5–6)
Goal: "This feels like a real product."
Tasks
Week 5: Dashboard + History
Day 21–22: User Dashboard
- [ ] Create GetUserStats use case (total solved, success rate, streak)
- [ ] Create GetCategoryProgress use case
- [ ] Create GetActivityHeatmap use case (daily solve count for past year)
- [ ] Create GetRecentActivity use case
- [ ] Create DashboardController + routes
- [ ] Create stats overview component (solved count, streak, success rate)
- [ ] Create category progress bar chart (Recharts)
- [ ] Create activity heatmap component (GitHub-style)
- [ ] Create recent submissions widget
- [ ] Create daily challenge card
Day 23–24: Submission History
- [ ] Create submission history page with pagination
- [ ] Create submission detail view (code, result, test cases)
- [ ] Create code diff viewer (compare two submissions)
- [ ] Create result badge component (Accepted = green, WA = red, etc.)
- [ ] Add "View previous submissions" link on problem page
Week 6: Admin Panel + Polish
Day 25–27: Admin Panel
- [ ] Create admin layout with sidebar navigation
- [ ] Create problem management table (list, search, filter)
- [ ] Create problem form (create + edit) with:
- [ ] Title, description (Markdown editor), difficulty, category
- [ ] Starter code input (Monaco Editor)
- [ ] Solution code input (optional)
- [ ] Tags input
- [ ] Publish/Unpublish toggle
- [ ] Create test case management:
- [ ] Add/edit/delete test cases per problem
- [ ] Mark as hidden/visible
- [ ] Order test cases
- [ ] Create admin stats page (total users, total submissions, etc.)
- [ ] Add role-based route protection (frontend + backend)
- [ ] Create CreateProblem, UpdateProblem, DeleteProblem use cases
- [ ] Create CreateTestCase, UpdateTestCase, DeleteTestCase use cases
Day 28–30: UI Polish
- [ ] Add skeleton loaders for all data-fetching pages
- [ ] Add toast notifications for all actions (success, error)
- [ ] Add empty states for no problems, no submissions
- [ ] Add confirm dialogs for destructive actions (delete problem)
- [ ] Add responsive mobile layout (sidebar → bottom nav)
- [ ] Add loading states for submit/run buttons
- [ ] Add optimistic UI updates for submissions
- [ ] Review and fix all accessibility issues (keyboard nav, ARIA labels)
- [ ] Add page metadata (title, description) for all routes
Sprint 3 Deliverable
✅ Dashboard with analytics, heatmap, and progress tracking
✅ Submission history with diff comparison
✅ Full admin panel for problem + test case management
✅ Polished UI with skeletons, toasts, empty states
✅ Mobile responsive layout
✅ Accessible interface
9. Sprint 4 — Differentiation (Week 7–8)
Goal: "This is why you hire me."
Tasks
Week 7: Auth Upgrade + AI Hints + Daily Challenge
Day 31–32: GitHub OAuth
- [ ] Setup next-auth v5 with GitHub provider
- [ ] Create OAuth callback route
- [ ] Update User model to support OAuth (nullable password, githubId)
- [ ] Create OAuth buttons on login/register pages
- [ ] Link GitHub avatar to user profile
- [ ] Test OAuth flow end-to-end
Day 33–34: AI-Powered Hints
- [ ] Create OpenAIHintService in infrastructure/external/
- [ ] Create GetHintForProblem use case
- [ ] Create hint API endpoint (POST /api/problems/:slug/hint)
- [ ] Rate limit to 3 hints per problem per user per day
- [ ] Design prompt template:
- Include problem description + user's current code
- Instruct: "Give a conceptual hint, NOT code. Max 2 sentences."
- [ ] Create hint UI component (collapsible, with "Get Hint" button)
- [ ] Track hint usage in database
- [ ] Add loading animation for hint generation
Day 35: Daily Challenge + Streaks
- [ ] Create cron job or scheduled task to rotate daily challenge
- [ ] Create GetDailyChallenge use case
- [ ] Create daily challenge banner on dashboard
- [ ] Implement streak calculation logic
- [ ] Show streak counter in header/profile
- [ ] Create streak milestone notifications (7-day, 30-day, etc.)
Week 8: Quality + Documentation + Deploy
Day 36–37: Testing Suite
- [ ] Unit tests for ALL use cases (Vitest)
- [ ] Auth: RegisterUser, LoginUser, RefreshToken
- [ ] Problem: GetProblems, GetProblemBySlug, CreateProblem
- [ ] Submission: SubmitSolution, GetSubmissions
- [ ] Dashboard: GetUserStats, GetActivityHeatmap
- [ ] Integration tests for API endpoints (Vitest + supertest)
- [ ] Auth flow (register → login → protected route)
- [ ] Problem CRUD (create → read → update → delete)
- [ ] Submission flow (submit → queue → result)
- [ ] E2E tests (Playwright)
- [ ] Register → Login → Browse Problems → Solve → See Result
- [ ] Admin: Create Problem → Add Test Cases → Publish
- [ ] Dashboard: Verify stats update after solving
- [ ] OAuth login flow
- [ ] Dark mode toggle persistence
Day 38–39: Documentation
- [ ] Setup Swagger/OpenAPI with swagger-jsdoc
- [ ] Document all API endpoints with:
- [ ] Request body schemas
- [ ] Response schemas
- [ ] Authentication requirements
- [ ] Error responses
- [ ] Example requests/responses
- [ ] Create interactive Swagger UI at /api-docs
- [ ] Write comprehensive README.md:
- [ ] Project overview with badges (TypeScript, Next.js, etc.)
- [ ] Architecture diagram (Mermaid)
- [ ] Demo GIF or video
- [ ] Tech stack table
- [ ] Setup instructions (local dev)
- [ ] Environment variables table
- [ ] API documentation link
- [ ] Contributing guidelines
- [ ] License
Day 40: Production Deployment
- [ ] Frontend → Vercel (production)
- [ ] Configure environment variables
- [ ] Setup custom domain (if available)
- [ ] Backend → VPS
- [ ] Docker Compose for backend + Redis + judge worker
- [ ] Setup nginx reverse proxy
- [ ] Configure SSL (Let's Encrypt)
- [ ] Setup PM2 or systemd for process management
- [ ] Database → Supabase PostgreSQL
- [ ] Run production migration
- [ ] Seed production data
- [ ] Monitoring
- [ ] Setup Sentry for error tracking
- [ ] Add health check endpoints (/health, /ready)
- [ ] Test graceful shutdown (SIGTERM handling)
- [ ] Final smoke test of all features in production
Sprint 4 Deliverable
✅ GitHub OAuth login
✅ AI-powered contextual hints
✅ Daily challenge with streak tracking
✅ Comprehensive test suite (unit + integration + E2E)
✅ Browse problems with search, category, and difficulty filters
✅ Open a problem and see description + code editor
✅ Write JavaScript code in Monaco Editor
✅ Run code against visible test cases (playground mode)
✅ Submit solution for evaluation against hidden test cases
✅ See real-time execution status via WebSocket
✅ View pass/fail results with runtime and memory
✅ View submission history with code diff comparison
✅ Track progress on dashboard with analytics charts
✅ See GitHub-style activity heatmap
✅ Maintain daily streak
✅ Solve daily challenge
✅ Get AI-powered hints (limited per day)
✅ Admin can create, edit, delete, publish problems
✅ Admin can manage test cases (visible + hidden)
An engineer reviewing the code can:
✅ See Clean Architecture with SOLID principles
✅ Read comprehensive API documentation (Swagger)
✅ Run the full test suite (unit + integration + E2E)
✅ Understand the system from the README + architecture diagram
✅ Run the project locally with a single docker-compose up
✅ See CI/CD pipeline in GitHub Actions
At this point, the project demonstrates: systems design, clean code architecture, distributed systems (queue + worker), DevOps awareness, testing discipline, and product thinking. This is a portfolio project that gets interviews.