A complete authentication system with a React frontend and Node.js backend, built with TypeScript and modern development practices.
This project demonstrates a full-stack authentication system with the following features:
- User registration and login
- Protected routes
- Form validation with React Hook Form and Zod
- API handling with React Query
- Type-safe API interactions
- Error handling and user feedback
- React with TypeScript
- React Router for navigation
- React Hook Form for form management
- Zod for schema validation
- React Query for data fetching and caching
- Tailwind CSS for styling
- Axios for API requests
- Node.js with Express
- TypeScript for type safety
- Prisma ORM for database interactions
- SQLite database (for development)
- JWT for authentication
- bcrypt for password hashing
/
├── src/ # Frontend React application
│ ├── api/ # API client code
│ ├── components/ # Reusable UI components
│ ├── contexts/ # React context providers
│ ├── hooks/ # Custom React hooks
│ ├── pages/ # Application pages
│ └── types/ # TypeScript type definitions
├── backend/ # Backend Node.js application
│ ├── prisma/ # Prisma schema and migrations
│ └── src/ # Backend source code
│ ├── controllers/ # Route controllers
│ ├── middleware/ # Express middleware
│ ├── models/ # Types for requst and payload
│ └── routes/ # API routes
├── README.md # Project documentation
└── package.json # Project dependencies and scripts
- Node.js v16+
- npm or yarn
-
Clone the repository
-
Install dependencies for both frontend and backend:
# Install frontend dependencies npm install # Install backend dependencies cd backend && npm install
-
Set up environment variables for the backend:
Create a
.envfile in thebackenddirectory with:DATABASE_URL="file:./dev.db" JWT_SECRET="your_jwt_secret_key_here" PORT=5000 -
Initialize the database:
cd backend && npx prisma migrate dev --name initStart both the frontend and backend with a single command:
npm run dev:allOr run them separately:
# Frontend
npm run dev
# Backend
npm run backendThe frontend will be available at http://localhost:5173 and the backend API at http://localhost:5000.
- Start the development servers
- Make changes to the code
- The changes will be reflected automatically due to hot reloading
# Build frontend
npm run build
# Build backend
cd backend && npm run build