Build a RESTful API for managing bookmarks with user authentication using mostly Go's standard library.
- User registration and authentication with JWT tokens
- CRUD operations for bookmarks (URL, title, description, notes, tags)
- Tag management system
- Search and filter bookmarks by tags and text
- Pagination for bookmark listings
- SQLite database for data persistence
- Use only Go standard library (no external frameworks)
- SQLite database with
database/sqlpackage - JWT authentication
- JSON API responses
- RESTful endpoint design
- ID, Username, Email, Password Hash, Created/Updated timestamps
- ID, User ID, URL, Title, Description, Notes, Tags, Created/Updated timestamps
- ID, User ID, Name, Created timestamp
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user profile
GET /api/bookmarks- List bookmarks (with pagination, search, tag filtering)POST /api/bookmarks- Create bookmarkGET /api/bookmarks/{id}- Get single bookmarkPUT /api/bookmarks/{id}- Update bookmarkDELETE /api/bookmarks/{id}- Delete bookmark
GET /api/tags- List user's tagsDELETE /api/tags/{id}- Delete tag
POST /api/auth/register
{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123"
}{
"token": "jwt_token_here",
"user": {
"id": 1,
"username": "johndoe",
"email": "john@example.com"
}
}POST /api/bookmarks
{
"url": "https://golang.org",
"title": "Go Programming Language",
"description": "Official Go website",
"notes": "Great learning resource",
"tags": ["programming", "go"]
}{
"bookmarks": [
{
"id": 1,
"url": "https://golang.org",
"title": "Go Programming Language",
"description": "Official Go website",
"notes": "Great learning resource",
"tags": ["programming", "go"],
"created_at": "2025-01-08T12:00:00Z",
"updated_at": "2025-01-08T12:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 1,
"total_pages": 1
}
}page- Page number (default: 1)limit- Items per page (default: 20, max: 100)tags- Comma-separated tag names for filteringsearch- Search in title, description, notessort- Sort by: created_at, updated_at, titleorder- Sort order: asc, desc
- JWT tokens required for all bookmark and tag endpoints
- Include token in Authorization header:
Bearer <token> - Tokens expire in 24 hours
- Username: 3-50 characters, alphanumeric + underscore
- Email: Valid email format
- Password: Minimum 8 characters
- URL: Valid HTTP/HTTPS format
- Title: Maximum 500 characters
- Description: Maximum 2000 characters
- Notes: Maximum 5000 characters
- Tags: Maximum 20 tags, each 1-50 characters
{
"error": {
"code": "ERROR_CODE",
"message": "Human readable error message",
"details": {}
}
}- 200 OK - Successful GET/PUT
- 201 Created - Successful POST
- 204 No Content - Successful DELETE
- 400 Bad Request - Invalid input
- 401 Unauthorized - Missing/invalid auth
- 404 Not Found - Resource not found
- 409 Conflict - Duplicate resource
- 500 Internal Server Error - Server error
- SQLite database
- Users table with unique username/email constraints
- Bookmarks table with foreign key to users
- Tags table with user association
- Many-to-many relationship between bookmarks and tags
- Appropriate indexes for performance
- All endpoints functional with proper authentication
- Database operations work correctly
- Input validation prevents invalid data
- Pagination works for large datasets
- Search and filtering return accurate results
- Error handling provides meaningful responses
- Application can be containerized with Docker