From a309ec25e2602a4bc3e84bb1c956b6188198c59a Mon Sep 17 00:00:00 2001 From: lokeshramchand-ctrl Date: Sun, 29 Jun 2025 23:39:16 +0530 Subject: [PATCH] Next: All transactions --- Backend/config/allowedOrigin.js | 11 ----- Backend/config/db.js | 36 ---------------- Backend/index.js | 2 +- Backend/models/transcation.js | 13 ------ Backend/{routes => }/predict.js | 0 Backend/routes/transaction_route.js | 66 ----------------------------- Frontend/monarch/lib/homepage.dart | 2 +- 7 files changed, 2 insertions(+), 128 deletions(-) delete mode 100644 Backend/config/allowedOrigin.js delete mode 100644 Backend/config/db.js delete mode 100644 Backend/models/transcation.js rename Backend/{routes => }/predict.js (100%) delete mode 100644 Backend/routes/transaction_route.js diff --git a/Backend/config/allowedOrigin.js b/Backend/config/allowedOrigin.js deleted file mode 100644 index 9271fa6..0000000 --- a/Backend/config/allowedOrigin.js +++ /dev/null @@ -1,11 +0,0 @@ -const allowedOrigins = [ - 'http://localhost:5000', - 'https://192.168.1.102', - 'https://10.231.7.128', - 'https://192.168.1.100', - 'https://192.168.1.9', - - -] - -module.exports = allowedOrigins diff --git a/Backend/config/db.js b/Backend/config/db.js deleted file mode 100644 index acc058e..0000000 --- a/Backend/config/db.js +++ /dev/null @@ -1,36 +0,0 @@ -const mongoose = require("mongoose"); - -const connectDB = async () => { - try { - const conn = await mongoose.connect(process.env.MONGO_URI, { - useNewUrlParser: true, - useUnifiedTopology: true, - }); - - mongoose.set("strictQuery", false); - mongoose.set("toJSON", { - virtuals: true, - versionKey: false, - transform: (doc, ret) => { - delete ret._id; - return ret; - }, - }); - mongoose.set("toObject", { - virtuals: true, - versionKey: false, - transform: (doc, ret) => { - delete ret._id; - return ret; - }, - }); - mongoose.set("runValidators", true); - - console.log(`✅ MongoDB Connected: ${conn.connection.host}`); - } catch (error) { - console.error(`❌ Error: ${error.message}`); - process.exit(1); - } -}; - -module.exports = connectDB; diff --git a/Backend/index.js b/Backend/index.js index d0de40c..9ea2f35 100644 --- a/Backend/index.js +++ b/Backend/index.js @@ -7,7 +7,7 @@ const app = express(); app.use(express.json()); // to parse JSON // Prediction route -const predictRoute = require('./routes/predict'); +const predictRoute = require('./predict'); app.use('/api/predict', predictRoute); // MongoDB connection diff --git a/Backend/models/transcation.js b/Backend/models/transcation.js deleted file mode 100644 index 5d26088..0000000 --- a/Backend/models/transcation.js +++ /dev/null @@ -1,13 +0,0 @@ -// models/transaction.js -const mongoose = require('mongoose'); - -const transactionSchema = new mongoose.Schema({ - description: String, - amount: Number, - category: String, - date: { type: Date, default: Date.now }, -}); - -const Transaction = mongoose.model('Transaction', transactionSchema); - -module.exports = Transaction; diff --git a/Backend/routes/predict.js b/Backend/predict.js similarity index 100% rename from Backend/routes/predict.js rename to Backend/predict.js diff --git a/Backend/routes/transaction_route.js b/Backend/routes/transaction_route.js deleted file mode 100644 index b1546eb..0000000 --- a/Backend/routes/transaction_route.js +++ /dev/null @@ -1,66 +0,0 @@ -// routes/transactionroutes.js - -const express = require('express'); -const router = express.Router(); -const axios = require('axios'); -const Transaction = require('./models/transaction'); // ✅ lowercase filename - -// Add transaction -router.post('/add', async (req, res) => { - try { - const { description, amount } = req.body; - const predictRes = await axios.post('http://192.168.1.9:5000/api/predict', { description }); - const category = predictRes.data.category || 'Other'; - - const newTransaction = new Transaction({ description, amount, category }); - await newTransaction.save(); - - res.status(200).json({ - message: '✅ Transaction saved with category', - data: newTransaction, - }); - } catch (err) { - console.error('❌ Error adding transaction:', err.message); - res.status(500).json({ error: err.message }); - } -}); - -// Update budget -router.post('/update', async (req, res) => { - try { - const { budget } = req.body; - await BudgetModel.updateOne({}, { amount: budget }, { upsert: true }); - res.status(200).json({ success: true }); - } catch (error) { - res.status(500).json({ error: 'Failed to update budget' }); - } -}); - -// Get transactions -router.get('/', async (req, res) => { - try { - const category = req.query.category; - let query = {}; - - if (category && category !== 'All') { - query.category = category; - } - - const transactions = await Transaction.find(query).sort({ date: -1 }); - - res.status(200).json({ - success: true, - data: transactions.map(tx => ({ - id: tx._id, - description: tx.description, - amount: tx.amount, - category: tx.category, - date: tx.date, - })), - }); - } catch (err) { - res.status(500).json({ error: err.message }); - } -}); - -module.exports = router; diff --git a/Frontend/monarch/lib/homepage.dart b/Frontend/monarch/lib/homepage.dart index 8526f59..0f29647 100644 --- a/Frontend/monarch/lib/homepage.dart +++ b/Frontend/monarch/lib/homepage.dart @@ -622,7 +622,7 @@ class _FinTrackHomePageState extends State primaryColor: primaryColor, cardColor: cardColor, - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButtonLocation: FloatingActionButtonLocation.centerTop, ), ); }