This repository contains a full-stack finance application with a refactored React frontend and Node.js/Express backend.
Finance app with refactored React components
All source code has been organized into a git repository with a clean project structure and comprehensive gitignore configuration.
Finance/
├── .git/ # Git repository
├── .gitignore # Git ignore rules
│
├── Backend (Node.js/Express)
├── app.js # Express server entry point
├── package.json # Backend dependencies
├── bin/www # Server executable
├── routes/ # API routes
│ ├── index.js
│ └── users.js
├── views/ # Server-side views
├── public/ # Static files
├── test-*.js # Test files
└── cors-diagnostic.js # CORS testing
│
└── Frontend (React/Vite)
└── finance-app/
├── .env.local # Environment variables
├── vite.config.js # Vite configuration
├── package.json # Frontend dependencies
├── index.html # HTML entry point
│
└── src/
├── main.jsx # React DOM render
├── App.jsx # Main app component
├── App.css
├── index.css
│
├── Components/ # React components
│ ├── TransactionsTable.jsx # Main container (refactored)
│ ├── TransactionForm.jsx # Form component (NEW)
│ ├── TransactionTableDisplay.jsx # Table display (NEW)
│ ├── ReceiptScanner.jsx # OCR scanner (NEW)
│ ├── Toast.jsx # Notifications (NEW)
│ ├── EnhancedDashboard.jsx
│ ├── Login.jsx
│ ├── Registration.jsx
│ └── ProtectedRoute.jsx
│
├── hooks/ # Custom React hooks (NEW)
│ └── index.js
│ ├── useTransactions() # Transaction management
│ ├── useTransactionForm() # Form state
│ ├── useOCR() # OCR processing
│ └── useToast() # Notifications
│
├── services/ # API layer (NEW)
│ └── transactionService.js
│ ├── Axios interceptors
│ ├── Request: auto-inject token
│ ├── Response: error handling
│ └── Methods: fetch, add, AI advice
│
├── utils/ # Utility functions (NEW)
│ └── transactionUtils.js
│ ├── parseReceiptText()
│ ├── parseTotalAmount()
│ ├── parseReceiptDate()
│ ├── detectStoreAndType()
│ ├── formatDate()
│ └── validateTransaction()
│
├── constants/ # Constants (NEW)
│ └── transactionConstants.js
│ ├── API config & endpoints
│ ├── Categories & types
│ ├── Store patterns (45+ retailers)
│ ├── Regex patterns
│ ├── Keyword categories
│ └── Configuration values
│
└── assets/
└── react.svg
- TransactionsTable.jsx: 1,114 lines (all logic in one component)
- Hard-coded API URLs throughout
- Direct DOM manipulation (
document.createElement()) - Scattered state management
- Duplicate code
- Difficult to test and maintain
TransactionsTable.jsx→ 1 container + 3 presentational componentsTransactionForm.jsx→ Form handlingTransactionTableDisplay.jsx→ Table displayReceiptScanner.jsx→ OCR interfaceToast.jsx→ React-based notifications
- Centralized API calls in
transactionService.js - Axios request/response interceptors
- Automatic token injection
- Global error handling
- Environment-based configuration
useTransactions()→ Fetch & manage transactionsuseTransactionForm()→ Form state & validationuseOCR()→ OCR state managementuseToast()→ Notification system
- Receipt parsing logic extracted to
transactionUtils.js - All hardcoded values moved to
transactionConstants.js - Reusable formatting functions
- Centralized configuration
- Removed
document.createElement()calls - Replaced with React state & components
- Automatic cleanup with
useEffect - No memory leaks
- Node.js - Runtime
- Express.js - Web framework
- PostgreSQL - Database
- AWS Bedrock - AI/ML services
- Tesseract.js - OCR (server-side bundling)
- React 18 - UI framework
- Vite - Build tool
- Tailwind CSS - Styling
- React Router - Navigation
- Axios - HTTP client
- Tesseract.js - OCR processing
git init
git config user.name "JustinCodesByHand"
git config user.email "[email protected]"
git add -A
git commit -m "Initial commit: ..."- Repository: Initialized and clean
- Branch:
master - Latest Commit:
f2cfaab- Initial commit with full refactoring - Files Tracked: 38 files
- Total Changes: 4,252 insertions
git log --oneline # View all commits
git log --stat # See file changes
git log -p # See full diffs
git show <commit-hash> # View specific commit# Make changes
git status # See what changed
git add . # Stage changes
git commit -m "description" # Commit
# Branching
git branch feature-name # Create feature branch
git checkout feature-name # Switch to branch
git merge feature-name # Merge into masterDATABASE_URL=postgresql://user:pass@localhost/finance
JWT_SECRET=your-secret-key
AWS_REGION=us-east-1VITE_API_BASE_URL=http://localhost:5000npm install # Install dependencies
npm start # Production server
npm run dev # Development with nodemon
npm run test-db # Test database connection
npm run test-lambda # Test AWS Lambdacd finance-app
npm install
npm run dev # Start dev server (Vite)
npm run build # Production build
npm run preview # Preview production build| Aspect | Before | After |
|---|---|---|
| Main Component | 1,114 lines | 130 lines + split components |
| Files | 1 monolithic | 8 focused files |
| Reusability | Low | High (hooks, utils, services) |
| Testability | Difficult | Easy (pure functions & hooks) |
| DOM Manipulation | Direct (document.*) |
React-managed |
| API Calls | Scattered | Centralized service |
| Error Handling | Basic | Comprehensive |
| Maintenance | Hard | Easy |
- Set up remote:
git remote add origin <github-url> - Push to GitHub:
git push -u origin master - Create feature branches for new features
- Implement CI/CD (GitHub Actions, etc.)
- Add tests (Jest, React Testing Library)
- Documentation (JSDoc comments, API docs)
(Add your license here)
Developed by: JustinCodesByHand
Email: [email protected]