Skip to content

ivan-koltsov/mern-interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MERN Stack Senior Interview Project

A comprehensive MERN (MongoDB, Express.js, React.js, Node.js) stack project designed for senior-level technical interviews. This project demonstrates advanced concepts, best practices, and real-world scenarios.

πŸš€ Features

Backend (Node.js/Express)

  • Authentication & Authorization: JWT-based auth with role-based access control
  • Database: MongoDB with Mongoose ODM
  • Caching: Redis integration for performance optimization
  • Real-time Communication: Socket.io for live features
  • File Upload: Multer with image processing (Sharp)
  • Email Service: Nodemailer integration
  • Security: Helmet, rate limiting, input validation
  • Logging: Winston logger with different levels
  • Testing: Jest with supertest for API testing
  • API Documentation: Swagger/OpenAPI
  • Error Handling: Centralized error handling middleware
  • Validation: Joi schema validation

Frontend (React)

  • Modern React: Hooks, Context API, Custom hooks
  • State Management: Redux Toolkit with RTK Query
  • UI Framework: Material-UI with custom theming
  • Real-time Updates: Socket.io client integration
  • Form Handling: React Hook Form with validation
  • Routing: React Router with protected routes
  • Testing: Jest with React Testing Library
  • Performance: Code splitting, lazy loading
  • PWA: Service workers, offline support

πŸ“‹ Interview Tasks

Task 1: Authentication System Enhancement

Difficulty: Senior Time: 2-3 hours

Implement a multi-factor authentication system:

  • Add TOTP (Time-based One-Time Password) using Google Authenticator
  • Implement backup codes generation and validation
  • Add device fingerprinting for suspicious login detection
  • Create admin dashboard for user management

Requirements:

  • Use speakeasy library for TOTP
  • Implement rate limiting for MFA attempts
  • Add audit logging for security events
  • Create comprehensive test coverage

Task 2: Real-time Chat Application

Difficulty: Senior Time: 3-4 hours

Build a real-time chat system with advanced features:

  • Private and group chat rooms
  • Message encryption (end-to-end)
  • File sharing with progress indicators
  • Typing indicators and read receipts
  • Message search and filtering
  • Chat history pagination

Requirements:

  • Use Socket.io for real-time communication
  • Implement message encryption using crypto-js
  • Add file upload with size limits and type validation
  • Create responsive UI with Material-UI
  • Add comprehensive error handling

Task 3: E-commerce API with Advanced Features

Difficulty: Senior Time: 4-5 hours

Develop a complete e-commerce API:

  • Product catalog with advanced filtering
  • Shopping cart with Redis
  • Order management with status tracking
  • Payment integration (Stripe/PayPal)
  • Inventory management
  • Discount and coupon system
  • Analytics and reporting

Requirements:

  • Implement proper data validation and sanitization
  • Add comprehensive error handling
  • Create API documentation with Swagger
  • Implement caching strategies
  • Add unit and integration tests

Task 4: Performance Optimization

Difficulty: Senior Time: 2-3 hours

Optimize the application for high performance:

  • Implement Redis caching for frequently accessed data
  • Add database query optimization
  • Implement CDN integration for static assets
  • Add compression and minification
  • Implement lazy loading and code splitting
  • Add performance monitoring

Requirements:

  • Use Redis for session storage and caching
  • Optimize MongoDB queries with proper indexing
  • Implement CDN for image and static file delivery
  • Add performance metrics collection
  • Create load testing scenarios

Task 5: Microservices Architecture

Difficulty: Senior+ Time: 5-6 hours

Refactor the application into microservices:

  • User service (authentication, profiles)
  • Product service (catalog, inventory)
  • Order service (orders, payments)
  • Notification service (emails, push notifications)
  • API Gateway with rate limiting and routing
  • Service discovery and health checks

Requirements:

  • Use Docker for containerization
  • Implement service-to-service communication
  • Add circuit breaker pattern
  • Create comprehensive monitoring
  • Implement proper logging and tracing

