A robust authentication application built using the MERN stack with advanced features, providing users with a secure and seamless experience.
- Live: https://gorgeous-palmier-38585b.netlify.app
- Code: https://github.com/roberta484/MERN-Authentication.git
-
User Authentication:
- Sign Up: Create a new account with email verification.
- Sign In: Securely log in to your account.
- Sign Out: End your session safely.
-
Account Management:
- Dashboard: Access user-specific information and manage your account.
- Email Verification: Verify user email addresses using Nodemailer.
- Password Reset: Securely reset forgotten passwords.
-
Responsive Design:
- Built with Tailwind CSS and Shadcn UI for a modern and responsive user interface.
-
State Management:
- Data fetching and state management using Tanstack Query for a smooth user experience.
-
Form Handling:
- Form validation and management with React Hook Form and Zod.
-
Testing:
- Unit test with Jest and supertest for the server-side.
- Api testing with vitest and mock service worker
-
Containerization:
- Entire application is containerized using Docker for easy development.
-
SEO:
- Basic SEO with react-helmet-async
-
security features
- CORS configuration
- Rate limiting
- Input validations
- Helmet
- Error Handling
-
Frontend:
- React
- TypeScript
- Vite
- Tailwind CSS
- Shadcn UI
- React Hook Form
- Zod for validation
- Tanstack Query
- Axios
- Vitest
- Mock Service Worker
-
Backend:
- Node.js
- Express
- MongoDB (with Mongoose)
- TypeScript
- Nodemailer for email services
- Winston for logging
- Jest
-
DevOps & Tools:
- Docker
- Docker Compose
- Git
- Node.js (v18 or higher)
- MongoDB
- Docker (optional)
- Git
-
Clone the Repository
git clone https://github.com/roberta484/MERN-Authentication.git cd MERN-Authentication -
Environment Configuration
Create
.envfiles in both frontend and backend directories:Backend (.env)
NODE_ENV=development PORT=3000 CORS_ORIGIN=http://localhost:5173 FRONTEND_URL=http://localhost:5173 MONGO_DB_URI=mongodb://mongo:27017/mern-auth (for docker) MONGODB_URI=mongodb://localhost:27017/mern-auth ACCESS_SECRET_KEY=secret ACCESS_TOKEN_EXPIRE_TIME="1d" SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_USER=your-email@gmail.com SMTP_PASS=your-app-specific-password
Frontend (.env)
VITE_BACKEND_URL = http://localhost:3000/api/v1
-
Install Dependencies
# Install backend dependencies cd backend npm install # Install frontend dependencies cd ../frontend npm install
-
Start Development Servers
Backend
cd backend npm run devFrontend (new terminal)
cd frontend npm run dev -
Access the Application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
-
Build and Run Containers
docker-compose up --build
-
Stop Containers
docker-compose down
# Run backend tests
cd backend
npm run test