Skip to content

πŸ”– A minimal Go + Gin-based backend API for saving and managing user bookmarks with JWT authentication and tag support.

Notifications You must be signed in to change notification settings

jishnu70/BookmarkSaver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Bookmark Saver API

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.


πŸš€ Features

  • πŸ” 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

πŸ“ Project Structure

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

βš™οΈ Tech Stack

  • Go
  • Gin (HTTP Router)
  • GORM (ORM)
  • PostgreSQL
  • JWT for authentication
  • bcrypt for password hashing

πŸ“¦ Setup & Run Locally

1. Clone the repository

git clone https://github.com/jishnu70/BookmarkSaver.git
cd BookmarkSaver

2. Create .env file

SECRET=your_jwt_secret
DB_URL=postgres://username:password@localhost:5432/bookmarkdb

Make sure PostgreSQL is running and the DB (bookmarkdb) exists.

3. Install dependencies

go mod tidy

4. Run migrations

go run migrate.go

5. Start the server

go run main.go

Server will run on http://localhost:8080


πŸ› οΈ API Endpoints

πŸ”“ Public

  • POST /api/register – Register new user
  • POST /api/login – Login and receive JWT token

πŸ” Protected (JWT required in Authorization: Bearer <token> header)

  • GET /auth/bookmarks/ – Get all bookmarks
  • GET /auth/bookmarks/:id – Get a specific bookmark
  • POST /auth/bookmarks/ – Create a new bookmark
  • PUT /auth/bookmarks/:id – Update a bookmark
  • DELETE /auth/bookmarks/:id – Delete a bookmark

πŸ“Œ Example Bookmark JSON

{
  "title": "My Portfolio",
  "url": "https://myportfolio.com",
  "tags": ["personal", "work"]
}

🏁 Future Improvements

  • πŸ”„ Refresh tokens
  • πŸ” Search/filter by tags
  • πŸ“„ Swagger docs
  • πŸš€ Docker deployment

About

πŸ”– A minimal Go + Gin-based backend API for saving and managing user bookmarks with JWT authentication and tag support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages