A cloud-native microservice-based web app that lets users log in and manage a course catalog. Features both Google OAuth and traditional username/password authentication, and is deployed on IBM Cloud.
- Frontend: React (Vite)
- Backend: Node.js with Express.js
- Database: MongoDB Atlas
- Authentication: Google OAuth & JWT (passport.js)
- Deployment: IBM Cloud (Cloud Foundry + Toolchain)
- Uses Express to handle HTTP requests.
- Connects to MongoDB Atlas via Mongoose using
MONGO_URI. - Seeds initial courses from
initialCourses.jsonif DB is empty. - Middleware:
corswith dynamicFRONTEND_URLexpress-session(for Google OAuth sessions)passportfor authentication
- Routes:
/auth: Handles login/signup & Google OAuth/api: Handles course-related endpoints
- In production, serves React frontend from
dist/.
- Username/Password Auth:
POST /signup: Registers user, hashes password, returns JWTPOST /login: Authenticates and returns JWT
- Google OAuth:
GET /auth/google: Redirects to Google loginGET /auth/google/callback: Handles callback, issues JWT, redirects to frontend
- JWT Auth:
- Tokens signed with
JWT_SECRET, expire in 1 hour
- Tokens signed with
- Passport Strategy:
- Configured for Google, stores user in MongoDB
- Handles core app functionality:
GET /api/items: Fetch all coursesPOST /api/item: Add a coursePUT /api/item: Edit a courseDELETE /api/item: Remove a course
- Local Dev:
http://localhost:5173usingnpm run dev - Production: Compiled to
dist, served by backend - API calls use relative routes with
credentials: "include" - Features include:
- Course listing
- Login/signup
- User profile & possibly enrolled courses (if implemented)
User.js: Stores user credentials, cart, dark mode, etc.Admin.js: Similar to User but withrole: "admin"Course.js: Defines schema for course objects
-
User Logs In
- Google or username/password
- JWT issued, frontend redirects
-
Course Actions
- Frontend calls
/apiroutes to fetch/add/edit/delete
- Frontend calls
-
Backend Handles Requests
- Verifies JWT/auth
- Interacts with MongoDB
- Returns JSON responses
-
Frontend Updates View
- Displays data dynamically
The following admin accounts have been pre-seeded into the database for testing admin functionality:
- Username:
admin1| Password:adminpass1 - Username:
admin2| Password:passadmin123
To test admin features:
- Start the application with
npm run dev. - Log in using one of the above credentials via the login page.
- Access admin-only routes (course management,number and people who have enrolled , number of views for the course) to verify restricted access.
npm install
npm run dev
cd server node app.js