A production-ready full-stack application built with Express.js backend and React 19 frontend, demonstrating clean architecture, scalability, and best practices.
- Session & token-based authentication
- Login/Logout APIs
- Session & token expiry management
- "Remember me" functionality
- Protected routes
- HTTP-only cookie token storage
- Upload and import CSV files (Sample 1 format)
- Generate XLSX files (Sample 2 format)
- Stock data management
- File validation and error handling
- Optimized database schema with proper indexes
- Prisma migrations and seeders
- Complex SQL queries for data analysis
- Scalable for millions of records
- Node.js with ES6 Modules
- Express.js
- MySQL with Prisma ORM
- JWT & Express Session
- CSV parsing and XLSX generation
- Bcrypt for password hashing
- React 19
- TypeScript
- Vite
- TailwindCSS
- shadcn/ui components
- Custom theme system (light/dark mode)
project-root/
├── backend/ # Express.js backend (ES6 modules)
│ ├── config/ # Configuration files
│ ├── controllers/ # Request handlers
│ ├── middleware/ # Custom middleware
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ ├── validators/ # Input validation
│ ├── utils/ # Helper functions
│ ├── prisma/ # Prisma schema, migrations, seed
│ └── queries/ # SQL queries (Task 3)
├── frontend/ # React 19 frontend
│ └── src/
│ ├── components/ # React components (UI + Logic separated)
│ ├── pages/ # Page components
│ ├── hooks/ # Custom hooks
│ ├── services/ # API services
│ └── utils/ # Helper functions
└── README.md # This file
- Node.js (LTS version - v18 or higher)
- MySQL database (v5.7 or higher)
- npm or yarn
git clone https://github.com/Jaffer720/Node-Task.git
cd Taskcd backend
npm installCreate .env file:
# Windows (PowerShell)
Copy-Item .env.example .env
# Linux/Mac
cp .env.example .envEdit .env and update the DATABASE_URL with your MySQL credentials:
DATABASE_URL="mysql://root:your_password@localhost:3306/task_db"Generate Prisma Client, run migrations, and seed database:
npm run prisma:generate
npm run migrate
npm run seedStart the backend server:
npm run dev✅ Backend will run on http://localhost:3000
Open a new terminal:
cd frontend
npm install
npm run dev✅ Frontend will run on http://localhost:5173
Open your browser and navigate to: http://localhost:5173
Login with:
- Email:
admin@example.com - Password:
admin123
After running npm run seed in the backend, you can login with:
Admin User:
- Email:
admin@example.com - Password:
admin123
Test Users (for Task #3):
- Email:
user1@example.comtouser10000@example.com - Password:
password123
POST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/verify- Verify authenticationPOST /api/auth/refresh- Refresh token
POST /api/csv/upload- Upload CSV file (requires authentication)GET /api/csv/generate- Generate Sample 2 file (requires authentication)
SQL queries are available in backend/queries/task3-queries.sql:
- Select all users with address count
- Select users without addresses
- Select duplicate addresses with counter
- Uses ES6 modules (
type: "module"in package.json) - Prisma ORM with full ES6 support
- Hot reload with
npm run dev - Migrations:
npm run migrate - Seeders:
npm run seed - Prisma Studio:
npm run prisma:studio(database GUI)
- React 19 with TypeScript
- Component separation pattern (UI + Logic)
- shadcn/ui components
- TailwindCSS with dark mode
- Vite for fast development
Each feature component follows a separation pattern:
ComponentUI.tsx- Pure UI component (no business logic)useComponent.ts- Custom hook with all logicindex.tsx- Main export combining both
This ensures:
- Testability: Logic can be tested independently
- Reusability: UI can be reused with different logic
- Maintainability: Clear separation of concerns
- Type Safety: Full TypeScript support
cd backend
npm startcd frontend
npm run build
npm run previewISC