Skip to content
/ Hanno Public

Bookstore API A REST API for managing books and authors like a librarian.

Notifications You must be signed in to change notification settings

Shoetan/Hanno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore API

A REST API for managing books and authors like a librarian.

Project Structure

  • openapi.yaml: API specification – refer to this for request/response formats
  • internal/api/types.go: Request/response types and validation
  • internal/api/handlers.go: HTTP handlers using standard net/http
  • internal/db/: SQLC-generated database code
  • internal/db/migrations/: Database schema and seed data

Endpoints

  1. Authors and Books:
    • GET /api/v1/authors: List all authors
    • GET /api/v1/books: List all books
    • POST /api/v1/books: Create a new book
    • PUT /api/v1/books/{id}: Update a book
    • DELETE /api/v1/books/{id}: Delete a book
    • GET /api/v1/authors/{id}/stats: Get author statistics

Getting started

Ensure the following tools are installed on your system:

Getting Started

# Install dependencies and tools
make setup

# Start PostgreSQL
make docker-up

# Run migrations
make migrate-up

# Run the API
make run
# API will be available at http://localhost:8080

Note

  • Use make run to restart the API after changes
  • See Makefile for all available commands
  • PostgreSQL is accessible at localhost:5432
  • Database credentials: bookstore/bookstore
  • Each time you run make migrate-up, the database is seeded with:
    • A set of authors and books
    • 10,000 randomized book sales records
    • Note: Sales data will be different after each migration

About

Bookstore API A REST API for managing books and authors like a librarian.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published