Introduction

Introduction ▶️

Cada goods search engine is a service which provides a platform for managing all the goods in Cada™ infrastructure.

⚠️ Warning: Application is in beta test.

Table of content

  • Good
  • Category

Technologies

1Search Engine: Go 
2    -Source: https://go.dev
3Database Manager: Go
4    - Source: https://go.dev
5Database: MongoDB
6    - Source: https://mongodb.com
7Documentation: Docuowl
8    - Source: https://github.com/docuowl/docuowl

Good

Good

Good as a object is as the name hence, a service for goods and managing.

Structure

1type Good struct {
2	Id         primitive.ObjectID `bson:"_id"`
3	CategoryId primitive.ObjectID             
4	Name       map[primitive.ObjectID]string  
5	Properties map[string]interface{}         
6	CreatedAt  time.Time                      
7	UpdatedAt  time.Time                      
8	IsActive   bool                           
9}

Functions

1type IGoodRepository interface {
2    CreateGood(good Good) (*Good, error)
3    GetGood(filters interface{}, findOptions *options.FindOneOptions) (*Good, error)
4    GetGoods(filters interface{}, o *options.FindOptions) ([]*Good, error)
5    UpdateGood(good *Good) (*Good, error)
6    VirtualRemoveGood(filter interface{}) (*Good, error)
7    RemoveGood(filter interface{}) error
8}

Category

Category

Category is a module which provides a establishment for defining categories in all the solution.

This helps the user to find goods in a better approach and also specifying categories which will be shown like a binary tree to the user.

Structure

1type Category struct {
2	Id             primitive.ObjectID `bson:"_id"`
3	ParentCategory primitive.ObjectID
4    Names          map[string]string              
5	CreatedAt      time.Time                      
6	UpdatedAt      time.Time                      
7	IsActive       bool                           
8}

Functions

1type ICategoryRepository interface {
2    CreateCategory(category *Category) (*Category, error)
3    GetCategory(filters interface{}, findOptions *options.FindOneOptions) (*Category, error)
4    GetCategories(filters interface{}, options *options.FindOptions) ([]*Category, error)
5    UpdateCategory(category *Category) (*Category, error)
6    RemoveCategory(filters interface{}) error
7}

Language

Language

Language specifies the system language which will be used in this system widely, when inserted a text in this system, the text will have a language which needs to be specified so the user can determine the needed actions for being done.

Structure

 1type SystemLanguage struct {
 2    Id          primitive.ObjectID `bson:"_id"`
 3    Name        string
 4    Description string
 5    Country     string
 6    Code        string
 7    CreatedAt   time.Time
 8    UpdatedAt   time.Time
 9    IsActive    bool
10}

Functions

1type ILanguageRepository interface {
2	CreateLanguage(language SystemLanguage) (*SystemLanguage, error)
3	GetLanguage(id string) (*SystemLanguage, error)
4	GetLanguages(filters interface{}, o *options.FindOptions) ([]*SystemLanguage, error)
5	UpdateLanguage(language *SystemLanguage) (*SystemLanguage, error)
6	RemovePermanentLanguage(id string) error
7	RemoveIsActive(id string) error
8}

RESTful API

RESTful API

Authentication and authorization

For authentication and authorization we use JWT (Json Web Token)

Category API

Category API

  • POST "/category/CreateCategory" cc.CreateCategory

Request

1type CreateCategoryRequest struct {
2	// Parent Category id
3	ParentCategory string
4	// Language Code - Name
5	Names          map[string]string
6}

Response

1type Category struct {
2	Id             primitive.ObjectID `bson:"_id"`
3	ParentCategory primitive.ObjectID
4	Names          map[primitive.ObjectID]string
5	CreatedAt      time.Time
6	UpdatedAt      time.Time
7	IsActive       bool
8}
  • GET "/category/GetCategory" cc.GetCategory

Request

1type GetCategoryRequest struct {
2	Id             string
3	ParentCategory string
4	Names          []string
5	IsActive       bool
6}
7

Response

1type Category struct {
2	Id             primitive.ObjectID `bson:"_id"`
3	ParentCategory primitive.ObjectID
4	Names          map[primitive.ObjectID]string
5	CreatedAt      time.Time
6	UpdatedAt      time.Time
7	IsActive       bool
8}
  • GET "/category/GetCategories" cc.GetCategories

Request

1type GetCategoriesRequest struct {
2	Id             string
3	ParentCategory string
4	Names          []string
5	IsActive       bool
6}

Response

List of Category

