Categorygithub.com/Giafn/goMoneySaveAndManage
repository
0.0.0-20240519093243-457f91722a47
Repository: https://github.com/giafn/gomoneysaveandmanage.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

Management uang gaji dan tabungan

Description

aplikasi api ini rencana nya akan di buat menggunakan go, gorm, postgresql, dan juga jwt

Desain Database

Tabel Users

Menyimpan informasi pengguna aplikasi.

FieldTypeDescription
idINTPrimary key, Auto Increment
nameVARCHAR(100)Nama pengguna
emailVARCHAR(100)Email pengguna
passwordVARCHAR(255)Kata sandi (hashed)
created_atTIMESTAMPWaktu pembuatan akun

Tabel Salaries

Menyimpan informasi gaji bulanan pengguna.

FieldTypeDescription
idINTPrimary key, Auto Increment
user_idINTForeign key ke Users
amountDECIMAL(10,2)Jumlah gaji
monthINTBulan (1-12)
yearINTTahun
created_atTIMESTAMPWaktu pencatatan

Tabel Expenses

Menyimpan informasi pengeluaran bulanan pengguna.

FieldTypeDescription
idINTPrimary key, Auto Increment
user_idINTForeign key ke Users
categoryVARCHAR(100)Kategori pengeluaran
amountDECIMAL(10,2)Jumlah pengeluaran
monthINTBulan (1-12)
yearINTTahun
created_atTIMESTAMPWaktu pencatatan

Tabel Savings

Menyimpan informasi tabungan pengguna dengan target dan estimasi waktu terkumpul.

FieldTypeDescription
idINTPrimary key, Auto Increment
user_idINTForeign key ke Users
target_amountDECIMAL(10,2)Target tabungan
current_amountDECIMAL(10,2)Jumlah tabungan saat ini
start_dateDATETanggal mulai menabung
end_dateDATETanggal estimasi tercapai
created_atTIMESTAMPWaktu pencatatan

Tabel SavingsHistory

Menyimpan informasi histori menabung pengguna.

FieldTypeDescription
idINTPrimary key, Auto Increment
saving_idINTForeign key ke Savings
user_idINTForeign key ke Users
amountDECIMAL(10,2)Jumlah yang ditabung
dateDATETanggal menabung
created_atTIMESTAMPWaktu pencatatan

Endpoint REST API

1. Users

a. Register User

  • Endpoint: POST /api/users/register
  • Description: Mendaftarkan pengguna baru.
  • Request Body:
    {
      "name": "John Doe",
      "email": "[email protected]",
      "password": "password123"
    }
    
  • Response:
    {
      "message": "User registered successfully",
      "user_id": 1
    }
    

b. Login User

  • Endpoint: POST /api/users/login
  • Description: Masuk sebagai pengguna.
  • Request Body:
    {
      "email": "[email protected]",
      "password": "password123"
    }
    
  • Response:
    {
      "message": "Login successful",
      "token": "jwt-token"
    }
    

2. Salaries

a. Add Salary

  • Endpoint: POST /api/salaries
  • Description: Menambahkan gaji bulanan.
  • Request Header: Authorization: Bearer <token>
  • Request Body:
    {
      "amount": 5000000,
      "month": 5,
      "year": 2024
    }
    
  • Response:
    {
      "message": "Salary added successfully",
      "salary_id": 1
    }
    

b. Get Salaries

  • Endpoint: GET /api/salaries
  • Description: Mendapatkan daftar gaji pengguna.
  • Request Header: Authorization: Bearer <token>
  • Response:
    [
      {
        "salary_id": 1,
        "amount": 5000000,
        "month": 5,
        "year": 2024
      },
      ...
    ]
    

3. Expenses

a. Add Expense

  • Endpoint: POST /api/expenses
  • Description: Menambahkan pengeluaran bulanan.
  • Request Header: Authorization: Bearer <token>
  • Request Body:
    {
      "category": "Makanan",
      "amount": 2000000,
      "month": 5,
      "year": 2024
    }
    
  • Response:
    {
      "message": "Expense added successfully",
      "expense_id": 1
    }
    

b. Get Expenses

  • Endpoint: GET /api/expenses
  • Description: Mendapatkan daftar pengeluaran pengguna.
  • Request Header: Authorization: Bearer <token>
  • Response:
    [
      {
        "expense_id": 1,
        "category": "Makanan",
        "amount": 2000000,
        "month": 5,
        "year": 2024
      },
      ...
    ]
    

4. Savings

a. Add New Savings Target

  • Endpoint: POST /api/savings
  • Description: Menambahkan target tabungan.
  • Request Header: Authorization: Bearer <token>
  • Request Body:
    {
      "target_amount": 10000000,
      "start_date": "2024-05-01"
    }
    
  • Response:
    {
      "message": "Savings target added successfully",
      "saving_id": 1
    }
    

b. Get Savings

  • Endpoint: GET /api/savings
  • Description: Mendapatkan daftar target tabungan pengguna.
  • Request Header: Authorization: Bearer <token>
  • Response:
    [
      {
        "saving_id": 1,
        "target_amount": 10000000,
        "current_amount": 0,
        "start_date": "2024-05-01",
        "end_date": null
      },
      ...
    ]
    

5. SavingsHistory

a. Save

  • Endpoint: POST /api/savings/save
  • Description: Menambahkan nominal menabung.
  • Request Header: Authorization: Bearer <token>
  • Request Body:
    {
      "saving_id": 1,
      "amount": 500000,
      "date": "2024-05-10"
    }
    
  • Response:
    {
      "message": "Savings history added successfully",
      "history_id": 1
    }
    

b. Get Savings History

  • Endpoint: GET /api/savings/history
  • Description: Mendapatkan daftar histori menabung pengguna.
  • Request Header: Authorization: Bearer <token>
  • Response:
    [
      {
        "history_id": 1,
        "saving_id": 1,
        "amount": 500000,
        "date": "2024-05-10"
      },
      ...
    ]