How bharatbalajid/streamlit_expense_tracker works
Project type and purpose
• This is a lightweight full-stack web application (“Personal Expense Tracker”) built in Python.
• It uses Streamlit for the UI, MongoDB for data storage, and Plotly for data visualization.
• Purpose: allow users to add, view, analyze, and manage personal expenses, with extra admin controls (bulk delete, CSV export).
File structure
• Top-level files only:
– app.py: entry point that defines the Streamlit front-end, business logic, and DB access.
– requirements.txt: declares dependencies (streamlit, pymongo, plotly, etc.).
– README.md: high-level project description.
• No separate “frontend” or “backend” directories—everything lives in a single monolithic script.
README for additional insights
• Confirms key flows:
– Add Expense (category, friend, amount, notes)
– View Expenses
– Analytics (category/friend breakdown via interactive charts)
– Delete (single/bulk)
– Admin login (extra controls: delete-all, export CSV)
• Technology stack spelled out: Streamlit, MongoDB, Plotly.
Main components
a. Streamlit UI layer
b. Application logic layer (in-app Python functions: validate input, enforce admin auth, invoke DB operations, generate charts)
c. Data access layer (PyMongo client, CRUD operations on MongoDB)
d. MongoDB database (collections: expenses, users/admins)
e. Plotly library (invoked by application logic to render charts in the UI)
f. External CSV export module (could be shown as a utility or service)
Relationships and interactions
• User interacts with Streamlit UI → UI calls application logic functions.
• Application logic → reads/writes to MongoDB via PyMongo.
• Application logic → passes data to Plotly to render charts in the UI.
• Admin login flow → application logic verifies credentials against the users/admins collection in MongoDB.
• CSV export → application logic fetches data, generates a CSV, and streams/downloads back to the user.
Architectural patterns and design principles
• Monolithic architecture (single process handling UI, business, and data logic).
• Layered separation (Presentation → Business Logic → Data Access).
• External service integration (MongoDB as an external NoSQL store; Plotly as embedded charting library).
• Simple role-based access control (user vs. admin flows).