Skip to content

TalksUp backend API - A podcast recommendation project based on user likes

Notifications You must be signed in to change notification settings

sebasvil20/TalksUpAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TalksUp API

forthebadge made-with-go digital ocean postgresql

GoDoc reference example MIT license

Made with ♥️ by @Sebasvil20 and @Santisepulveda90

This is the backend API to TalksUp project, a podcast recommendations based on user likes

Main features

  • RESTful API
  • API Key required, otherwise API cannot be consumed
  • Dependency Injection
  • Standard CRUD operations on database tables
  • JWT-based authentication
  • Environment dependent application configuration management

Getting Started

If this is your first time encountering Go, please follow the instructions to install Go on your computer. The API requires Go 1.14 or above.

After installing Go, run the following commands to start experiencing with the API:

# download the TalksUp API
git clone git@github.com:sebasvil20/TalksUpAPI.git

cd TalksUpAPI

# Install dependencies
go mod tidy

# start a PostgreSQL database server
brew services start postgresql

# Create database
createdb talksup

# run migrations script from migrations/talksup.sql

# Run API
SCOPE=DEV
go build src/api/main.go

At this time, you have a RESTful API server running at http://127.0.0.1:8080. It provides the following endpoints:

Utils

Method Endpoint Description
GET /health Healthcheck service provided for health checking purpose
PUT /upload Requires a form-data content type with a file on it. Uploads an image and returns the cdn url

Auth

Method Endpoint Description
GET /auth/login Login with user credentials to receive jwt token
GET /auth/validate Validates the given jwt (passed by headers)

Users

Method Endpoint Description
GET /users Get all users with their likes *
GET /users/:user_id/reviews Get all reviews by user id
POST /users Create new user
PUT /users Updates given user
POST /users/associate Associate user with a list of categories (likes)

Categories

Method Endpoint Description
GET /categories?lang= Get all categories, optional lang query param e.g. ESP
GET /categories Get all users with their likes *
POST /categories Create new category *

Authors

Method Endpoint Description
GET /authors Get all authors
GET /authors/:authod_id Get author by id. Returns author info and its podcasts
POST /authors Create new author *
DELETE /authors/:id Delete author *

Podcasts

Method Endpoint Description
GET /podcasts?category_id=&lang= Get all podcasts with fully info (categories, author, lang, platforms)
GET /podcasts/:podcast_id/reviews Get all reviews by podcast id
POST /podcasts Create new podcast *
POST /podcasts/associate Associate podcast with a list of categories

Lists

Method Endpoint Description
GET /lists Get all podcast list
GET /lists/:id Get detailed podcast list
POST /lists Create new list
POST /lists/associate Associate a slice of podcasts with a list
POST /lists/like Likes a list
DELETE /lists/:id Delete a list

Reviews

Method Endpoint Description
POST /reviews Create review for a podcast
DELETE /reviews/:id Delete an owned review

(*) Admin role required

(**) Admin role not required but admin approval required

Try the URL http://localhost:8080/health in a browser, and you should see something like "PONG" displayed.

Project Layout

The TalksUpAPI uses the following project layout:

.
├── migrations                   SQL Files with db struct
├── src                 
│    └── api                     main applications of the project
│        └── app                 dependency injection providers and router handler
│        └── config              configurations and global vars
│        └── controllers         first cape of API where the request is received
│        └── models              all API structs
│        └── repository          access to database data
│        └── service             all business logic
│        └── utils               several util funcs
│              └── middleware    middleware funcs to handle api keys and auth
│              └── auth          jwt related funcs (Generate and validate)
└── 

The top level directories src, internal, pkg are commonly found in other popular Go projects, as explained in Standard Go Project Layout.

Within each feature package, code are organized in layers (API, service, repository), following the dependency guidelines as described in the clean architecture.

Deployment

Open a Pull Request to main branch, if all checks of CI pass and you merge the branch, the CD'll start running and the app will be automatically updated

About

TalksUp backend API - A podcast recommendation project based on user likes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published