A minimal, secure, and extensible backend API for saving and managing bookmarks with support for user authentication, tagging, and protected endpoints. Built with Go, Gin, PostgreSQL, and GORM.
- π JWT-based authentication
- π CRUD operations for bookmarks
- π·οΈ Tag support with many-to-many relationships
- π§βπΌ User registration and login
- π Protected routes with middleware
- π¦ Environment-based configuration
bookmarksaver/
βββ controllers/ # Route handler functions
βββ initializers/ # Environment and DB setup
βββ middleware/ # Auth middleware
βββ models/ # GORM models
βββ main.go # Route definitions and server start
βββ .env # Secret keys and DB URL
- Go
- Gin (HTTP Router)
- GORM (ORM)
- PostgreSQL
- JWT for authentication
- bcrypt for password hashing
git clone https://github.com/jishnu70/BookmarkSaver.git
cd BookmarkSaver
SECRET=your_jwt_secret
DB_URL=postgres://username:password@localhost:5432/bookmarkdb
Make sure PostgreSQL is running and the DB (
bookmarkdb
) exists.
go mod tidy
go run migrate.go
go run main.go
Server will run on
http://localhost:8080
POST /api/register
β Register new userPOST /api/login
β Login and receive JWT token
GET /auth/bookmarks/
β Get all bookmarksGET /auth/bookmarks/:id
β Get a specific bookmarkPOST /auth/bookmarks/
β Create a new bookmarkPUT /auth/bookmarks/:id
β Update a bookmarkDELETE /auth/bookmarks/:id
β Delete a bookmark
{
"title": "My Portfolio",
"url": "https://myportfolio.com",
"tags": ["personal", "work"]
}
- π Refresh tokens
- π Search/filter by tags
- π Swagger docs
- π Docker deployment