Skip to content

Tracks loans between marketplace users showing who owes what... Created at https://coslynx.com

Notifications You must be signed in to change notification settings

coslynx/borrow-lend-ledger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Borrow Lend Tracker MVP

A web application to track money borrowed and lent between individuals, maintaining a clear transaction ledger and summary.

Developed with the software and tools below.

Framework: React (Vite) Language: TypeScript Styling: Tailwind CSS API Client: Axios State Management: React Context
git-last-commit GitHub commit activity GitHub top language

πŸ“‘ Table of Contents

  • πŸ“ Overview
  • πŸ“¦ Features
  • πŸ“‚ Structure
  • πŸ’» Installation
  • πŸ—οΈ Usage
  • 🌐 Hosting
  • 🀝 Contributing (Placeholder)
  • πŸ“œ API Documentation (Conceptual Backend)
  • πŸ“„ License
  • πŸ‘ Authors

πŸ“ Overview

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.

πŸ“¦ Features

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).

πŸ“‚ Structure

/
β”œβ”€β”€ 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

πŸ’» Installation

Warning

πŸ”§ Prerequisites

  • 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.

πŸš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/borrow-lend-ledger.git
    cd borrow-lend-ledger
  2. Install dependencies:
    npm install
  3. Configure environment variables:
    • Copy the example environment file:
      cp .env.example .env
    • Edit the .env file and set the VITE_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

πŸ—οΈ Usage

πŸƒβ€β™‚οΈ Running the MVP

  1. Ensure the conceptual backend API is running and accessible at the URL specified in your .env file.

  2. Start the frontend development server:

    npm run dev

    This command (defined in package.json and described in commands.json) starts the Vite development server, typically on http://localhost:5173.

  3. Access the application in your web browser at the URL provided by Vite (e.g., http://localhost:5173).

Tip

βš™οΈ Configuration

  • The primary configuration is the backend API endpoint set in the .env file via VITE_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.

πŸ“š Available Scripts

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 the dist/ directory.
  • npm run lint: Lints the codebase using ESLint.
  • npm run typecheck: Performs TypeScript type checking without emitting files.

🌐 Hosting

πŸš€ Deployment Instructions

This frontend application is built as a static site and can be deployed to various static hosting providers.

Example: Deploying to Netlify / Vercel

  1. Build the application:
    npm run build
    This creates an optimized production build in the dist/ directory.
  2. 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 to npm run build and the publish directory to dist.
    • 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 to dist.
  3. 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.

πŸ”‘ Environment Variables

  • 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

🀝 Contributing (Placeholder)

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.

πŸ“œ API Documentation (Conceptual Backend)

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.

πŸ” Endpoints

  • 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).

πŸ”’ Authentication

  • 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.

πŸ“ Examples (Conceptual curl)

# 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

πŸ“œ License & Attribution

πŸ“„ License

This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.

πŸ€– AI-Generated MVP

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

πŸ“ž Contact

For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:

🌐 CosLynx.com

Create Your Custom MVP in Minutes With CosLynxAI!