A web application to track money borrowed and lent between individuals, maintaining a clear transaction ledger and summary.
- π Overview
- π¦ Features
- π Structure
- π» Installation
- ποΈ Usage
- π Hosting
- π€ Contributing (Placeholder)
- π API Documentation (Conceptual Backend)
- π License
- π Authors
This repository contains the Minimum Viable Product (MVP) for a Borrow/Lend Tracker web application. The primary goal is to provide a simple, efficient way for individuals (e.g., users within web marketplaces) to record and track money exchanged between known parties. It maintains a clear ledger ("sheet") of who borrowed how much from whom and calculates summaries of net debts and credits per person.
The frontend is built using React with TypeScript for type safety, bootstrapped with Vite for a fast development experience. Tailwind CSS is used for utility-first styling. Global state, including the transaction list and calculated summaries, is managed using React Context API. Data persistence relies on interaction with a conceptual backend API via Axios.
Feature | Description | |
---|---|---|
βοΈ | Architecture | Component-based React frontend using Vite. Features separation into pages (pages ), reusable UI elements (components ), state management (context ), and API interaction layer (services ). |
π | Documentation | This README provides an overview, setup instructions, usage details, and conceptual API definition. Code includes JSDoc comments where applicable. |
π | Dependencies | Core dependencies include react , react-dom , react-router-dom , axios . Dev dependencies include vite , typescript , tailwindcss , eslint . |
π§© | Modularity | Clear separation of concerns: Pages for views, Components for UI elements, Context for global state, Services for API calls. |
β¨ | Core Functionality | Add new transactions (lender, borrower, amount). View a chronological ledger of all transactions. View an aggregated summary of who owes whom. |
π¨ | Styling | Utility-first styling with Tailwind CSS, adhering to a consistent dark theme. |
π§ | Routing | Client-side routing handled by react-router-dom for navigation between Ledger, Add Transaction, and Summary pages. |
πΎ | State Management | Global application state (transactions, summaries, loading/error status) managed centrally via React Context API (TransactionContext ). |
π‘ | API Interaction | Uses Axios (src/services/api.ts ) to communicate with a conceptual backend API for fetching and creating transactions. |
β | Validation | Includes basic client-side form validation in TransactionForm.tsx (required fields, positive amount, lender != borrower). |
/
βββ public/
β βββ index.html # HTML entry point
βββ src/
β βββ components/ # Reusable UI components
β β βββ Button.tsx
β β βββ Input.tsx
β β βββ SummaryDisplay.tsx
β β βββ TransactionForm.tsx
β β βββ TransactionList.tsx
β βββ context/ # React Context for global state
β β βββ TransactionContext.tsx
β βββ pages/ # Page-level components associated with routes
β β βββ AddTransactionPage.tsx
β β βββ LedgerPage.tsx
β β βββ SummaryPage.tsx
β βββ services/ # API interaction logic
β β βββ api.ts
β βββ App.tsx # Root application component with routing setup
β βββ index.css # Global styles and Tailwind directives
β βββ main.tsx # Application entry point (renders App into DOM)
β βββ vite-env.d.ts # Vite environment variable type definitions
βββ .env # Environment variables (API base URL) - *DO NOT COMMIT*
βββ .env.example # Example environment variables file
βββ .eslintrc.cjs # ESLint configuration (if generated/added)
βββ .gitignore # Git ignore rules
βββ commands.json # Descriptions of npm scripts
βββ index.html # Link to public/index.html (Vite convention)
βββ package.json # Project dependencies and scripts
βββ postcss.config.js # PostCSS configuration (for Tailwind/Autoprefixer)
βββ README.md # This file
βββ startup.sh # Optional development server startup script
βββ tailwind.config.js # Tailwind CSS configuration
βββ tsconfig.json # TypeScript compiler configuration
βββ vite.config.ts # Vite build tool configuration
Warning
- Node.js: LTS version recommended (e.g., v18.x or v20.x). Check with
node -v
. - npm: Usually included with Node.js. Check with
npm -v
. - Git: For cloning the repository.
- Conceptual Backend API: This frontend requires a running backend API service that implements the endpoints defined in API Documentation. The frontend expects this API to be accessible at the URL specified in the
.env
file.
- Clone the repository:
git clone https://github.com/coslynx/borrow-lend-ledger.git cd borrow-lend-ledger
- Install dependencies:
npm install
- Configure environment variables:
- Copy the example environment file:
cp .env.example .env
- Edit the
.env
file and set theVITE_API_BASE_URL
to the base URL of your running conceptual backend API.# Example .env content VITE_API_BASE_URL=http://localhost:3001/api # Replace with your actual backend API URL
- Copy the example environment file:
-
Ensure the conceptual backend API is running and accessible at the URL specified in your
.env
file. -
Start the frontend development server:
npm run dev
This command (defined in
package.json
and described incommands.json
) starts the Vite development server, typically onhttp://localhost:5173
. -
Access the application in your web browser at the URL provided by Vite (e.g.,
http://localhost:5173
).
Tip
- The primary configuration is the backend API endpoint set in the
.env
file viaVITE_API_BASE_URL
. Vite uses this during build time and makes it available to the application. vite.config.ts
: Configures the Vite build tool (dev server port, build options).tailwind.config.js
: Configures Tailwind CSS theme and content scanning.tsconfig.json
: Configures the TypeScript compiler options.
You can use the following scripts defined in package.json
(see commands.json
for descriptions):
npm run dev
: Starts the development server.npm run build
: Creates a production build in thedist/
directory.npm run lint
: Lints the codebase using ESLint.npm run typecheck
: Performs TypeScript type checking without emitting files.
This frontend application is built as a static site and can be deployed to various static hosting providers.
- Build the application:
This creates an optimized production build in the
npm run build
dist/
directory. - Deploy the
dist
directory:- Netlify: Use the Netlify CLI (
netlify deploy --prod
) or connect your Git repository via the Netlify dashboard. Set the build command tonpm run build
and the publish directory todist
. - Vercel: Use the Vercel CLI (
vercel --prod
) or connect your Git repository via the Vercel dashboard. Vercel typically auto-detects Vite projects. Ensure the Output Directory is set todist
.
- Netlify: Use the Netlify CLI (
- Set Environment Variables: Configure the
VITE_API_BASE_URL
environment variable in your hosting provider's settings. This variable is needed during the build process on the hosting platform.
VITE_API_BASE_URL
(Required at Build Time): The base URL of the backend API the deployed frontend will communicate with. Example:https://your-api.example.com/api
Note
As this is an AI-generated MVP, direct contributions are not typically accepted in the conventional sense. However, feedback and suggestions can be directed to CosLynx.com. If forking, follow standard Git practices.
The frontend (src/services/api.ts
) expects a backend API with the following endpoints. This MVP only includes the frontend code; the backend must be implemented separately.
-
GET /transactions
- Description: Retrieves all recorded transactions.
- Method:
GET
- Response Body (Success - 200 OK):
application/json
[ { "id": "tx_123", "lender": "Alice", "borrower": "Bob", "amount": 50.00, "createdAt": "2023-10-27T10:00:00.000Z" }, { "id": "tx_456", "lender": "Charlie", "borrower": "Alice", "amount": 25.50, "createdAt": "2023-10-28T11:30:00.000Z" } ]
- Response Body (Error): Standard HTTP error codes (e.g., 500 Internal Server Error).
-
POST /transactions
- Description: Creates a new transaction record.
- Method:
POST
- Request Body:
application/json
{ "lender": "David", "borrower": "Eve", "amount": 100.75 }
- Response Body (Success - 201 Created):
application/json
(The newly created transaction object){ "id": "tx_789", "lender": "David", "borrower": "Eve", "amount": 100.75, "createdAt": "2023-10-29T14:00:00.000Z" }
- Response Body (Error): Standard HTTP error codes (e.g., 400 Bad Request for invalid data, 500 Internal Server Error).
- No authentication is implemented or expected by the frontend MVP. The conceptual backend API is assumed to be open or handle authentication independently if required.
# Get all transactions
curl http://localhost:3001/api/transactions
# Add a new transaction
curl -X POST http://localhost:3001/api/transactions \
-H "Content-Type: application/json" \
-d '{"lender": "Frank", "borrower": "Grace", "amount": 15.00}'
Note
This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.
This MVP was entirely generated using artificial intelligence through CosLynx.com.
No human was directly involved in the coding process of the repository: borrow-lend-ledger
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: CosLynx.com
- Twitter: @CosLynxAI
Create Your Custom MVP in Minutes With CosLynxAI!