Complete catalog of available endpoints, authentication, and expected payloads. All routes are mounted under http://localhost:3000/api/v1.
- JWT bearer:
Authorization: Bearer <token>(validated byauthToken). - Env:
JWT_SECRET,GEMINI_API_KEY(for AI),DB_URL,NODE_ENV. - File uploads use
multipart/form-data(Cloudinary viauploadFiles).
GET /login/success— returns logged-in user + JWT cookie after OAuth.GET /login/failed— login failure.GET /google— start Google OAuth.GET /google/callback— Google OAuth callback, issues JWT cookie + JSON.GET /logout— clears auth cookie.
POST /signup— create user. Body (validated):name,email,password(≥6 unlessgoogleIdprovided), optionalgoogleId,profilePic,age,height,weight,fitnessGoal,activityLevel.POST /login— email/password login.POST /admin-login— admin credentials login.PUT /change-password(auth) — body:currentPassword,password,confirmPassword.POST /forgot-password— start reset (sends code).POST /check-otp— verify reset code.POST /reset-password— complete reset.GET /my-profile(auth) — current user profile.GET /followers/:id— list followers.GET /following/:id— list following.GET /top-users— leaderboard of top users.PUT /update-info(auth) — update profile (same schema as signup; extra fields allowed).PUT /changeRole/:id(auth admin) — change user role.POST /follow/:id(auth) — follow user.POST /unfollow/:id(auth) — unfollow user.POST /admin/add(auth admin) — create admin user.PATCH /profile-picture(auth, multipart) — uploadimage.GET /— list users.GET /:id— get user by id.PATCH /:id— update user by id (no auth enforced in router).DELETE /:id(auth) — delete user.
POST /ask(auth) — body:message(1–1000 chars). Returns{ reply }from Gemini 1.5 Flash and stores chat history per user.GET /user-chats/:userId— get stored chat history for a user (no auth enforced).
POST /create(multipart) — fields:name(3–100),description(≤300), optionalexercisesarray,imagefile,videofile.GET /— list workouts.GET /list/names— list workout names.GET /:workoutId— get workout by id.GET /workout-exercises/:workoutId— workout with exercises populated.PUT /:workoutId(multipart) — update; same fields as create.DELETE /:workoutId— delete workout.
POST /create(multipart) — fields:name(≥2),description(10–500),targetMuscles,secondaryMuscles,equipment(bodyweight|dumbbell|barbell|machine|resistance band),difficulty(beginner|intermediate|advanced), optionalvideoUrl,imagefile(s),videofile(s),workoutName(required).GET /latest— latest exercises.GET /— list exercises.GET /:id— get exercise by id.PUT /:id(multipart) — update exercise; file fields optional.DELETE /:id— delete exercise.
Posts:
GET /posts/getPosts— list posts.POST /posts/createPost(auth, multipart) — body:content(5–1500), optionalimageUrls[],videoUrls[](or uploaded files).GET /posts/getPostById/:id— get single post.GET /posts/details/:id— post with extra details.DELETE /posts/deletePostById/:id(auth) — delete post.PUT /posts/edit/:id(auth, multipart) — update post content/media. Likes/Shares:POST /like/:postId(auth) — like post.POST /unlike/:postId(auth) — unlike.POST /share/:postId(auth) — share.DELETE /undoshare/:postId(auth) — undo share. Comments:GET /posts/getComments/:id— list comments.POST /comments/addComment/:postId(auth) — body:content(2–500).POST /comments/replyToComment/:commentId(auth) — reply body same as comment.PATCH /comments/editComment/:commentId(auth) — edit comment.DELETE /comments/deleteComment/:commentId(auth) — delete. User feeds:GET /following/posts(auth) — posts from following.GET /user-posts/:id— posts by user.GET /user-shares(auth) — posts current user shared.GET /user-all-posts(auth) — current user posts + shares.
POST /createTriviaQuestion— body:question(5–500),options(2–4 strings),correctAnswer, optionalpoints(default 10).GET /getTriviaQuestions— list all.GET /:id— get one.PUT /:id— update.DELETE /:id— delete.
POST /create— create challenge (no auth enforced). Body varies bytype:type: "exercise"+exerciseId(ObjectId),calcMethod(reps|time), optionaltarget,points.type: "trivia"+questionId(ObjectId), optionaltimeLimit,points.
GET /— list challenges.GET /:id— get challenge.PUT /:id— update challenge.DELETE /:id— delete challenge.
POST /createSession(auth) — create a session (body handled in controller).POST /join/:sessionId(auth) — join session.POST /start/:sessionId(auth) — start session.POST /end/:sessionId(auth) — end session.GET /— list sessions.
POST /update— update user progress for a session.GET /leaderboard/last-session— leaderboard for most recent completed session.GET /leaderboard/:sessionId— leaderboard by session.GET /user-sessions/:id— progress for a user across sessions.
POST /create— create exercise progress entry (fields in controller; supports optional detailed analysis).GET /all— list all progress records.GET /user/:userId— progress for a user.GET /exercise/:exerciseId— progress for an exercise.
GET /— aggregate counts (users, admins, exercises, sessions, etc.).GET /ages— user age distribution.GET /community— community engagement stats.GET /exercise-time— global exercise time stats.GET /user-growth— monthly user growth.
- Gemini model:
gemini-1.5-flashvia@google/generative-ai. - Bot scope: fitness/nutrition; off-topic prompts return a guidance message.
- Chat history stored per user in
FitnessChat(userId,messages[{sender,text,time}]).