Lightweight React + Node.js/MongoDB app to track LeetCode problems by company. Frontend (Vite + React + Tailwind) calls a small Express + Mongoose backend for auth and persisting solved problems.
my-project/— React frontend (Vite)src/— React sourcecomponents/—AuthForm.jsx,NavBar.jsx,Dashboard.jsx,CompanyProblems.jsx, etc.
vite.config.js— dev server proxy (/api -> http://localhost:3001)
server/— Express + Mongoose backendindex.js— API routes:/api/register,/api/login,/api/user,/api/solvedmodels/User.js— Mongoose user schema.env— containsMONGODB_URI
Prerequisites
- Node.js (v16+ recommended; v22 used during development)
- npm
- A MongoDB connection string (Atlas or local)
- Backend
-
Configure environment
Create or edit
server/.envwith:MONGODB_URI="your-mongodb-connection-string" PORT=3001 -
Install and start the server
cd server npm install npm startThe server will log
Server listening on port 3001andMongoDB connected!when healthy.
- Frontend
-
Install and start the Vite dev server
cd my-project npm install npm run dev -
Open the app in the browser (Vite will show the local URL, usually
http://localhost:5173). The dev server proxies/apito the backend.
All endpoints accept and return JSON.
-
POST /api/register
- Body: { email, password }
- Success: 201 { message, user: { email } }
-
POST /api/login
- Body: { email, password }
- Success: 200 { message, user: { email } }
-
POST /api/user
- Body: { email }
- Success: 200 { email, solved: [], solvedDates: [], recent: [] }
-
POST /api/solved
- Body: { email, problemId, action } // action: 'add' | 'remove'
- Success: 200 { message, user: { email, solved, solvedDates, recent } }
Notes: The backend returns full user lists (without password) for /api/user and /api/solved.
- Authentication:
AuthForm.jsxcalls/api/registerand/api/login; after success it fetches/api/userand the app saves the returned profile to localStorage so the session persists across reloads. - CompanyProblems: marks problems as solved using a unique key
company::problemNameand calls/api/solvedwithaction: 'add'or'remove'. - Dashboard: fetches
/api/userfor solved/solvedDates/recent. Recent activity displays the last 3 items.