Admin dashboard project with a React + Redux frontend and a Node.js + TypeScript backend (JWT auth + MongoDB).
This repository currently contains two applications:
Frontend: Dashboard UI, authentication screen, and CRUD-style management pages.blog-tutorials/node-api-jwt-auth: Backend API for authentication and user management.
- Built with Vite + React 19 + Tailwind CSS.
- Routing with
react-router-dom(login page + nested dashboard layout). - Global state with Redux Toolkit (
auth,brand,productslices). - Auth gate in layout: only
adminandsuper_adminroles can access/dashboard. - Login page currently uses mocked authentication data (no backend call yet).
Home: metrics/cards/charts and analytics widgets.Brands: create, list, update, delete (stored in Redux state).Products: fetch initial products from Fake Store API + local create/update/delete.Category: routes are scaffolded, UI pages are currently placeholders.- Reusable UI pieces: sidebar, top navigation, footer, loading component, toast notifications.
- Built with Express + TypeScript + MongoDB (Mongoose).
- JWT-based authentication and role-based route protection.
- Seeders run at startup (roles + default super admin user).
POST /auth/signupPOST /auth/loginPOST /auth/login-passwordPOST /auth/admins(super admin only)GET /users(admin/super admin)GET /users/me(authenticated user)- CORS enabled for local frontend integration.
.
|-- Frontend
| |-- src
| | |-- Pages
| | |-- Components
| | |-- Store
| | |-- Router
| | `-- Utils
| `-- package.json
`-- blog-tutorials
`-- node-api-jwt-auth
|-- src
| |-- controllers
| |-- models
| |-- config
| `-- seeders
`-- package.json
- Node.js 20+
- npm
cd Frontend
npm install
npm run devFrontend runs on Vite default port (usually http://localhost:5173).
Create Frontend/.env:
VITE_BASE_URL=http://localhost:4500/Note: VITE_BASE_URL is already wired in Frontend/src/Utils/FetchData.js.
- Node.js 20+
- yarn
- MongoDB (local or Docker)
docker run -d --rm -e MONGO_INITDB_ROOT_USERNAME=user -e MONGO_INITDB_ROOT_PASSWORD=secret -p 27018:27017 --name mongodb mongo:8.0Create blog-tutorials/node-api-jwt-auth/.env:
HOST=http://localhost
PORT=4500
MONGODB_URL=mongodb://user:secret@localhost:27018/admin
JWT_SECRET=replace_with_a_strong_secret
JWT_EXPIRE=3600cd blog-tutorials/node-api-jwt-auth
yarn install
yarn startBackend runs on http://localhost:4500.
When backend starts, it seeds this account:
- Email:
ned@stark.com - Password:
123456
Use it only for local development; change in production-like environments.
Right now, frontend login is mocked in Frontend/src/Pages/Auth/index.jsx.
To connect real backend auth:
- Replace mocked auth in
handleSubmitwith an API request toPOST /auth/login. - Send this body:
{
"email": "ned@stark.com",
"password": "123456"
}- On success, store
data.tokenin Reduxauth.tokenanddata.userin Reduxauth.user. - Keep
Authorization: Bearer <token>header for protected backend routes (/users,/users/me).
Important integration note:
- Current frontend
Brands/Products/Categorypages are mostly local-state CRUD and Fake Store API driven. - If you want full backend-powered CRUD for those modules, backend endpoints for brands/products/categories must be added first (they are not implemented yet in
node-api-jwt-auth).
npm run dev- start development servernpm run build- production buildnpm run preview- preview buildnpm run lint- lint source
yarn start- run API withts-nodeyarn build- compile TypeScriptyarn lint- lint sourceyarn lint:fix- auto-fix lint issues
- Frontend dashboard experience is implemented and usable locally.
- Backend authentication API is implemented and can be connected.
- Category and full backend CRUD for dashboard entities are pending.
