{"id":32551212,"url":"https://github.com/sprmke/pawn-tracker","last_synced_at":"2026-04-12T03:37:33.335Z","repository":{"id":319489700,"uuid":"1078267419","full_name":"sprmke/pawn-tracker","owner":"sprmke","description":"A web app for managing pawn business loans with multi-investor allocation, interest calculations, and transaction tracking.","archived":false,"fork":false,"pushed_at":"2025-10-26T19:03:59.000Z","size":342,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-26T21:05:31.020Z","etag":null,"topics":["bun","drizzle","neon","nextjs","postgresql","react","shadcn","tailwind","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sprmke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-17T13:16:07.000Z","updated_at":"2025-10-26T19:04:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"52cbb665-1dbd-412e-9537-145cc10a4c73","html_url":"https://github.com/sprmke/pawn-tracker","commit_stats":null,"previous_names":["sprmke/pawn-tracker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sprmke/pawn-tracker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprmke%2Fpawn-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprmke%2Fpawn-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprmke%2Fpawn-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprmke%2Fpawn-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sprmke","download_url":"https://codeload.github.com/sprmke/pawn-tracker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprmke%2Fpawn-tracker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281512680,"owners_count":26514302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","drizzle","neon","nextjs","postgresql","react","shadcn","tailwind","typescript"],"created_at":"2025-10-28T20:59:02.494Z","updated_at":"2026-04-12T03:37:33.322Z","avatar_url":"https://github.com/sprmke.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pawn Business Tracker\n\nA comprehensive web application for tracking pawn business loans and investor transactions, built with Next.js 15, React 19, Tailwind CSS, and shadcn/ui.\n\n## Features\n\n### Google Calendar Integration\n\n- **Automatic calendar event creation** for all loan events:\n  - 📤 **Disbursement events** (sent dates) with investor details\n  - 📅 **Due date events** with principal and interest breakdown\n  - 💰 **Interest due events** for loans with multiple interest periods\n- **Investor notifications**: All investors are automatically added as attendees and receive email notifications\n- **Complete loan information**: Events include detailed loan data, amounts, and investor breakdowns\n- **Automatic synchronization**: Events are created, updated, and deleted automatically with loan changes\n\n### Module 1: Pawn Tracker\n\n- **Create and manage loans** with detailed information:\n\n  - Loan name/label\n  - Type (Lot Title, OR/CR, Agent)\n  - Principal amount\n  - Interest rates (default and per-investor)\n  - Due dates with monthly or total interest options\n  - Status tracking (Active, Done, Overdue)\n  - Free lot tracking (in sqm)\n  - Notes and additional details\n\n- **Multi-investor allocation**:\n\n  - Select multiple investors per loan\n  - Individual amount allocation per investor\n  - Custom interest rates per investor\n  - Multiple sent dates support\n\n- **Real-time preview**:\n  - Calculate capital, interest, and total per investor\n  - Loan summary with total principal, interest, and amount due\n  - Visual breakdown before submission\n\n### Module 2: Investor In \u0026 Outs\n\n- **Investor dashboard** showing:\n\n  - Total capital invested\n  - Total interest earned\n  - Current balance with status indicators\n  - Active and total loans\n\n- **Investor detail page** with two tabs:\n\n  - **Tab 1: Loans \u0026 Gains**\n\n    - All loans joined by the investor\n    - Capital, interest rate, and earnings per loan\n    - Total gains calculation\n\n  - **Tab 2: Transactions \u0026 Balance**\n    - Complete transaction history\n    - Running balance after each transaction\n    - Date, type, amount, and notes\n    - Color-coded balance status (Green: Can invest, Yellow: Low funds, Red: No funds)\n\n### Dashboard\n\n- Overview statistics:\n  - Total principal amount\n  - Total interest earned\n  - Active loans count\n  - Overdue loans alert\n- Recent loans with quick status view\n\n## Tech Stack\n\n- **Framework**: Next.js 15 with App Router\n- **UI Library**: React 19\n- **Styling**: Tailwind CSS\n- **UI Components**: shadcn/ui\n- **Database ORM**: Drizzle ORM\n- **Database**: Neon PostgreSQL (serverless)\n- **Form Handling**: React Hook Form + Zod validation\n- **Type Safety**: TypeScript\n\n## Getting Started\n\n### Prerequisites\n\n- Bun installed ([bun.sh](https://bun.sh))\n- A Neon PostgreSQL database (free tier available at [neon.tech](https://neon.tech))\n\n### Installation\n\n1. Clone the repository:\n\n```bash\ngit clone \u003crepository-url\u003e\ncd pawn-tracker\n```\n\n2. Install dependencies:\n\n```bash\nbun install\n```\n\n3. Set up environment variables:\n\n```bash\ncp .env.example .env.local\n```\n\nEdit `.env.local` and add your Neon database URL:\n\n```env\nDATABASE_URL=your_neon_database_url_here\n```\n\n4. Push the database schema:\n\n```bash\nbun run db:push\n```\n\n   If you already had a database from an older deploy and see **`column ... interest_period_id does not exist`** (or **`interest_period_status`** errors), apply the pending migration:\n\n   - **Option A (recommended):** run `bun run db:push` again so Drizzle adds missing columns/enums from `db/schema.ts`.\n   - **Option B:** in the Neon **SQL Editor**, run the file `db/migrations/0001_interest_incomplete_and_period_link.sql` (adds `Incomplete` enum value + `interest_period_id` + index).  \n     On PostgreSQL before version 15, replace the first line with `ALTER TYPE interest_period_status ADD VALUE 'Incomplete';` (no `IF NOT EXISTS`).\n\n5. Seed the database with default investors:\n\n```bash\nbun run db:seed\n```\n\n6. Run the development server:\n\n```bash\nbun run dev\n```\n\n7. Open [http://localhost:3000](http://localhost:3000) in your browser.\n\n## Database Schema\n\nThe application uses the following main tables:\n\n- **investors**: Store investor information\n- **loans**: Store loan details\n- **loan_investors**: Junction table linking loans and investors with allocation details\n- **transactions**: Store investor transactions for balance tracking\n\n## Available Scripts\n\n- `bun run dev` - Start development server\n- `bun run build` - Build for production\n- `bun run start` - Start production server\n- `bun run db:generate` - Generate database migrations\n- `bun run db:migrate` - Run database migrations\n- `bun run db:push` - Push schema changes to database\n- `bun run db:studio` - Open Drizzle Studio (database GUI)\n\n## Code Architecture \u0026 DRY Principles\n\nThis project follows **DRY (Don't Repeat Yourself)** principles with a well-organized component architecture:\n\n### Shared Utilities (`/lib/`)\n\n- **format.ts**: Centralized formatting functions (currency, dates, percentages)\n- **calculations.ts**: Business logic for loan calculations, investor stats, and aggregations\n- **badge-config.ts**: Consistent badge styling across the app\n\n### Custom Hooks (`/hooks/`)\n\nEncapsulated logic for common patterns:\n\n- `usePagination`: Handle pagination state and logic\n- `useSorting`: Handle sorting state and logic\n- `useFilters`: Handle filtering state and logic\n\nSee `/hooks/README.md` for detailed documentation.\n\n### Benefits\n\n✅ **~500+ lines of duplicate code eliminated**  \n✅ **Consistent formatting and calculations across the app**  \n✅ **Easy to maintain and test**  \n✅ **Type-safe with TypeScript**  \n✅ **Composable and reusable**\n\nSee `REFACTORING_SUMMARY.md` for complete refactoring details.\n\n## Key Features Explained\n\n### Multi-Investor Loan Creation\n\nThe loan form allows you to:\n\n1. Select multiple investors from a dropdown\n2. Allocate specific amounts to each investor\n3. Set custom interest rates per investor\n4. Specify different sent dates for each investor\n5. Preview calculations before creating the loan\n\n### Balance Tracking\n\nThe transaction system tracks:\n\n- All money IN/OUT for each investor\n- Running balance after each transaction\n- Visual indicators for investment capacity\n- Complete audit trail with dates and notes\n\n### Responsive Design\n\nThe application is fully responsive and works on:\n\n- Desktop computers\n- Tablets\n- Mobile phones\n\n## Deployment\n\n### Deploy to Vercel\n\n1. Push your code to GitHub\n2. Import your repository on [Vercel](https://vercel.com)\n3. Add your `DATABASE_URL` environment variable\n4. Deploy!\n\nVercel will automatically:\n\n- Build your Next.js application\n- Set up automatic deployments on push\n- Provide a production URL\n\n## Contributing\n\nThis is a private business application. For modifications or feature requests, please contact the development team.\n\n## License\n\nPrivate and Confidential - All Rights Reserved\n\n## Support\n\nFor issues or questions, please contact the system administrator.\n\n---\n\nBuilt with ❤️ for efficient pawn business management\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsprmke%2Fpawn-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsprmke%2Fpawn-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsprmke%2Fpawn-tracker/lists"}