1type Category struct {
2    Id             primitive.ObjectID `bson:"_id"`
3    ParentCategory primitive.ObjectID
4    Names          map[primitive.ObjectID]string
5    CreatedAt      time.Time
6    UpdatedAt      time.Time
7    IsActive       bool
8}
  • GET "/category/GetAllSubCategories" cc.GetAllSubCategories

Request

1type GetCategorySubCategoriesRequest struct {
2	Id string
3}

Response

List of Category

1type Category struct {
2    Id             primitive.ObjectID `bson:"_id"`
3    ParentCategory primitive.ObjectID
4    Names          map[primitive.ObjectID]string
5    CreatedAt      time.Time
6    UpdatedAt      time.Time
7    IsActive       bool
8}
  • PUT "/category/UpdateCategory" cc.UpdateCategory

Request

1type UpdateCategoryRequest struct {
2	Id             string
3	ParentCategory string
4	Names          map[string]string
5}
6

Response

1type Category struct {
2	Id             primitive.ObjectID `bson:"_id"`
3	ParentCategory primitive.ObjectID
4	Names          map[primitive.ObjectID]string
5	CreatedAt      time.Time
6	UpdatedAt      time.Time
7	IsActive       bool
8}
9
  • DELETE "/category/VirtualDeletion" cc.VirtualRemoveCategory

Request

1type VirtualDeletionCategoryRequest struct {
2	Id string
3}

Response

1type Category struct {
2	Id             primitive.ObjectID `bson:"_id"`
3	ParentCategory primitive.ObjectID
4	Names          map[primitive.ObjectID]string
5	CreatedAt      time.Time
6	UpdatedAt      time.Time
7	IsActive       bool
8}
9
  • DELETE "/category/DeleteCategory", cc.RemoveCategory

Request

1type RemoveCategoryRequest struct {
2	Id string
3}

Response HTTP OK - Object has been removed successfully

Good API

Good API

  • POST("/good/CreateGood", gc.CreateGood)

Request

1type CreateGoodRequest struct {
2	Name       map[string]string
3	Properties map[string]interface{}
4}

Response

1type Good struct {
2	Id         primitive.ObjectID `bson:"_id"`
3	CategoryId primitive.ObjectID
4	Name       map[primitive.ObjectID]string
5	Properties map[string]interface{}
6	CreatedAt  time.Time
7	UpdatedAt  time.Time
8	IsActive   bool
9}
  • GET("/good/GetGood", gc.GetGood)

Request

1type GetGoodRequest struct {
2	Id         string
3	CategoryId string
4	Name       map[string]string
5	Properties map[string]interface{}
6	IsActive   bool
7}

Response

1type Good struct {
2	Id         primitive.ObjectID `bson:"_id"`
3	CategoryId primitive.ObjectID
4	Name       map[primitive.ObjectID]string
5	Properties map[string]interface{}
6	CreatedAt  time.Time
7	UpdatedAt  time.Time
8	IsActive   bool
9}
  • GET("/good/GetGoods", gc.GetGoods)

Request

1type GetGoodsRequest struct {
2	CategoryId string
3	Name       map[string]string
4	Properties map[string]interface{}
5	IsActive   bool
6}

Response

List of Good

1type Good struct {
2	Id         primitive.ObjectID `bson:"_id"`
3	CategoryId primitive.ObjectID
4	Name       map[primitive.ObjectID]string
5	Properties map[string]interface{}
6	CreatedAt  time.Time
7	UpdatedAt  time.Time
8	IsActive   bool
9}
  • PUT("/good/UpdateGood", gc.UpdateGood)

Request

1type UpdateGoodRequest struct {
2	Id         string
3	CategoryId string
4	Name       map[string]string
5	Properties map[string]interface{}
6}

Response

1type Good struct {
2	Id         primitive.ObjectID `bson:"_id"`
3	CategoryId primitive.ObjectID
4	Name       map[primitive.ObjectID]string
5	Properties map[string]interface{}
6	CreatedAt  time.Time
7	UpdatedAt  time.Time
8	IsActive   bool
9}
  • DELETE("/good/VirtualDeletion", gc.VirtualRemoveGood)

Request

1type VirtualRemoveGoodRequest struct {
2	Id string
3}

Response

HTTP OK - Virtual deletion was a success

  • DELETE("/good/Deletion", gc.RemoveGood)

Request

1type RemoveGoodRequest struct {
2	Id string
3}

Response

HTTP OK - Deletion was a success

User API

User Api

  • POST(“/user/SignUp”, uc.SignUp)

Request

