Skip to content

finance tracker app #588

Open
Open

Description

@nishva2610patel-wq

import streamlit as st
import pandas as pd
import plotly.express as px
import os
from datetime import datetime

--- 1. THEME & PAGE SETUP (Lavender + White) ---

st.set_page_config(page_title="Lavender Ledger", layout="wide")
st.markdown("""

<style> /* Background White, accents in Lavender */ .stApp { background-color: #F8F8FF; } h1, h2, h3, p, div { color: #4B0082; } /* Buttons in Lavender */ .stButton>button { background-color: #E6E6FA; color: #4B0082; border: 2px solid #9370DB; border-radius: 10px; } /* Metric styling */ [data-testid="stMetricValue"] { color: #6A5ACD; } </style>

""", unsafe_allow_html=True)

st.title("💜 Lavender Ledger")

--- 2. DATA LOAD & SAVE SETUP ---

DATA_FILE = "maru_kharchu.csv"

def load_data():
if os.path.exists(DATA_FILE):
return pd.read_csv(DATA_FILE)
else:
return pd.DataFrame(columns=["Date", "Type", "Account", "Category", "Amount", "Description"])

df = load_data()

--- 3. SIDEBAR (Darek Vastu Add Karva Mate) ---

st.sidebar.header("Navi Entry Add Karo")

Categories ane types tamara photo mathi lidhela che

types = ["Income", "Expense", "Transfer", "Transfer (Income)", "Other (Expense)", "Other (Income)"]
accounts = ["Shailesh Account", "Jaymil Account", "Home Account", "Jigna Account BOB", "Nishva Account", "Nishva Account HD"]
categories = [
"Opening Balance", "Salary", "Grocery (Karyanu)", "Dairy Products", "Movie Exp",
"Shopping", "Bank", "Vegetable & Fruits", "Hospital", "Medicine", "Others",
"Nasto", "Pooja Product", "Stationery", "Bank charges", "SIP", "Cloths",
"Hotel exp", "Marriage & Other", "Transport", "Charity", "Society Exp",
"Vehicle Repairing", "Salon"
]

with st.sidebar.form("entry_form"):
date_input = st.date_input("Date", datetime.today())
type_input = st.selectbox("Type", types)
account_input = st.selectbox("Account Name", accounts)
category_input = st.selectbox("Category", categories)
amount_input = st.number_input("Amount (₹)", min_value=0.0, format="%.2f")
desc_input = st.text_input("Description (Vigat)")
submitted = st.form_submit_button("Data Save Karo")

if submitted:
    new_data = pd.DataFrame({
        "Date": [date_input],
        "Type": [type_input],
        "Account": [account_input],
        "Category": [category_input],
        "Amount": [amount_input],
        "Description": [desc_input]
    })
    df = pd.concat([df, new_data], ignore_index=True)
    df.to_csv(DATA_FILE, index=False)
    st.sidebar.success("Tamari entry add thai gai che!")
    st.rerun()

--- 4. AUTO SUM CALCULATION ---

Type hisaab thi total automatically calculate thase

total_income = df[df["Type"] == "Income"]["Amount"].sum()
total_expense = df[df["Type"] == "Expense"]["Amount"].sum()
balance = total_income - total_expense

col1, col2, col3 = st.columns(3)
col1.metric("Total Income", f"₹ {total_income:,.2f}")
col2.metric("Total Expense", f"₹ {total_expense:,.2f}")
col3.metric("Balance", f"₹ {balance:,.2f}")

st.markdown("---")

--- 5. FILTER OPTIONS ---

st.subheader("Data Filter Karo")
col_filt1, col_filt2 = st.columns(2)
with col_filt1:
filter_type = st.multiselect("Type thi Filter karo", types, default=types)
with col_filt2:
filter_acc = st.multiselect("Account thi Filter karo", accounts, default=accounts)

filtered_df = df[df["Type"].isin(filter_type) & df["Account"].isin(filter_acc)]

--- 6. CHARTS (Phota mujab Pie Chart) ---

st.subheader("Kharcha No Pie Chart")
expense_data = filtered_df[filtered_df["Type"] == "Expense"]
if not expense_data.empty:
fig = px.pie(
expense_data,
values="Amount",
names="Category",
color_discrete_sequence=px.colors.qualitative.Pastel
)
fig.update_layout(paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
st.plotly_chart(fig, use_container_width=True)
else:
st.info("Haji koi expense add nathi karyo, chart jova mate expense add karo.")

--- 7. TABLE (Badho Data) ---

st.subheader("Tamaru Badhu Data (Ledger)")
st.dataframe(filtered_df, use_container_width=True, hide_index=True)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions