Skip to content

Commit

Permalink
Merge pull request #18 from RECYTHNG/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sawalreverr authored Jun 20, 2024
2 parents 6bbc036 + 3cf5129 commit fb275d2
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 2 deletions.
123 changes: 121 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,122 @@
## RECYTHING - CAPSTONE PROJECT BACKEND
# Recything - Backend

Test
Recything is a mobile platform designed to facilitate recycling education, littering reporting, and gamified achievements for users. The app allows end users to find recycling information, report improper trash disposal, and earn rewards for completing tasks, while a web dashboard enables super admins to manage accounts and access all data.

![dashboard admin](docs/Dashboard%20-%20Website.png)
[( Recything - Web )](https://recything.netlify.app/)

## Features

### User

- Register / Login account
- Edit user detail
- Homepage mobile
- Reporting Littering / Rubbish
- Customer service with an AI
- Article content for an education
- Video content for an education
- Doing task challenge to earn rewards
- About our team
- Achievements detail (leaderboard)

### Superadmin / Admin

- Login Superadmin / Admin
- Dashboard admin
- Manage Admins data (only superadmin)
- Manage Users data
- Manage Reports (approve/reject report from user)
- Manage Articles (add/update/delete)
- Manage Videos (add/update/delete)
- Manage Achievement (update target point for an each badge)
- Manage Custom Data for dataset AI
- Manage Tasks (approving/rejecting task user)

## TechStacks

- [Echo](https://github.com/labstack/echo) (Web Framework Go)
- [Cloudinary](https://github.com/cloudinary/cloudinary-go/) (Cloud storage free)
- [Viper](https://github.com/spf13/viper) (Configuration)
- [Validator](https://github.com/go-playground/validator) (Type validation)
- [JWT](https://github.com/golang-jwt/jwt) (Middleware)
- [OpenAI](https://github.com/sashabaranov/go-openai) (Chat Bot)
- MySQL (SQL)
- [GORM](https://gorm.io/docs/) (ORM)
- AWS EC2 (Deployment)

## API Documentation

[( Swagger API )](https://recything.site/)
![Swagger](docs/Swagger.png)

[( Postman API )](https://www.postman.com/sawalrever23/workspace/capstone/collection/34865902-43aa5087-a7e3-4c4b-89b6-749fafe0a359?action=share&creator=34865902)
![Postman](docs/Postman.png)

## ERD

[( ERD - draw.io )](https://drive.google.com/file/d/1fbE-hpS4z3lMEEUfUAiL2XWvwETfgipp/view)
![ERD](docs/ERD%20Recything.drawio.png)

## Setup

### Manually

1. Rename **config.example.yaml** to **config.yaml**
2. Fill all the field in **config.yaml** with your configuration
3. Make sure you have **GO** version **1.22+** and **MySQL** to run this project
4. Create new database in **MySQL** named **recything_db**
5. Run the program
```bash
go run cmd/api/main.go
```

### Docker

1. Build an image
```bash
docker build -t sawalrever23/recything-be:latest .
```
2. Create new network
```bash
docker network create api-network
```
3. Pull MySQL image (if you don't have one)
```bash
docker pull mysql
```
4. Pull Golang image (if you don't have one)
```bash
docker pull golang
```
5. Run MySQL on port 3306
```bash
docker run -itd --name mysql-service \
--network api-network \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD={your_password} \
-e MYSQL_DATABASE=recything_db \
-v /tmp/mysql-volume:/var/lib/mysql \
mysql:latest
```
6. Run our build
```bash
docker run -itd --name recything-be \
-p 8080:8080 \
--network api-network \
--restart on-failure \
sawalrever23/recything-be:latest
```

### Docker Compose

- Running our compose

```bash
docker compose up -d
```

- Stopping compose
```bash
docker compose down
```
16 changes: 16 additions & 0 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package main

import (
"log"

"github.com/robfig/cron/v3"
"github.com/sawalreverr/recything/config"
"github.com/sawalreverr/recything/internal/database"
"github.com/sawalreverr/recything/internal/server"
"github.com/sawalreverr/recything/internal/task/manage_task/repository"
)

func main() {
Expand Down Expand Up @@ -55,5 +59,17 @@ func main() {

app := server.NewEchoServer(conf, db)

// cronjob for update status task
c := cron.New()

taskRepo := repository.NewManageTaskRepository(db)
c.AddFunc("@daily", func() {
log.Println("Updating task challenge status...")
taskRepo.UpdateTaskChallengeStatus()
})

c.Start()
defer c.Stop()

app.Start()
}
Binary file added docs/Dashboard - Website.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ERD Recything.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Postman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Swagger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/robfig/cron/v3 v3.0.1
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
Expand Down
4 changes: 4 additions & 0 deletions internal/article/usecase/usecase.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package article

import (
"time"

admin "github.com/sawalreverr/recything/internal/admin/repository"
art "github.com/sawalreverr/recything/internal/article"
"github.com/sawalreverr/recything/internal/helper"
Expand Down Expand Up @@ -151,6 +153,8 @@ func (u *articleUsecase) Update(articleID string, article art.ArticleInput) erro
Description: article.Description,
ThumbnailURL: article.ThumbnailURL,
AuthorID: articleFound.AuthorID,
CreatedAt: articleFound.CreatedAt,
UpdatedAt: time.Now(),
}

if err := u.articleRepo.DeleteAllSection(articleID); err != nil {
Expand Down

0 comments on commit fb275d2

Please sign in to comment.