1type UserSignUpRequest struct {
2	Email    string
3	Password string
4}

Response

HTTP OK - Sign up was successful

  • POST(“/user/SignIn”, uc.SignIn)

Reqeust

1type UserSignInRequest struct {
2	Email    string
3	Password string
4}

Response

HTTP OK - JWTTOKEN

  • POST("/user/ResendEmailConfirmationToken", uc.ReSendEmailConfirmation)
  • Request go type UserResendEmailConfirmationRequest struct { Email string } Response

HTTP OK - Email confirmation token has been resent

  • POST("/user/ForgetPassword", uc.ForgetPassword)

Request

1type UserForgetPasswordRequest struct {
2	Email string
3}

Response

HTTP OK - Your password recovery email has been sent

  • POST("/user/VerifyForgetPassword", uc.VerifyForgetPassword)

Request

1type UserVerifyForgetPasswordRequest struct {
2	Token    string
3	Email    string
4	Password string
5}

Response HTTP Accepted - Password has changed

  • POST("/user/VerifyEmail", uc.VerifyEmail)

Request

1type UserEmailConfirmationRequest struct {
2	ConfirmationToken string
3}

Response HTTP OK - Email has confirmed.

  • POST("/user/InsertUser", uc.InsertUser)

Request

 1type CreateUserRequest struct {
 2	Email             string
 3	Password          string
 4	AvatarId          string
 5	Roles             []string
 6	EmailConfirmation bool
 7	FirstName         string
 8	LastName          string
 9	KycVerified       bool
10}

Response

 1type User struct {
 2	Id                primitive.ObjectID `json:"_id" bson:"_id"`
 3	AvatarId          string
 4	Roles             []string
 5	IsActive          bool
 6	Email             string
 7	Password          string
 8	EmailConfirmation bool
 9	FirstName         string
10	LastName          string
11	KycVerified       bool
12	TotpSecret        string
13	CreatedAt         int64
14	UpdatedAt         int64
15}
  • GET("/user/GetUser", uc.GetUser)

Request

1type GetUserRequest struct {
2	Id string
3}

Response

 1type User struct {
 2	Id                primitive.ObjectID `json:"_id" bson:"_id"`
 3	AvatarId          string
 4	Roles             []string
 5	IsActive          bool
 6	Email             string
 7	Password          string
 8	EmailConfirmation bool
 9	FirstName         string
10	LastName          string
11	KycVerified       bool
12	TotpSecret        string
13	CreatedAt         int64
14	UpdatedAt         int64
15}
  • GET("/user/GetUsers", uc.GetUsers)

Request

1type GetUsersRequest struct {
2	Skip  int64
3	Limit int64
4}

Response List of User

 1type User struct {
 2	Id                primitive.ObjectID `json:"_id" bson:"_id"`
 3	AvatarId          string
 4	Roles             []string
 5	IsActive          bool
 6	Email             string
 7	Password          string
 8	EmailConfirmation bool
 9	FirstName         string
10	LastName          string
11	KycVerified       bool
12	TotpSecret        string
13	CreatedAt         int64
14	UpdatedAt         int64
15}
  • GET("/user/GetUserByRole", uc.GetUserByRole)

Request

1type GetUsersByRole struct {
2	Skip  int64
3	Limit int64
4	Role  string
5}

Response List of User

 1type User struct {
 2	Id                primitive.ObjectID `json:"_id" bson:"_id"`
 3	AvatarId          string
 4	Roles             []string
 5	IsActive          bool
 6	Email             string
 7	Password          string
 8	EmailConfirmation bool
 9	FirstName         string
10	LastName          string
11	KycVerified       bool
12	TotpSecret        string
13	CreatedAt         int64
14	UpdatedAt         int64
15}
  • PUT("/user/UpdateUser", uc.UpdateUser)

Request

 1type UpdateUserRequest struct {
 2	Id                string
 3	AvatarId          string
 4	Roles             []string
 5	IsActive          bool
 6	Email             string
 7	Password          string
 8	EmailConfirmation bool
 9	FirstName         string
10	LastName          string
11	KycVerified       bool
12}

Response

 1type User struct {
 2	Id                primitive.ObjectID `json:"_id" bson:"_id"`
 3	AvatarId          string
 4	Roles             []string
 5	IsActive          bool
 6	Email             string
 7	Password          string
 8	EmailConfirmation bool
 9	FirstName         string
10	LastName          string
11	KycVerified       bool
12	TotpSecret        string
13	CreatedAt         int64
14	UpdatedAt         int64
15}