Skip to content

Repository files navigation

Simple Auth Project

Simple Auth Project Screenshot

🎉 Your Auth App is Ready!

📦 What You Have

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

🚀 Start Your App NOW

Easiest Way (Windows):

# Just double-click:
START.bat

Or manually start in 3 terminals:

Terminal 1 (Docker):

docker-compose up -d

Terminal 2 (Backend):

cd backend
pnpm dev

Terminal 3 (Frontend):

cd frontend
pnpm dev

📱 Access Your App

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)

🧪 Test It Out

  1. Open http://localhost:5173
  2. Register with any username/email/password
  3. Login with those same credentials
  4. See personalized dashboard with stats
  5. Check database at http://localhost:8080 to see your user!

📊 Database Info

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;"

📚 Documentation Files

  • 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 Structure

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

🔐 Security Features

✅ 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


🚢 Next Steps (Optional)

1. Deploy Frontend (Free Options)

cd frontend
pnpm build
# Deploy 'dist' folder to:
# - Vercel (free, automatic)
# - Netlify (free, drag & drop)
# - GitHub Pages

2. Deploy Backend

Railway.app (Free tier):

  1. Push code to GitHub
  2. Connect Railway.app
  3. Set environment variables
  4. Deploy with one click

Alternative: Heroku Docker deployment

3. Use Cloud Database

  • PlanetScale (MySQL, free tier)
  • Railway (PostgreSQL/MySQL)
  • CockroachDB (free tier)

🆘 Common Issues

"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

📞 Quick Reference

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)

✨ What's Possible Now

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.

Releases

Packages

Used by

Contributors

Languages