A RESTful API for a Bookstore application built with Go, Fiber, GORM, and JWT authentication.
Features user registration/login, password reset via email, book management, and comment/like/dislike functionality.
- User registration and login with JWT authentication
- Password reset via email (Resend API integration)
- Book CRUD operations (protected routes)
- Commenting, liking, and disliking on books
- Modular structure: handlers, services, repositories, middleware
- CORS and request logging middleware
- Go
- Fiber (web framework)
- GORM (ORM)
- JWT (authentication)
- Resend (email service)
- [SQLite/MySQL/Postgres] (database, configurable)
- Go 1.18+
- A supported database (SQLite, MySQL, or Postgres)
- Resend API key (for email)
-
Clone the repository:
git clone https://github.com/yourusername/bookstore-api.git cd bookstore-api -
Install dependencies:
go mod tidy
-
Configure your environment variables and database connection as needed.
-
Run database migrations (if needed):
go run cmd/main.go -
Start the server:
go run cmd/main.goThe API will be available at
http://localhost:3001.
POST /user/register— Register a new userPOST /user/login— Login and receive JWTPOST /user/request-password-reset— Request password reset emailPOST /user/reset-password— Reset password
GET /user/:id— Get user by IDGET /user/:username— Get user by username
POST /book/— Create a bookGET /book/— List all booksGET /book/:id— Get book by ID
POST /book/:bookID/comments/— Add comment to a bookGET /book/:bookID/comments/— List comments for a bookPOST /book/:bookID/comments/:commentID/like— Like a commentPOST /book/:bookID/comments/:commentID/dislike— Dislike a comment
bookstore-api/
├── cmd/
│ └── main.go
├── config/
├── database/
├── handlers/
├── middleware/
├── models/
├── repositories/
├── services/
├── go.mod
└── go.sum
MIT
Contributions welcome!
Feel free to open issues or pull requests.