The project is not complete, todo :
- dockerize
- simple frontend with templating
This is Rest A.P.I project written in go and mysql with pure net/http. This project logic handled with mysql stored procedure.
- Go Installed
- Mysql Installed
- Git Clone
https://github.com/Fadil-Tao/manga-basis-data.git - Create a user in mysql
- Follow the env example
- run migration with
go run cmd/migrate/main.go up for migration help
go run cmd/migrate/main.go -h - run server with
go run cmd/api/main.gotheres provided admin user :
"email" : "admin@gmail.com",
"username" : "admin",
"password" : "12345678"Authentication-related endpoints for login, registration, and logout.
POST /login
Description: User login.
Example Request:
{
"email": "rio@gmail.com",
"password": "rionandosoeksin"
}Example Response
{
"Message": "Login Success"
}POST /register
Description: User registration.
Example Request example
{
"username": "ilham",
"email": "ilham@gmail.com",
"password": "ilham123456"
}Example Response example
{
"message": "User Registered successfully"
}POST /logout
Description: User logout.
Example Response
{
"Message": "Log out Success"
}Endpoints for managing author data, including adding, retrieving, updating, and deleting authors.
POST /author
Description: Add a new author (Admin only).
Example Request:
{
"name": "miyamoto",
"birthday": "1960-06-07",
"biography": "Guy who likes to draw"
}Example Response
{
"message": "Author Created successfully"
}GET /author
Description: Retrieve all authors
Example Response :
{
"message": "Authors Succesfully Retrieved",
"data": [
{
"id": "1",
"name": "Kinji Hakari",
"birthday": "1982-10-02"
},
{
"id": "3",
"name": "fujimoto",
"birthday": "1998-05-20"
}
]
}GET /author/{id}
Description : Retrieve author details by ID.
Example Response :
{
"message": "data succesfully retrieved",
"data": {
"id": "10",
"name": "hiroiko tanaka",
"birthday": "1998-01-20",
"biography": "i like fish",
"Manga": null
}
}PUT /author/{id}
Description : Update author details (admin only).
Example Request :
{
"name": "hiroiko tanaka",
"birthday": "1998-01-20",
"biography": "i like fish"
}Example Response :
{
"name": "hiroiko tanaka",
"birthday": "1998-01-20",
"biography": "i like fish"
}DELETE /author/{id}
Description : Delete an author by ID (admin only). Example Response:
{
"message": "Author successfully deleted"
}Endpoints for managing genre data, including creating, retrieving, updating, and deleting genres.
POST /genre
Description: Create a new genre (Admin Only)
Request:
{
"name": "romance",
"description": "Story about loves"
}Response:
{
"message": "Genre Created successfully"
}GET /genre
Description : Retrieve All Genre Example Response :
{
"message": "Genres successfully retrieved",
"data": [
{
"id": "1",
"name": "horror",
"description": "stories about scary stuffs"
},
{
"id": "4",
"name": "sport",
"description": "about sports"
},
{
"id": "6",
"name": "Isekai",
"description": "Story about transport into different world"
},
{
"id": "8",
"name": "motor jawa",
"description": "Story about transport into different world"
},
{
"id": "9",
"name": "romance",
"description": "Story about loves"
}
]
}POST /genre/{id}
Description : Update genre data by ID (Admin Only) Example Request:
{
"name": "native fantasy",
"description": "stories about native"
}Example Response:
{
"message": "Genre updated successfully"
}DELETE /genre/{id}
Description : Delete Genre By Id (Admin only) Example Response :
{
"message": "Genre successfully deleted"
}Endpoints for managing manga, including creation, association with authors/genres, liking, retrieval, updating, and deletion.
POST /manga
Description: Create a new manga (Admin Only)
Example Request:
{
"title": "Berserkin time",
"synopsys": "This one is so edgy",
"status": "in_progress",
"published_at": "2004-05-22",
"finished_at": "2016-09-22"
}Example Response:
{
"message": "Manga Created successfully"
}POST /manga/{id}/author
Description : Associate an author with a manga (Admin Only) Example Request :
{
"authorId": 5
}Example Response :
{
"message": "Author and Manga connected successfully"
}POST /manga/{id}/genre
Description : Associate a genre with a manga Example Request :
{
"genreId": 1
}Example Response:
{
"message": "Toggle triggered successfully"
}GET /manga
Description : Retrieve a list of all manga. Example Reponse :
{
"message": "succefully retrieved manga",
"data": [
{
"id": "2",
"title": "Attack On Titan",
"status": "finished",
"published_at": "2010-05-22",
"finished_at": "2020-09-22",
"rating": 0,
"totalReview": 0,
"likes": 1,
"totalUserRated": 0
},
{
"id": "4",
"title": "Berserk",
"status": "finished",
"published_at": "2004-05-22",
"finished_at": "2016-09-22",
"rating": 0,
"totalReview": 0,
"likes": 1,
"totalUserRated": 0
}
]
}GET /manga?name={name}
Description : Search for manga by name.
Example: /manga?name=ber
Example Response :
{
"message": "succefully retrieved manga",
"data": [
{
"id": "4",
"title": "Berserk",
"status": "finished",
"published_at": "2004-05-22",
"finished_at": "2016-09-22",
"rating": 0,
"totalReview": 0,
"likes": 0,
"totalUserRated": 0
}
]
}GET /manga/{id}
Description: Retrieve manga details by ID.
Example Response :
{
"message": "manga success retrieved",
"data": {
"id": "4",
"title": "Berserk",
"synopsys": "This one is so edgy",
"status": "finished",
"published_at": "2004-05-22",
"finished_at": "2016-09-22",
"genre": [
{
"id": "1",
"name": "horror"
}
],
"author": [
{
"id": "5",
"name": "Hajime Isayama"
}
]
}
}PUT /manga/{id}
Description : Retrieve author details by ID.
Example: /manga/4
Example Request:
{
"title": "ben ten",
"synopsys": "naruto",
"status": "in_progress",
"published_at": "2000-05-22",
"finished_at": "2015-09-22"
}Example Response:
{
"message": "Manga updated successfully"
}DELETE /manga/{id}
Description : Retrieve author details by ID.
Example : /manga/5
Example Response :
{
"message": "Manga successfully deleted"
}DELETE /manga/{mangaId}/author/{authorId}
Description : Delete an association between a manga and an author. (Admin)
Example : /manga/1/author/7
Example Response :
{
"message": "Deleted successfully"
}DELETE /manga/{mangaId}/genre/{genreId}
Description : Delete an association between a manga and a genre.(Admin Only)
Example Response :
{
"message": "Deleted successfully"
}Endpoint for user to give rating to a manga on scale 1-10
POST /manga/{id}/rating
Description: Rate a manga.
Example: /manga/1/rating
Example Request:
{
"rating": 10
}Endpoints for managing readlists and their associated manga items.
POST /readlist
Description: Create a new readlist.
Example Request:
{
"name": "xxx",
"description": "xxx"
}Example Response :
{
"message": "Readlist Created successfully"
}POST /readlist/{id}/item
Description : : Add a manga to a readlist (Admin Only) Example Request:
{
"mangaId": "2",
"readStatus": "done"
}Example Response:
{
"message": "manga added to readlist successfully"
}GET /readlist
Description : Retrieve all readlists
Example Response:
{
"message": "readlist succesfully retrieved",
"data": [
{
"id": "1",
"owner": "jenipers",
"name": "My most despised readlist",
"description": "i hate this book very much",
"created_at": "2024-11-29 05:24:44",
"updated_at": "2024-11-29 05:54:30"
},
{
"id": "3",
"owner": "rionandoo",
"name": "isekaioo",
"description": "this is just bunch of book i wish to read if i have free time",
"created_at": "2024-12-03 03:49:25",
"updated_at": "2024-12-03 03:49:25"
}
]
}GET /readlist/{id}/item
Description : Retrieve all manga items in a readlist.
Example Response :
{
"message": "readlist item succesfully retrieved",
"data": [
{
"mangaId": "4",
"title": "Berserk",
"readStatus": "done",
"addedAt": "2024-12-03 03:52:08"
}
]
}PUT /readlist/{id}
Description : Update a readlist's details
Example Request :
{
"name": "Koleksi Buku Rio",
"description": "People Come and go"
}Example Response :
{
"message": "Readlist updated successfully"
}PUT /readlist/{readlistId}/manga/{mangaId}
Description : Update the reading status of a manga in a readlist.
Example Request
{
"status": "done"
}Example Response
{
"message": "Readlist updated successfully"
}DELETE /readlist/{readlistId}/manga/{mangaId}
Example Response:
{
"message": "Readlist item deleted successfully"
}Endpoints for creating, retrieving, and managing reviews for manga.
POST /manga/{id}/review
Description: Create a review for a manga.
Example: /manga/4/review
Example Request:
{
"review": "My fav so far",
"tag": "Reccomended"
}Example Response :
{
"message": "Review Created successfully"
}GET /manga/{id}/review
Description : Retrieve a list of reviews for a manga.
Example : /manga/4/review
Example Response :
{
"message": "review succesfully retrieved",
"data": [
{
"username": "fery",
"user_id": "2",
"review": "i dont love it!",
"tag": "Not Reccomended",
"created_at": "2024-12-03 07:29:49",
"like": 0
},
{
"username": "ilham",
"user_id": "5",
"review": "i love it!",
"tag": "Reccomended",
"created_at": "2024-12-03 07:29:18",
"like": 0
},
{
"username": "rionandoo",
"user_id": "4",
"review": "i hate narutoo",
"tag": "Mixed Feelings",
"created_at": "2024-12-03 05:39:37",
"like": 1
}
]
}GET /manga/{mangaId}/review/{reviewerId}
Description : Retrieve a specific review for a manga by the reviewer's ID (Admin)
Example : /manga/4/review/4
{
"message": "review data retrieved succesfully",
"data": {
"manga_id": "4",
"username": "rionandoo",
"user_id": "4",
"review": "i hate narutoo",
"tag": "Mixed Feelings",
"created_at": "2024-12-03 05:39:37",
"like": 1
}
}PUT /manga/{mangaId}/review/{reviewerId}/like
Description : Update a review for a manga (Admin Only)
Example : /manga/2/review/4
Example Request :
{
"review": "i hate narutoo",
"tag": "Not Reccomended"
}Example Response :
{
"message": "Review Updated successfully"
}Endpoints for managing user accounts, retrieving user-related information, and performing user-related operations
GET /users
Description : Retrieve all users.
Example Response :
{
"message": "user succesfully retrieved",
"data": [
{
"id": 2,
"username": "fery",
"email": "fery@gmail.com",
"created_at": "2024-11-13 21:31:34"
},
{
"id": 3,
"username": "jenipers",
"email": "jenipers@yahoo.com",
"created_at": "2024-11-25 19:59:36"
},
{
"id": 4,
"username": "rionandoo",
"email": "rio@gmail.com",
"created_at": "2024-12-02 14:20:07"
},
{
"id": 5,
"username": "ilham",
"email": "ilham@gmail.com",
"created_at": "2024-12-03 01:38:48"
}
]
}GET /users?username={query}
Description : Search for a user by username
Example : /users?username=rio
Example Response :
{
"message": "user succesfully retrieved",
"data": [
{
"id": 4,
"username": "rionandoo",
"email": "rio@gmail.com",
"created_at": "2024-12-02 14:20:07"
}
]
}GET /users/{username}
Description : Retrieve detailed information about a specific user.
Example : /users/fery
Example Response :
{
"message": "user succesfully retrieved",
"data": {
"id": 2,
"username": "fery",
"email": "fery@gmail.com",
"created_at": "2024-11-13 21:31:34"
}
}GET /users/{username}/likedmanga
Description : Retrieve the list of manga liked by a specific user.
Example : /users/rionandoo/likedmanga
Example response :
{
"message": "mangas succesfully retrieved",
"data": [
{
"id": "4",
"title": "Berserk",
"status": "finished",
"published_at": "2004-05-22",
"finished_at": "2016-09-22",
"likedAt": "2024-12-03 03:25:16",
"likes": 1
}
]
}GET /users/{username}/ratedmanga
Description : Retrieve the list of manga rated by a specific user.
Example : /users/rionandoo/ratedmanga
Example Response :
{
"message": "mangas succesfully retrieved",
"data": [
{
"id": "4",
"title": "Berserk",
"status": "finished",
"published_at": "2004-05-22",
"finished_at": "2016-09-22",
"ratededAt": "2024-12-03 03:45:35",
"yourRating": 10,
"rating": 1,
"totalUserRated": 10
},
{
"id": "1",
"title": "naruto",
"status": "in_progress",
"published_at": "2000-05-22",
"finished_at": "2015-09-22",
"ratededAt": "2024-12-02 22:35:57",
"yourRating": 7,
"rating": 1,
"totalUserRated": 7
}
]
}GET /users/{username}/readlist
Description : Retrieve the list of readlists owned by a user.
Example : /users/rionandoo/readlist
Example Response :
{
"message": "mangas succesfully retrieved",
"data": [
{
"id": "3",
"name": "Koleksi Buku Rio",
"description": "People Come and go",
"created_at": "2024-12-03 03:49:25",
"updated_at": "2024-12-03 03:59:51"
},
{
"id": "5",
"name": "yohsa",
"description": "this is just bunch of book i wish to read if i have free time",
"created_at": "2024-12-03 05:09:52",
"updated_at": "2024-12-03 05:09:52"
}
]
}PUT /users/{username}
Description : Update a user's information.
Example : /users/rionandoo
Example request :
{
"username": "rionandoo"
}Example response :
{
"message": "User Updated successfully"
}DELETE /users/{username}
Description : Delete a user
Example : /users/rionandoo
Example Response:
{
"message": "user deleted Successfully"
}