πŸ› οΈ Setup Instructions

Prerequisites

  • Node.js >= 16.0.0
  • MongoDB >= 5.0
  • Redis >= 6.0
  • Git

Installation

  1. Clone the repository
git clone <repository-url>
cd mern-interview-project
  1. Install dependencies
npm run install-all
  1. Environment Setup
cp .env.example .env
# Edit .env with your configuration
  1. Database Setup
# Start MongoDB and Redis
# Update connection strings in .env
  1. Run the application
# Development mode
npm run dev

# Production build
npm run build
npm start

πŸ§ͺ Testing

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

πŸ“Š Project Structure

β”œβ”€β”€ server/                 # Backend API
β”‚   β”œβ”€β”€ config/            # Configuration files
β”‚   β”œβ”€β”€ controllers/       # Route controllers
β”‚   β”œβ”€β”€ middleware/        # Custom middleware
β”‚   β”œβ”€β”€ models/           # Mongoose models
β”‚   β”œβ”€β”€ routes/           # API routes
β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”œβ”€β”€ utils/            # Utility functions
β”‚   └── tests/            # Backend tests
β”œβ”€β”€ client/               # Frontend React app
β”‚   β”œβ”€β”€ public/           # Static files
β”‚   β”œβ”€β”€ src/              # Source code
β”‚   β”‚   β”œβ”€β”€ components/   # React components
β”‚   β”‚   β”œβ”€β”€ hooks/        # Custom hooks
β”‚   β”‚   β”œβ”€β”€ pages/        # Page components
β”‚   β”‚   β”œβ”€β”€ services/     # API services
β”‚   β”‚   β”œβ”€β”€ store/        # Redux store
β”‚   β”‚   └── utils/        # Utility functions
β”‚   └── tests/            # Frontend tests
β”œβ”€β”€ docs/                 # Documentation
β”œβ”€β”€ docker/               # Docker configuration
└── scripts/              # Build and deployment scripts

πŸ”§ Configuration

Environment Variables

Create a .env file in the root directory:

# Server Configuration
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://localhost:27017/mern-interview
REDIS_URL=redis://localhost:6379

# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=7d

# Email Configuration
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password

# File Upload
MAX_FILE_SIZE=5242880
UPLOAD_PATH=uploads/

# External APIs
STRIPE_SECRET_KEY=sk_test_...
PAYPAL_CLIENT_ID=your-paypal-client-id
PAYPAL_CLIENT_SECRET=your-paypal-secret

πŸš€ Deployment

Docker Deployment

# Build and run with Docker
npm run docker:build
npm run docker:up

Manual Deployment

# Build for production
npm run build

# Start production server
npm start

πŸ“ˆ Performance Monitoring

The project includes:

  • Winston logging with different levels
  • Performance metrics collection
  • Error tracking and monitoring
  • Health check endpoints
  • Load testing scenarios

πŸ”’ Security Features

  • JWT-based authentication
  • Role-based access control
  • Input validation and sanitization
  • Rate limiting
  • CORS configuration
  • Helmet security headers
  • SQL injection prevention
  • XSS protection

πŸ“ API Documentation

Access the API documentation at:

  • Swagger UI: http://localhost:5000/api-docs
  • API Endpoints: http://localhost:5000/api/v1

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new features
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License.

🎯 Interview Tips

Before the Interview

  • Review the project structure and understand the architecture
  • Practice explaining your design decisions
  • Be prepared to discuss trade-offs and alternatives
  • Review common MERN stack interview questions

During the Interview

  • Start with understanding the requirements clearly
  • Ask clarifying questions about edge cases
  • Explain your approach before coding
  • Write clean, readable code with proper comments
  • Consider performance and security implications
  • Be ready to discuss scalability and optimization

After Completing Tasks

  • Be prepared to explain your implementation
  • Discuss potential improvements and optimizations
  • Show understanding of best practices and patterns
  • Demonstrate knowledge of testing and deployment strategies

Good luck with your interview! πŸš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published