Book Management Backend is a RESTful API built with Golang following Clean Architecture.
It provides book, author, and user management with JWT authentication, uses PostgreSQL for data storage,
supports Cloudinary for image uploads, and includes Swagger for API documentation.
You can see the live deployed version of the API and explore its endpoints on Swagger UI:
π Book Management Backend Swagger API
Here youβll find full API documentation, try out endpoints, check request/response schemas, etc.
βββ π .git/ π« (auto-hidden) # Git metadata, do not touch
βββ π book-management-backend/ # Main project source
β βββ π cmd/ # Application entry point
β β βββ π΅ main.go # Main file, starts the server
β βββ π configs/ # Configuration management, loads from .env
β β βββ π΅ config_env.go # Loads env variables and configs
β βββ π docs/ # Auto-generated Swagger docs (do not edit manually)
β β βββ π΅ docs.go
β β βββ π swagger.json
β β βββ βοΈ swagger.yaml
β βββ π internal/ # Business logic (Clean Architecture)
β β βββ π handlers/ # Controllers: handle requests β call services
β β β βββ π΅ auth_handler.go
β β β βββ π΅ author_handler.go
β β β βββ π΅ book_handler.go
β β β βββ π΅ genre_handler.go
β β βββ π middlewares/ # Middleware (auth, logging, CORS, etc.)
β β β βββ π΅ auth_middleware.go
β β β βββ π΅ cors_middleware.go
β β β βββ π΅ ip_middleware.go
β β βββ π models/ # Entities / structs mapping to DB
β β β βββ π΅ author.go
β β β βββ π΅ book.go
β β β βββ π΅ genre.go
β β β βββ π΅ user.go
β β βββ π repositories/ # Repository layer: DB queries
β β β βββ π΅ author_repository.go
β β β βββ π΅ book_repository.go
β β β βββ π΅ genre_repository.go
β β β βββ π΅ user_repository.go
β β βββ π routers/ # HTTP route definitions
β β β βββ π΅ auth_routes.go
β β β βββ π΅ author_routes.go
β β β βββ π΅ book_routes.go
β β β βββ π΅ genre_routes.go
β β β βββ π΅ router.go
β β βββ π services/ # Service layer: business logic
β β β βββ π΅ author_service.go
β β β βββ π΅ book_service.go
β β β βββ π΅ genre_service.go
β β β βββ π΅ user_service.go
β β βββ π wire/ # Dependency injection (Google Wire / manual DI)
β βββ π notes/ # Development notes (internal docs)
β β βββ π RUN.md # How to run the project
β β βββ π init.txt
β β βββ π lib.txt
β β βββ π run.txt
β β βββ π structure.txt
β βββ π pkg/ # Reusable packages (utils, db, etc.)
β β βββ π databases/
β β β βββ π΅ postgresql.go # PostgreSQL connection & migrations
β β βββ π utils/
β β βββ π΅ cloudinary.go # Cloudinary image upload helper
β β βββ π΅ jwt.go # JWT helper functions
β βββ π tmp/ π« (auto-hidden) # Temporary files (e.g., from Air hot reload)
β βββ βοΈ .air.toml # Air configuration (hot reload)
β βββ π .env π« (auto-hidden) # Environment file (production/secret)
β βββ π .env.local π« (auto-hidden) # Local environment file (development)
β βββ π DockerFile.local # Dockerfile for local development
β βββ βοΈ docker-compose-local.yaml # Docker Compose (Go + PostgreSQL)
β βββ π΅ go.mod # Go module definition
β βββ π΅ go.sum # Dependency checksums
βββ π« .gitignore # Files ignored by Git
βββ π README.md # Main documentation (project overview)
- Build and start containers:
docker compose -f docker-compose-local.yaml up -d --build- Builds the
book_app:devimage and starts the app + PostgreSQL containers.
- Subsequent runs:
docker compose -f docker-compose-local.yaml up -d- Starts containers without rebuilding.
- Stop containers:
docker compose -f docker-compose-local.yaml down- Stops and removes containers.
- Database connection and migrations are handled automatically via GORM.
- App runs on port
8080inside Docker, accessible athttp://localhost:8080/.
- Golang π¦
- Gin β‘ (HTTP web framework)
- GORM π¦ (ORM for database)
- PostgreSQL π
- JWT Authentication π
- Cloudinary βοΈ (image upload)
- Swagger π (API docs)
- Docker π³ (containerization)