Skip to content

prashankulathunga/GOLD_PRICE_PREDICT-SYSTEM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gold Market Price Prediction System + Pawning Shop Management System

Project Type Score Frontend Backend ML API Database

Final year university research project that combines gold price forecasting with a complete pawn shop operations platform.

This repository is a full submission archive: application source code, database exports, notebooks, proposal files, analysis sheets, and supporting research materials are all included.


Abstract

This project was designed to solve two connected business problems:

  1. predicting gold market movement from historical price data,
  2. and using those insights inside a real operational system for pawn shop management.

Instead of stopping at a notebook-only forecasting experiment, the research was implemented as a working full-stack platform. The final system integrates:

  • a React + Vite frontend for the user interface,
  • a Node.js + Express backend for business operations and authentication,
  • a Flask prediction API serving a serialized Prophet model,
  • and a MySQL database for customer, pawn item, interest, exchange-rate, cashbook, and chart data.

The result is a hybrid decision-support and transaction-management system where staff can estimate pawn values, issue loans, track active and redeemed items, record interest payments, maintain a cashbook, and visualize actual vs predicted gold prices in one workflow.


Research Objectives

  • Forecast future gold prices from historical daily USD-denominated market data.
  • Convert forecast output into practical valuation support for pawning decisions.
  • Reduce manual errors in customer management, loan issuance, interest tracking, and cashbook operations.
  • Create a single platform that links research intelligence and business execution.

Project Highlights

  • Forecast-driven decision support with 3-month, 6-month, and 12-month gold price prediction views.
  • Full pawn item lifecycle management covering active, redeemed, and expired states.
  • Customer registration and retrieval with JWT-protected operations.
  • Automated interest workflow that updates balances, extends due dates, and records payments.
  • Cashbook tracking for debit and credit transactions.
  • USD/LKR support using exchange-rate synchronization.
  • Actual vs predicted visualization through dashboard charts backed by MySQL.
  • Daily cron automation for expired item updates, FX synchronization, and predicted value insertion.
  • Archive-complete research repo including notebooks, proposal files, Excel analysis, plots, and SQL exports.

System Architecture

flowchart LR
    U[User / Staff] --> F[React + Vite Frontend]
    F -->|JWT-secured REST| N[Node.js + Express API]
    F -->|Prediction requests| P[Flask API + Prophet Model]
    F -->|Market / FX lookups| X[External Gold and Exchange APIs]

    N --> D[(MySQL: pawn_testdb)]
    N --> C[Daily Cron Jobs]

    C -->|mark expired items| D
    C -->|update balances| D
    C -->|store daily prediction| P
    C -->|sync USD/LKR rate| X

    P -->|forecast output| D
    D -->|chart, customer, pawn, interest, cashbook data| F
Loading

Core Functional Modules

1. Gold Price Prediction Layer

  • A dedicated Flask API in FullProject/Python_API loads prophet_model.pkl.
  • The /predict endpoint accepts a target date and returns a forecasted yhat value.
  • The dashboard requests future dates for:
    • 3 months
    • 6 months
    • 12 months
  • Predicted values are also inserted into MySQL by the Node cron workflow for continuity in the operational dataset.

2. Pawning Shop Management Layer

  • User sign-up and login with JWT authentication.
  • Customer creation, lookup, and update workflows.
  • Pawn item creation with:
    • customer linkage,
    • item details,
    • karat/cartage,
    • weight,
    • actual price,
    • loan price,
    • due date generation,
    • and automatic initial cashbook debit.
  • Interest payment recording with balance updates and redemption handling.
  • Dashboard and operational views for monitoring records and trends.

3. Automation Layer

The backend cron process in FullProject/back_end/cornjobs/cornjobs.js performs daily background tasks:

  • marks pawn items as Expired when due dates pass,
  • inserts the latest USD to LKR exchange rate into the database,
  • requests the day forecast from the Flask API and stores it in GoldDataset,
  • updates NeedPayAmount values and related interest balances.

Forecasting and Research Layer

This repository contains both the deployed inference path and the supporting research experiments.

Deployed Model

Historical Dataset Snapshot

Repository-backed notebook and SQL data show:

  • 1,191 daily records
  • date range: 2020-01-01 to 2024-07-31
  • target variable: gold price in USD

The database also contains:

Archived Experiments Included

Evaluation Note

The archived XGBoost notebook records:

  • RMSE: 228.05
  • MAE: 163.85

That notebook is part of the research comparison workflow. The live application, however, is wired to the Prophet model through the Flask API.


End-to-End Business Workflow

  1. A user creates an account and signs in through the web interface.
  2. Customer information is registered or retrieved using a customer ID.
  3. Staff estimate pawn value using live market context, item weight, karat level, and loan period.
  4. A pawn item record is created with an automatically calculated due date and an initial cashbook debit.
  5. Interest payments can be recorded against a pawn item.
  6. The system updates the remaining balance, due date, redemption state, and cashbook credit.
  7. Dashboard views present exchange rates, forecast cards, actual vs predicted charts, and financial activity.
  8. Scheduled backend jobs keep expiration status, exchange-rate data, and predicted price data moving forward daily.

Technology Stack

Layer Implementation
Frontend React 18, Vite, Tailwind CSS, DaisyUI, ApexCharts, Framer Motion
Backend API Node.js, Express, bcrypt, JWT, MySQL2, CORS, body-parser
ML / Forecasting API Flask, pandas, numpy, Prophet, scikit-learn
Database MySQL
Auth JWT Bearer token verification middleware
Automation node-cron
Research Assets Colab/Jupyter notebooks, Python experiments, Excel sheets, PDFs, plots

Database Snapshot

The main domain database is pawn_testdb.

Table Purpose
users application users and authentication-linked identity records
customers pawn shop customer master data
pawnitems pawned item records, status, loan values, due dates, cartage, balances
interest interest payments, balances, and payment history
cashbook operational debit and credit transaction logging
golddataset historical and appended predicted gold prices
predicteddata actual vs predicted series used by charts
usdRate latest USD to LKR exchange-rate storage

Fastest reproducibility options:


Repository Structure

GOLD_PRICE_PREDICT-SYSTEM/
├── README.md
├── FullProject/
│   ├── front_end/                 # React + Vite web application
│   ├── back_end/                  # Node.js + Express business API
│   │   ├── controller/
│   │   ├── route/
│   │   ├── middleware/
│   │   ├── cornjobs/
│   │   └── Dump20250214.sql
│   ├── Python_API/                # Flask prediction API + Prophet model
│   │   ├── main.py
│   │   ├── prophet_model.pkl
│   │   └── requirements.txt
│   ├── Database/                  # Individual MySQL table exports
│   └── ColabNoteBook/             # Research notebooks
├── OtherThings/                   # Proposal docs, analysis files, plots, prototype experiments
│   ├── Project_G/pythonProject/
│   ├── Project Analize Data/
│   └── other_files/

API Surface Overview

Node.js Business API

Method Endpoint Purpose
POST /api/v1/user/signup register user
POST /api/v1/user/login authenticate and issue JWT
GET /api/v1/user/get-user get current authenticated user
POST /api/v1/customer/create-customer create customer
GET /api/v1/customer/find-by-id-customer/:CustomerID fetch customer by ID
PUT /api/v1/customer/update-by-id-customer/:customerId update customer
POST /api/v1/pawn/create-pawn-item create pawn record
GET /api/v1/pawn/get-all-pawn-item list pawn items with customer join
GET /api/v1/pawn/get-pawn-item-by-id/:pawnItemId fetch one pawn item
POST /api/v1/interest/save-interest save interest payment and update balance
GET /api/v1/interest/get-interest list interest records
POST /api/v1/cashbook/create-cashbook add manual cashbook record
GET /api/v1/cashbook/get-all-cashbook list cashbook entries
GET /api/v1/chart/get-chart-data return actual vs predicted chart series
GET /api/v1/exchange/rate return latest USD/LKR rate

Flask Prediction API

Method Endpoint Purpose
POST /predict return Prophet forecast for the requested date

Local Setup and Execution

Prerequisites

  • Node.js and npm
  • Python 3
  • MySQL

1. Create and Import the Database

Create the database:

CREATE DATABASE pawn_testdb;

Then import either the full dump or the individual tables.

Option A: Import the full dump

mysql -u root -p pawn_testdb < FullProject/back_end/Dump20250214.sql

Option B: Import individual table exports

Use the SQL files inside FullProject/Database if you prefer table-by-table restoration.

2. Configure the Node Backend

Create a .env file inside FullProject/back_end:

PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=pawn_testdb
JWT_SECRET=replace_with_a_secure_secret

3. Install and Run the Prediction API

cd FullProject/Python_API
pip install -r requirements.txt
python main.py

Default runtime:

  • Flask API: http://127.0.0.1:5000

4. Install and Run the Node Business API

cd FullProject/back_end
npm install
npm run dev

Expected runtime:

  • Node API: http://localhost:3000

Keep this process running if you want the built-in daily cron automation to execute.

5. Install and Run the Frontend

cd FullProject/front_end
npm install
npm run dev

Default Vite runtime:

  • Frontend: http://localhost:5173

Important Runtime Note

The current frontend is hardwired to:

  • http://localhost:3000/api/v1/ for the Node backend
  • http://127.0.0.1:5000/predict for the Flask forecasting API

So for the project to run without refactoring, keep:

  • Node on port 3000
  • Flask on port 5000

If you change ports or hosts, update:


Included Research Resources

This repository contains more than just runtime code. It includes the wider academic workflow:

  • Colab notebooks for Prophet and XGBoost model experimentation
  • Python prototype scripts for additional forecasting / analytical approaches
  • SQL exports for reproducible database setup
  • Excel and PDF analysis files for research interpretation
  • proposal documents and supporting submission materials
  • plot images and screenshots documenting output and experimentation

That makes this repository suitable not only for source review, but also for:

  • project demonstration,
  • viva / presentation support,
  • academic evidence tracking,
  • and future extension work.

Engineering Notes

This project is strong as a research-backed prototype and academic system integration exercise. It already demonstrates:

  • real model deployment instead of offline-only analysis,
  • business process automation,
  • dashboard reporting,
  • and practical database-driven operations.

For production hardening, the main next steps would be:

  • move third-party API keys and service URLs fully into environment variables,
  • centralize all frontend HTTP configuration instead of mixing direct URLs across components,
  • add formal automated tests,
  • refine cron-based financial update rules,
  • and improve error handling and validation around operational finance flows.

Why This Project Stands Out

  • It does not treat prediction as an isolated ML experiment.
  • It embeds forecasting into an actual business workflow.
  • It preserves the complete research trail from proposal to prototype to operational platform.
  • It earned an academic evaluation of 82/100, reflecting both technical implementation and research quality.

Conclusion

The Gold Market Price Prediction System + Pawning Shop Management System is a complete final-year research implementation that bridges machine learning, financial operations, and full-stack software engineering. It demonstrates how predictive analytics can be turned into a usable operational product for real decision-making, not just a standalone experiment.

About

This gold price prediction system is a web app for pawning centers to forecast future gold prices and manage pawned items. Using Facebook Prophet, it predicts prices in USD and LKR for 3, 6, and 12 months. Built with React, Node.js, and Flask, it supports user authentication, interest calculations, expiry tracking, and efficient pawn management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors