Q1. What would a blog API structure look like?
Models: User, Post, Comment. Relationships: User has many posts, Post belongs to User, Post has many comments. Routes: auth (register/login), posts (CRUD), comments (CRUD). Authentication for creating posts, public for reading. Use JWT.
Q2. What would an e-commerce API structure look like?
Models: User, Product, Category, Order, CartItem. Routes: products (public), categories, cart (protected), orders (protected). Features: search products, filter by category, add to cart, checkout process. Authentication and admin roles for product management.
Q3. How do you handle relationships in database for such projects?
In MongoDB/Mongoose, use references (population) or embedding. Example: post schema has userId referencing User. For SQL, use foreign keys and joins. Mongoose: Post.find().populate('user'). In SQL: SELECT * FROM posts JOIN users ON posts.userId = users.id.
Q4. How would you implement pagination for listing endpoints?
Accept query parameters: page and limit. Calculate skip = (page - 1) * limit. For Mongoose: .find().skip(skip).limit(limit). For SQL: LIMIT limit OFFSET skip. Return pagination metadata: total pages, current page, hasNext.
Q5. How would you structure the frontend for these projects?
For a full-stack project, you might use React/Vue for frontend. The Express API serves JSON. Frontend handles UI, state management, and makes API calls. Alternatively, you could use server-side rendering with EJS if you want a traditional web app.
