A web application for tracking books you've read and unlocking achievements for consistent reading habits.
- Frontend: React (Vite)
- Backend: Express.js
- Database: MySQL with Sequelize ORM
- Authentication: JWT tokens
BookTrack/
├── client/ # React frontend
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── context/ # React context (Auth)
│ │ ├── pages/ # Page components
│ │ └── services/ # API service
│ └── package.json
│
└── server/ # Express backend
├── config/ # Database configuration
├── middleware/ # Auth middleware
├── models/ # Sequelize models
├── routes/ # API routes
├── index.js # Server entry point
└── package.json
- Node.js (v18+)
- MySQL server running locally
Create a MySQL database:
CREATE DATABASE booktrack;cd server
cp .env.example .env
# Edit .env with your MySQL credentials and JWT secret
npm install
npm run devThe server will start on http://localhost:5001 (or the PORT specified in your .env).
You should see:
Database synced successfully
Server running on port 5001
cd client
npm install
npm run devRun this SQL to add some starter achievements:
INSERT INTO achievements (name, description, criteria, icon, createdAt, updatedAt) VALUES
('First Book', 'Finish your first book', '{"type": "books_finished", "count": 1}', '📖', NOW(), NOW()),
('Bookworm', 'Finish 5 books', '{"type": "books_finished", "count": 5}', '📚', NOW(), NOW()),
('Avid Reader', 'Finish 10 books', '{"type": "books_finished", "count": 10}', '🏆', NOW(), NOW()),
('Library Builder', 'Finish 25 books', '{"type": "books_finished", "count": 25}', '🏛️', NOW(), NOW());POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user
GET /api/books/search?q=query- Search Google BooksPOST /api/books- Add book to databaseGET /api/books/:id- Get book by ID
GET /api/user-books- Get user's booksPOST /api/user-books- Add book to user's listPUT /api/user-books/:id- Update book statusDELETE /api/user-books/:id- Remove from listGET /api/user-books/history- Get read history
GET /api/achievements- Get all achievementsGET /api/achievements/user- Get user's achievementsPOST /api/achievements/check- Check for new achievements
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=booktrack
DB_PORT=3306
JWT_SECRET=your_generated_jwt_secret_key
JWT_EXPIRES_IN=7d
PORT=5001
GOOGLE_BOOKS_API_KEY=optional_api_key
Note: Generate a strong JWT_SECRET with:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"Each team member needs their own local .env file with their MySQL credentials.