Skip to content

Asura409/bookstore-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore API

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.

Features

  • 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

Tech Stack

  • Go
  • Fiber (web framework)
  • GORM (ORM)
  • JWT (authentication)
  • Resend (email service)
  • [SQLite/MySQL/Postgres] (database, configurable)

Getting Started

Prerequisites

  • Go 1.18+
  • A supported database (SQLite, MySQL, or Postgres)
  • Resend API key (for email)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/bookstore-api.git
    cd bookstore-api
  2. Install dependencies:

    go mod tidy
  3. Configure your environment variables and database connection as needed.

  4. Run database migrations (if needed):

    go run cmd/main.go
    
  5. Start the server:

    go run cmd/main.go
    

    The API will be available at http://localhost:3001.

API Endpoints

Public

  • POST /user/register — Register a new user
  • POST /user/login — Login and receive JWT
  • POST /user/request-password-reset — Request password reset email
  • POST /user/reset-password — Reset password

Protected (JWT required)

  • GET /user/:id — Get user by ID
  • GET /user/:username — Get user by username

Books

  • POST /book/ — Create a book
  • GET /book/ — List all books
  • GET /book/:id — Get book by ID

Comments

  • POST /book/:bookID/comments/ — Add comment to a book
  • GET /book/:bookID/comments/ — List comments for a book
  • POST /book/:bookID/comments/:commentID/like — Like a comment
  • POST /book/:bookID/comments/:commentID/dislike — Dislike a comment

Project Structure

bookstore-api/
├── cmd/
│   └── main.go
├── config/
├── database/
├── handlers/
├── middleware/
├── models/
├── repositories/
├── services/
├── go.mod
└── go.sum

License

MIT


Contributions welcome!
Feel free to open issues or pull requests.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages