Project build in accordance with the concept of "Clean Architecture" described in this article https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html REST API with custom JWT-based authentication system. Core functionality is about creating and managing storage of photos.
Structure:
4 Domain layers:
Models layer
Repository layer
UseCase layer
Delivery layer
Creates new user
{
"username": "user",
"password": "mysecretpassword"
}
{
"response": "success"
}
Request to get JWT Token based on user credentials
Request Headers:
Authorization: "Basic dXNlcjU6bXlzZWN1cmVwYXNzd29yZA=="
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzEwMzgyMjQuNzQ0MzI0MiwidXNlciI6eyJJRCI6IjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMCIsIlVzZXJuYW1lIjoiemhhc2hrZXZ5Y2giLCJQYXNzd29yZCI6IjQyODYwMTc5ZmFiMTQ2YzZiZDAyNjlkMDViZTM0ZWNmYmY5Zjk3YjUifX0.3dsyKJQ-HZJxdvBMui0Mzgw6yb6If9aB8imGhxMOjsk"
}
Delete current user
{
"delete":"ok"
}
{
"response": "delete success"
}
Upload new photo
Request Headers:
Content-Type: multipart/form-data; "boundary=--------------------------867303760029570575153177"
Request Body:
photo: undefined
{
"id": "20072ab149d6c20d96f73bffd4bf1628fc427de1"
}
Returns info about photo by id
GET /api/photogramm/getphoto/20c9f0501316ae4a8b130b0874a828d34f0e0252
{
"photo_id": "20c9f0501316ae4a8b130b0874a828d34f0e0252",
"username": "user5",
"user_id": 20,
"album_name": "summer"
}
Remove photo by id
{
"id":"20c9f0501316ae4a8b130b0874a828d34f0e0252"
}
{
"response": "delete success"
}
Creates new photo album
{
"name":"my new album"
}
{
"response": "success"
}
Returns info about album by name
{
"name":"summer"
}
{
"album_name": "summer",
"photos": [
"0aba003e44f59d2bf550edb65ce5f8483eb0947e",
"20c9f0501316ae4a8b130b0874a828d34f0e0252",
"c832e3a20d1d4454c7539ef27fb0c2f81a27c0ca",
"cb4d0853d31bbea86e9fa17b40033f368104ce09"
],
"total": 4
}
Remove album and photos belong to it
{
"name":"my new album"
}
{
"response": "success"
}
Returns info about all users albums and photos
{
"id": 20,
"username": "user5",
"photo_albums": [
{
"album_name": "",
"photos": [
"41988035482768c411b75c83601946299ca1debf",
"5afa7809707e20de224e1acb643f8b7fd70accb3",
"5f90318c1c23d18bceacb1c15a24feeb9ae48162"
],
"total": 3
},
{
"album_name": "summer",
"photos": [
"0aba003e44f59d2bf550edb65ce5f8483eb0947e",
"20c9f0501316ae4a8b130b0874a828d34f0e0252",
"c832e3a20d1d4454c7539ef27fb0c2f81a27c0ca",
"cb4d0853d31bbea86e9fa17b40033f368104ce09"
],
"total": 4
}
]
}
- go 1.19
- docker & docker-compose