Blame
|
1 | # Pocket Change Showdown: The Penny-Pincher's Paradise |
||||||
|
2 | |||||||
|
3 | > Feck yeah! It's time to tackle your moving expenses with a dash of style and a whole lot of sass! π° |
||||||
|
4 | |||||||
| 5 | <div align="center"> |
|||||||
|
6 | Hey look, there's more Flair than a corporate drone with a Monday morning hangover! |
||||||
|
7 |  |
||||||
|
8 |  |
||||||
| 9 |  |
|||||||
|
10 |  |
||||||
|
11 | <img src="https://teb.codes/2-Code/Flask/Pocket-Change-Showdown/logo.png" alt="logo" width="150"/> |
||||||
|
12 | |||||||
|
13 | Think you're bad at managing expenses? Ah, quit your whining. We've got everything: [sassy Features](#features) β’ super-speed [Quick Start](#quick-start) β’ hassle-free [Installation](#installation) β’ wordy [Documentation](#documentation) β’ places to rant... I mean, [Contributing](#contributing)! |
||||||
|
14 | </div> |
||||||
| 15 | ||||||||
| 16 | --- |
|||||||
| 17 | ||||||||
| 18 | ## π Table of Contents |
|||||||
|
19 | - [What Features?](#features) |
||||||
| 20 | - [Screenshots β Because Who Reads?](#screenshots) |
|||||||
| 21 | - [Quick Start β No, Really, Itβs Quick](#quick-start) |
|||||||
| 22 | - [Slog through Installation](#installation) |
|||||||
| 23 | - [Docker - Walk the Weird Whale](#docker) |
|||||||
| 24 | - [Kubernetes - Because You're Fancy](#kubernetes) |
|||||||
| 25 | - [Local Mayhem - Developer Stuff](#local-development) |
|||||||
| 26 | - [Mess About with Configuration](#configuration) |
|||||||
| 27 | - [Usage - Whatβs the Point?](#usage) |
|||||||
| 28 | - [Guff About API Documentation](#api-documentation) |
|||||||
| 29 | - [What Matters in Development?](#development) |
|||||||
| 30 | - [Contributing - Your Turn to Bitch](#contributing) |
|||||||
| 31 | - [License - Free Stuff's Always Good](#license) |
|||||||
|
32 | |||||||
| 33 | ## β¨ Features |
|||||||
| 34 | ### Core Functionality |
|||||||
|
35 | - πΈ **Receipt Management** - Store craploads of receipts. We dare you. |
||||||
| 36 | - π³ **Multiple Payment Methods** - We track whether you spent cash, credit, IOUs, or favors. |
|||||||
| 37 | - π·οΈ **Smart Categorization** - Keep your spending habits smart and snarky. |
|||||||
| 38 | - π **Analytics Dashboard** - Like looking at a magic crystal ball of shame. |
|||||||
| 39 | - π¨ **8 Color Themes** - Because your expenses can't be as drab as your personality. |
|||||||
| 40 | - π± **Mobile Responsive** - Track on the go, from your phone or hell, a potato. |
|||||||
| 41 | - π **No Login Required** - No strings attached, like that one-night stand. |
|||||||
|
42 | |||||||
| 43 | ### Data Management |
|||||||
|
44 | - π₯ **CSV Import** - Bring the madness of an Excel sheet to a whole new level. |
||||||
| 45 | - π€ **CSV Export** - Send your data on a field trip! |
|||||||
| 46 | - π **Template Download** - Look, Ma! Iβm organized. |
|||||||
| 47 | - πΎ **Persistent Storage** - Data that laughs in the face of restarts. |
|||||||
|
48 | |||||||
| 49 | ### PCS-Specific Categories |
|||||||
| 50 | - π Moving |
|||||||
| 51 | - βοΈ Travel |
|||||||
| 52 | - π Housing |
|||||||
| 53 | - π¦ Storage |
|||||||
| 54 | - π Transportation |
|||||||
| 55 | - π¨ Lodging |
|||||||
| 56 | - π Food |
|||||||
| 57 | - π¦ Supplies |
|||||||
| 58 | - ποΈ Services |
|||||||
|
59 | - β Make up your own crap! |
||||||
|
60 | |||||||
| 61 | ## πΈ Screenshots |
|||||||
| 62 | ||||||||
|
63 | |||||||
|
64 | |||||||
|
65 | ### Sample PDF |
||||||
|
66 | Donβt just stand there, gawk! [pdf_sample.pdf](./pdf_sample.pdf) |
||||||
|
67 | |||||||
|
68 | ## π Quick Start |
||||||
| 69 | ### Docker (Recommended) |
|||||||
| 70 | ```bash |
|||||||
|
71 | # Unleash the Kraken with the latest image |
||||||
|
72 | docker run -d \ |
||||||
| 73 | --name pcs-tracker \ |
|||||||
| 74 | -p 5001:5001 \ |
|||||||
| 75 | -v pcs-data:/app/data \ |
|||||||
| 76 | -v pcs-uploads:/app/uploads \ |
|||||||
| 77 | tebwritescode/pocket-change-showdown:latest |
|||||||
|
78 | # Chuckle maniacally at http://localhost:5001 |
||||||
|
79 | ``` |
||||||
| 80 | ||||||||
| 81 | ### Docker Compose |
|||||||
| 82 | ```bash |
|||||||
|
83 | # Phone-up Chuck Norris: "We're cloning a repo" |
||||||
|
84 | git clone https://github.com/tebwritescode/pocket-change-showdown.git |
||||||
| 85 | cd pocket-change-showdown |
|||||||
|
86 | # Compose your mess with Docker Compose |
||||||
|
87 | docker-compose up -d |
||||||
|
88 | # Dance your way to http://localhost:5001 |
||||||
|
89 | ``` |
||||||
| 90 | ||||||||
| 91 | ## π¦ Installation |
|||||||
| 92 | ### Docker |
|||||||
|
93 | #### Recognizing All Sorts |
||||||
| 94 | Because compatibility is key, unless it isn't! |
|||||||
|
95 | ```bash |
||||||
|
96 | # Pull for your peculiar machine |
||||||
|
97 | docker pull --platform linux/arm64 tebwritescode/pocket-change-showdown:latest |
||||||
|
98 | # Or let Docker rub its chin and decide |
||||||
|
99 | docker pull tebwritescode/pocket-change-showdown:latest |
||||||
| 100 | ``` |
|||||||
| 101 | ||||||||
|
102 | #### Docker Run Degeneracy |
||||||
|
103 | ```bash |
||||||
|
104 | # Deploy it, Captain |
||||||
|
105 | docker run -d \ |
||||||
| 106 | --name pcs-tracker \ |
|||||||
| 107 | -p 5001:5001 \ |
|||||||
| 108 | tebwritescode/pocket-change-showdown:latest |
|||||||
|
109 | # Make it last longer than a baking lesson |
||||||
|
110 | docker run -d \ |
||||||
| 111 | --name pcs-tracker \ |
|||||||
| 112 | -p 5001:5001 \ |
|||||||
| 113 | -v $(pwd)/data:/app/data \ |
|||||||
| 114 | -v $(pwd)/uploads:/app/uploads \ |
|||||||
| 115 | tebwritescode/pocket-change-showdown:latest |
|||||||
|
116 | # Secret sauce for the discerning chef |
||||||
|
117 | docker run -d \ |
||||||
| 118 | --name pcs-tracker \ |
|||||||
| 119 | -p 5001:5001 \ |
|||||||
| 120 | -e SECRET_KEY="your-secret-key-here" \ |
|||||||
| 121 | -e FLASK_ENV="production" \ |
|||||||
| 122 | -v pcs-data:/app/data \ |
|||||||
| 123 | -v pcs-uploads:/app/uploads \ |
|||||||
| 124 | tebwritescode/pocket-change-showdown:latest |
|||||||
| 125 | ``` |
|||||||
| 126 | ||||||||
| 127 | ### Kubernetes |
|||||||
| 128 | ```bash |
|||||||
|
129 | # Manifest your destiny, or just the code |
||||||
|
130 | kubectl apply -f k8s/ |
||||||
|
131 | # Or one by bloody one |
||||||
|
132 | kubectl apply -f k8s/namespace.yaml |
||||||
| 133 | kubectl apply -f k8s/secret.yaml |
|||||||
| 134 | kubectl apply -f k8s/pvc.yaml |
|||||||
| 135 | kubectl apply -f k8s/deployment.yaml |
|||||||
| 136 | kubectl apply -f k8s/service.yaml |
|||||||
|
137 | kubectl apply -f k8s/ingress.yaml # Optional, like an appendix |
||||||
|
138 | |||||||
|
139 | # Check if your stuff's intact |
||||||
|
140 | kubectl get all -n pcs-tracker |
||||||
|
141 | # If it worked, buy yourself a drink at http://<node-ip>:30001 |
||||||
|
142 | ``` |
||||||
| 143 | ||||||||
|
144 | #### Kubernetes Thingamabobs |
||||||
| 145 | - **Persistent Volumes** - Turns out you donβt need to webscrape for dataβit sticks around. |
|||||||
| 146 | - **Health Checks** - It only mostly dies. |
|||||||
| 147 | - **Resource Limits** - So demanding! |
|||||||
| 148 | - **Multi-Service** - Load balance like a tightrope walker. |
|||||||
| 149 | - **Ingress Ready** - Fancy domain? Me too. |
|||||||
|
150 | |||||||
| 151 | ### Local Development |
|||||||
| 152 | ```bash |
|||||||
|
153 | # Kiss the clouds goodbye |
||||||
|
154 | git clone https://github.com/tebwritescode/pocket-change-showdown.git |
||||||
| 155 | cd pocket-change-showdown |
|||||||
|
156 | # Create a virtual haven |
||||||
|
157 | python3 -m venv venv |
||||||
|
158 | source venv/bin/activate |
||||||
| 159 | # Unload a bag of dependencies |
|||||||
|
160 | pip install -r requirements.txt |
||||||
|
161 | # Go-Go-Gadget application |
||||||
|
162 | python app.py |
||||||
|
163 | # Channel your inner regulator at http://localhost:5001 |
||||||
|
164 | ``` |
||||||
| 165 | ||||||||
| 166 | ## βοΈ Configuration |
|||||||
| 167 | ### Environment Variables |
|||||||
| 168 | | Variable | Description | Default | |
|||||||
| 169 | |----------|-------------|---------| |
|||||||
|
170 | | `SECRET_KEY` | SMERSH-level deception sessions key | `pcs-secret-key-2024` | |
||||||
| 171 | | `FLASK_ENV` | Sneaky environment mood | `production` | |
|||||||
| 172 | | `DATABASE_URL` | Alchemize this: your database | `sqlite:///data/pcs_tracker.db` | |
|||||||
| 173 | | `MAX_CONTENT_LENGTH` | Maximum cr-p (content) upload size | `16777216` (16MB) | |
|||||||
|
174 | |||||||
| 175 | ### Data Persistence |
|||||||
|
176 | To make data hang around like a bad smell: |
||||||
| 177 | - `/app/data` - SQLite domicile |
|||||||
| 178 | - `/app/uploads` - Receipts chill as BLOBs |
|||||||
|
179 | |||||||
| 180 | ## π± Usage |
|||||||
|
181 | ### Tossin' Pennies - Adding Expenses |
||||||
| 182 | 1. Sing "Add Expense!" from any rooftop or just click it |
|||||||
| 183 | 2. Wake up from title-only dream |
|||||||
| 184 | 3. Attach facepalming receipts (optional) |
|||||||
| 185 | 4. Ceremoniously hit "Save" |
|||||||
| 186 | ||||||||
| 187 | ### Inflicting Data - Importing |
|||||||
| 188 | 1. Explore **Import/Export** β **Import CSV** |
|||||||
| 189 | 2. Don shiny template armor |
|||||||
| 190 | 3. Be daVinci, fill your masterpiece |
|||||||
| 191 | 4. Blast off with CSV sere-naah-de |
|||||||
| 192 | ||||||||
| 193 | ### Cheese-Cutting Format |
|||||||
|
194 | ```csv |
||||||
| 195 | Date,Title,Description,Category,Cost,Payment Method,Location,Vendor,Notes,Tags |
|||||||
| 196 | 2024-01-15,Moving Truck,U-Haul rental,Moving,299.99,Credit Card,Downtown,U-Haul,26ft truck,moving |
|||||||
| 197 | 2024-01-16,Hotel Stay,Overnight stay,Lodging,125.00,Company Card,Holiday Inn,Holiday Inn,1 night,travel |
|||||||
| 198 | ``` |
|||||||
| 199 | ||||||||
|
200 | ### Manipulating Categories & Payment Methods |
||||||
| 201 | 1. Go where no wo/man has deemed necessary: **Settings** |
|||||||
| 202 | 2. Cust-omize your little heart out |
|||||||
| 203 | 3. Create methods even mad scientists couldnβt |
|||||||
| 204 | 4. Marry whimsy: color themes purr with indulgence |
|||||||
|
205 | |||||||
|
206 | ### Accidental Analytics Dashboard |
||||||
| 207 | - Scorn last week, guilt-trip for next: from nanosecond to year |
|||||||
| 208 | - See-spend scenario via doughnut dive |
|||||||
| 209 | - Payment method squabbles (Bar chart showdown) |
|||||||
| 210 | - Dailies take you on the trend train (Line chart) |
|||||||
| 211 | - Top dog categories, percentages & flaunting aplenty |
|||||||
|
212 | |||||||
|
213 | ## π API Guff |
||||||
|
214 | ### Endpoints |
||||||
|
215 | | Method | Endpoint | Quirky Description | |
||||||
| 216 | |--------|----------|--------------------| |
|||||||
| 217 | | GET | `/` | Home sweet home(wrecker) | |
|||||||
| 218 | | GET | `/expenses` | Expense expedition | |
|||||||
| 219 | | GET/POST | `/expense/new` | New expense enlightenment | |
|||||||
| 220 | | GET/POST | `/expense/<id>/edit` | Edit the unavoidable | |
|||||||
| 221 | | POST | `/expense/<id>/delete` | PURGE! | |
|||||||
| 222 | | GET | `/expense/<id>/receipt` | Picture-perception | |
|||||||
| 223 | | GET | `/dashboard` | Analytical nincompoopery | |
|||||||
| 224 | | GET | `/api/expense_data` | JSON chateria | |
|||||||
| 225 | | GET/POST | `/settings` | Mischief management | |
|||||||
| 226 | | POST | `/settings/category/add` | Go rogue - add category | |
|||||||
| 227 | | POST | `/settings/payment/add` | Payment etiquette upgrade | |
|||||||
| 228 | | GET | `/export` | CSV in Wonderland | |
|||||||
| 229 | | GET/POST | `/import` | CSV Carousel | |
|||||||
| 230 | | GET | `/template` | CSV preface nobility | |
|||||||
| 231 | ||||||||
| 232 | ### API Response Satire |
|||||||
|
233 | ```json |
||||||
| 234 | GET /api/expense_data?period=month |
|||||||
| 235 | { |
|||||||
| 236 | "categories": { |
|||||||
| 237 | "labels": ["Moving", "Travel", "Housing"], |
|||||||
| 238 | "data": [1250.50, 890.25, 2100.00] |
|||||||
| 239 | }, |
|||||||
| 240 | "payment_methods": { |
|||||||
| 241 | "labels": ["Credit Card", "Cash", "Company Card"], |
|||||||
| 242 | "data": [3500.75, 450.00, 290.00] |
|||||||
| 243 | }, |
|||||||
| 244 | "daily_trend": { |
|||||||
| 245 | "labels": ["2024-01-01", "2024-01-02"], |
|||||||
| 246 | "data": [125.50, 340.25] |
|||||||
| 247 | } |
|||||||
| 248 | } |
|||||||
| 249 | ``` |
|||||||
| 250 | ||||||||
|
251 | ## π οΈ Development - Why Bother? |
||||||
|
252 | ### Tech Stack |
||||||
|
253 | - **Backend**: Flask, spicy SQLAlchemy |
||||||
| 254 | - **Frontend**: Bootstrap, Chart.js, Font Awesome (a peacock) |
|||||||
| 255 | - **Database**: SQLite: SQLAlchemy Sings |
|||||||
| 256 | - **File Storage**: Database belly storage |
|||||||
| 257 | - **Deployment**: Orchestrations with Docker, Kubernetes & Gunicorn bravado |
|||||||
|
258 | |||||||
|
259 | ### Structure of Madness |
||||||
|
260 | ``` |
||||||
| 261 | pocket-change-showdown/ |
|||||||
|
262 | βββ app.py # App-worthy babel |
||||||
| 263 | βββ requirements.txt # Dependency lug |
|||||||
| 264 | βββ Dockerfile # Docker concoction |
|||||||
| 265 | βββ docker-compose.yml # Docker squad |
|||||||
| 266 | βββ templates/ # HTML insidiousness |
|||||||
| 267 | β βββ base.html # The totally base |
|||||||
| 268 | β βββ index.html # Page of presents |
|||||||
| 269 | β βββ expenses.html # Expense paradox |
|||||||
| 270 | β βββ expense_form.html # Input vs Reality |
|||||||
| 271 | β βββ dashboard.html # Chase your shame |
|||||||
| 272 | β βββ settings.html # Hangover fixes |
|||||||
| 273 | β βββ import.html # CSV courtship |
|||||||
| 274 | βββ k8s/ # Kubernetes enigma |
|||||||
|
275 | β βββ namespace.yaml |
||||||
| 276 | β βββ secret.yaml |
|||||||
| 277 | β βββ pvc.yaml |
|||||||
| 278 | β βββ deployment.yaml |
|||||||
| 279 | β βββ service.yaml |
|||||||
| 280 | β βββ ingress.yaml |
|||||||
|
281 | βββ data/ # Runtime ingenuity |
||||||
|
282 | ``` |
||||||
| 283 | ||||||||
|
284 | ### Born from Code |
||||||
|
285 | ```bash |
||||||
|
286 | # Glayvin! Build me this Docker monstrosity |
||||||
|
287 | docker build -t pcs-tracker . |
||||||
|
288 | # Partake in fetching multi-arch wonders |
||||||
|
289 | docker buildx build \ |
||||||
| 290 | --platform linux/amd64,linux/arm64,linux/arm/v7 \ |
|||||||
| 291 | -t tebwritescode/pocket-change-showdown:latest \ |
|||||||
| 292 | --push . |
|||||||
| 293 | ``` |
|||||||
| 294 | ||||||||
|
295 | ### The Flat Schema (Non-Skiable) |
||||||
|
296 | ```sql |
||||||
|
297 | -- Ground Zero table for expense |
||||||
|
298 | CREATE TABLE expense ( |
||||||
|
299 | id INTEGER, |
||||||
|
300 | title VARCHAR(200), |
||||||
| 301 | description TEXT, |
|||||||
|
302 | category_id INTEGER, |
||||||
| 303 | cost FLOAT, |
|||||||
| 304 | payment_method_id INTEGER, |
|||||||
|
305 | date DATE, |
||||||
| 306 | receipt_image BLOB, |
|||||||
| 307 | receipt_filename VARCHAR(200), |
|||||||
| 308 | location VARCHAR(200), |
|||||||
| 309 | vendor VARCHAR(200), |
|||||||
| 310 | notes TEXT, |
|||||||
| 311 | tags VARCHAR(500), |
|||||||
| 312 | created_at DATETIME, |
|||||||
|
313 | updated_at DATETIME, |
||||||
| 314 | PRIMARY KEY (id) |
|||||||
|
315 | ); |
||||||
|
316 | -- Column of categorization |
||||||
|
317 | CREATE TABLE category ( |
||||||
|
318 | id INTEGER, |
||||||
| 319 | name VARCHAR(100), |
|||||||
| 320 | color VARCHAR(7), |
|||||||
| 321 | icon VARCHAR(50), |
|||||||
| 322 | is_default BOOLEAN, |
|||||||
| 323 | PRIMARY KEY (id) |
|||||||
|
324 | ); |
||||||
|
325 | -- Noteworthy payment table |
||||||
|
326 | CREATE TABLE payment_method ( |
||||||
|
327 | id INTEGER, |
||||||
| 328 | name VARCHAR(100), |
|||||||
| 329 | icon VARCHAR(50), |
|||||||
| 330 | is_default BOOLEAN, |
|||||||
| 331 | PRIMARY KEY (id) |
|||||||
|
332 | ); |
||||||
|
333 | -- Settings booth |
||||||
|
334 | CREATE TABLE settings ( |
||||||
|
335 | id INTEGER, |
||||||
| 336 | color_scheme VARCHAR(50), |
|||||||
| 337 | default_view VARCHAR(20), |
|||||||
| 338 | PRIMARY KEY (id) |
|||||||
|
339 | ); |
||||||
| 340 | ``` |
|||||||
| 341 | ||||||||
|
342 | ## π License - Go Forth and Conquer! |
||||||
| 343 | This project is merrily open source and blissfully up for grabs under the [MIT License](LICENSE). |
|||||||
|
344 | |||||||
|
345 | ## π Cheers & Acknowledgments |
||||||
| 346 | - Built under the spell of Flask and Bootstrap |
|||||||
| 347 | - Charts magicked by Chart.js |
|||||||
| 348 | - Icons with Font Awesome - Awe as your own |
|||||||
|
349 | |||||||
|
350 | ## π Screech for Help |
||||||
| 351 | For tirades, discontent, or amusing suggestions: |
|||||||
| 352 | - Holler on [GitHub Issues](https://github.com/tebwritescode/pocket-change-showdown/issues) |
|||||||
| 353 | - Vent thoroughly in GitHub Discussions |
|||||||
|
354 | |||||||
| 355 | --- |
|||||||
| 356 | <div align="center"> |
|||||||
|
357 | **P**ocket **C**hange **S**howdown - Because tracking every penny is nothing short of glorious insanity! |
||||||
|
358 | </div> |
||||||