A complete full-stack authentication system with:
✅ Frontend (React + Vite)
- Beautiful login page with dark/light design
- Registration page matching login design
- Interactive dashboard with user stats
- Icon-based UI with react-icons
- Responsive Tailwind CSS styling
✅ Backend (Node.js + Express)
- User registration with bcrypt password hashing
- Secure JWT authentication
- httpOnly cookie storage (prevents XSS)
- CORS configured for localhost
- Error logging and validation
✅ Database (MySQL in Docker)
- Users table with proper schema
- Connection pooling for efficiency
- Automatic timestamps (created_at, updated_at)
- Unique constraints on username and email
✅ Database Viewer (phpMyAdmin)
- Web-based MySQL management
- No extra installation needed
- Already added to docker-compose.yml
# Just double-click:
START.batTerminal 1 (Docker):
docker-compose up -dTerminal 2 (Backend):
cd backend
pnpm devTerminal 3 (Frontend):
cd frontend
pnpm dev| What | Where | Login |
|---|---|---|
| Register/Login | http://localhost:5173 | Just register! |
| View Database | http://localhost:8080 | root / fuck_yall_niggas |
| Backend API | http://localhost:5000 | (runs in background) |
- Open http://localhost:5173
- Register with any username/email/password
- Login with those same credentials
- See personalized dashboard with stats
- Check database at http://localhost:8080 to see your user!
Default Credentials:
Host: localhost
Port: 3306
User: root
Password: fuck_yall_niggas
Database: auth_db
Table Structure:
users (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL [hashed],
created_at TIMESTAMP,
updated_at TIMESTAMP
)Query Examples:
# See all users
docker exec -it auth_mysql mysql -uroot -pfuck_yall_niggas auth_db -e "SELECT * FROM users;"
# Count users
docker exec -it auth_mysql mysql -uroot -pfuck_yall_niggas auth_db -e "SELECT COUNT(*) FROM users;"- START.md - Quick start instructions
- LOCAL_HOSTING_GUIDE.md - Detailed hosting setup (MySQL Workbench, CLI, etc.)
- docker-compose.yml - Docker configuration (MySQL + phpMyAdmin)
- backend/.env - Backend environment variables
- frontend/.env - Frontend environment variables (if needed)
project/
├── frontend/ # React app (Vite)
│ ├── src/
│ │ ├── LoginForm.jsx # Login page
│ │ ├── RegisterForm.jsx # Register page
│ │ ├── Dashboard.jsx # Post-login dashboard
│ │ ├── App.jsx # Routes
│ │ └── api.js # API configuration
│ └── package.json
│
├── backend/ # Express server
│ ├── server.js # Main app
│ ├── authController.js # Auth logic
│ ├── db.js # Database connection
│ ├── middleware.js # Auth middleware
│ ├── .env # Settings
│ └── package.json
│
├── docker-compose.yml # Docker setup
├── init.sql # Database init script
├── START.md # Quick start
├── START.bat # Windows quick start
└── LOCAL_HOSTING_GUIDE.md # Detailed guide
✅ Passwords hashed with bcrypt (12 salt rounds) ✅ JWT tokens stored in secure httpOnly cookies ✅ CSRF protection with SameSite=Strict ✅ SQL injection prevention with parameterized queries ✅ Timing-attack resistant password comparison ✅ Email/username uniqueness enforced at DB level ✅ CORS configured only for localhost
cd frontend
pnpm build
# Deploy 'dist' folder to:
# - Vercel (free, automatic)
# - Netlify (free, drag & drop)
# - GitHub PagesRailway.app (Free tier):
- Push code to GitHub
- Connect Railway.app
- Set environment variables
- Deploy with one click
Alternative: Heroku Docker deployment
- PlanetScale (MySQL, free tier)
- Railway (PostgreSQL/MySQL)
- CockroachDB (free tier)
"Port X already in use"
# Windows - find and kill process
netstat -ano | findstr :5173
taskkill /PID <pid> /F"Docker not found"
- Install Docker Desktop from docker.com
- Restart your terminal after installing
"Cannot login"
- Make sure backend is running (see Terminal 2 output)
- Check database has users: Visit phpMyAdmin
"Database connection error"
# Reset everything
docker-compose down -v
docker-compose up -d| Task | Command |
|---|---|
| Start all | START.bat (Windows) or see START.md |
| Stop all | docker-compose down + Ctrl+C in terminals |
| Reset DB | docker-compose down -v && docker-compose up -d |
| View logs | Check the terminal where app is running |
| Kill port | taskkill /PID <pid> /F (Windows) |
Your authentication system is production-ready! You can:
✅ Register new users ✅ Login with credentials ✅ View user account info ✅ Logout securely ✅ View all registered users in database ✅ Add more features (password reset, profile editing, etc.) ✅ Deploy to production ✅ Scale to many users
You're all set! 🎉 Start the app and enjoy!
Questions? Check LOCAL_HOSTING_GUIDE.md for detailed instructions.
