Skip to content

mrtomdev/coins-selling-business

Repository files navigation

Finance OS - Coins Selling Business

Finance OS React TypeScript Vite Supabase License

A powerful profit & conversion calculator for coin trading businesses. Track sales, manage inventory, calculate profits, and export reports.

FeaturesQuick StartDeploymentSupabase SetupDocumentation


🌟 Features

Core Functionality

  • 💰 Profit Calculator — Compute profit in PKR from USDT investment, selling rate per 100k coins, and quantity sold
  • 📱 Multi-App Support — Tracks transactions across multiple platforms (Baat, Wafa, Taka, etc.)
  • 📦 Inventory Management — Record coin purchases, track sold vs. unsold inventory, compute unrealized vs. realized profit
  • 📊 Transactions Ledger — Full history with cost-basis breakdown using FIFO accounting
  • 👛 Wallet Dashboard — Aggregate view of capital, inventory value, and net profit
  • 📄 PDF Reports — Export transactions and payroll reports with professional formatting
  • ☁️ Cloud Sync — Data persists across devices via Supabase backend
  • 🌓 Dark/Light Theme — Beautiful Apple-inspired design with seamless theme switching

Advanced Features

  • FIFO Cost Accounting — First-In-First-Out cost basis calculation for accurate profit tracking
  • Real-time Calculations — Live profit estimates as you process sales
  • Multiple Currency Support — Track different apps with different rates and ratios
  • Secure Authentication — Supabase-powered secure data storage
  • Responsive Design — Works perfectly on desktop, tablet, and mobile
  • PWA Ready — Can be installed as a progressive web app

🚀 Quick Start

Prerequisites

  • Node.js 18 or higher
  • A Supabase project (free tier available at supabase.com)
  • npm or yarn package manager

Installation

# Clone the repository
git clone https://github.com/mrtomdev/coins-selling-business.git
cd coins-selling-business

# Install dependencies
npm install

# Create environment file
cp .env.example .env.local

# Configure your Supabase credentials in .env.local
# See "Supabase Setup" section below

# Start development server
npm run dev

Open http://localhost:3000 to view the app.


☁️ Supabase Setup

1. Create a Supabase Project

  1. Go to supabase.com and sign up/login
  2. Click New Project and fill in the details
  3. Wait for the project to be created (usually takes ~2 minutes)
  4. Go to Settings > API to find your:
    • Project URL
    • anon public key

2. Create Database Tables

Go to SQL Editor in your Supabase dashboard and run this schema:

-- Enable UUID extension
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

-- App State Table
CREATE TABLE IF NOT EXISTS app_state (
  id BIGINT PRIMARY KEY DEFAULT 1,
  wallet_pkr NUMERIC DEFAULT 0,
  wallet_coins NUMERIC DEFAULT 0,
  taka_coins NUMERIC DEFAULT 0,
  usdt_rate TEXT DEFAULT '285',
  conversion_ratio INTEGER DEFAULT 1000000,
  taka_ratio INTEGER DEFAULT 1000000,
  baat_selling_rate INTEGER DEFAULT 3250,
  taka_selling_rate INTEGER DEFAULT 3100,
  taka_rate TEXT DEFAULT '285',
  updated_at TIMESTAMPTZ DEFAULT NOW()
);

INSERT INTO app_state (id) VALUES (1) ON CONFLICT (id) DO NOTHING;

-- Transactions Table
CREATE TABLE IF NOT EXISTS transactions (
  id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
  timestamp BIGINT NOT NULL,
  amount_pkr NUMERIC NOT NULL,
  coins_sold NUMERIC NOT NULL,
  profit_pkr NUMERIC NOT NULL,
  rate_applied NUMERIC NOT NULL,
  app TEXT DEFAULT 'Baat',
  cost_basis_details JSONB,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Payroll Table
CREATE TABLE IF NOT EXISTS payroll (
  id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
  timestamp BIGINT NOT NULL,
  cost_pkr NUMERIC NOT NULL,
  beans NUMERIC NOT NULL,
  beans_sold NUMERIC DEFAULT 0,
  selling_rate NUMERIC NOT NULL,
  estimated_value NUMERIC NOT NULL,
  profit NUMERIC NOT NULL,
  status TEXT DEFAULT 'unrealized',
  app TEXT DEFAULT 'Baat',
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Enable RLS
ALTER TABLE app_state ENABLE ROW LEVEL SECURITY;
ALTER TABLE transactions ENABLE ROW LEVEL SECURITY;
ALTER TABLE payroll ENABLE ROW LEVEL SECURITY;

-- Create policies for public access
CREATE POLICY "Allow public read/write on app_state" ON app_state FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow public read/write on transactions" ON transactions FOR ALL USING (true) WITH CHECK (true);
CREATE POLICY "Allow public read/write on payroll" ON payroll FOR ALL USING (true) WITH CHECK (true);

3. Configure Environment Variables

Edit .env.local:

VITE_SUPABASE_URL=https://your-project-id.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key-here

🚀 Deployment

Deploy to Vercel (Recommended)

Deploy with Vercel

  1. Click the button above
  2. Import your GitHub repository
  3. Add environment variables:
    • VITE_SUPABASE_URL = your Supabase project URL
    • VITE_SUPABASE_ANON_KEY = your Supabase anon key
  4. Click Deploy

Deploy to Netlify

Deploy to Netlify

  1. Click the button above
  2. Connect your GitHub repository
  3. Set build command: npm run build
  4. Set publish directory: dist
  5. Add environment variables
  6. Click Deploy site

GitHub Pages

  1. Push code to GitHub
  2. Go to repository Settings > Pages
  3. Select source branch
  4. Site available at https://username.github.io/coins-selling-business

📁 Project Structure

├── App.tsx                 # Main application component
├── index.tsx              # React entry point
├── index.html             # HTML template with SEO meta tags
├── index.css              # Global styles and theme tokens
├── types.ts               # TypeScript type definitions
├── vite.config.ts         # Vite bundler configuration
├── vercel.json           # Vercel deployment config
├── netlify.toml          # Netlify deployment config
├── supabase_schema.sql   # Database schema
├── components/
│   ├── Dashboard.tsx      # Main dashboard
│   ├── BSalesPage.tsx     # Sales terminal
│   ├── PayrollPage.tsx    # Inventory management
│   ├── WalletPage.tsx     # Wallet balance
│   ├── TransactionsPage.tsx # Transaction ledger
│   └── ...
├── lib/
│   ├── supabase.ts        # Supabase client
│   └── theme.ts           # Theme utilities
└── utils/
    └── format.ts          # Formatting utilities

🔧 Tech Stack

Technology Purpose
React 18 UI framework
TypeScript Type-safe development
Vite 7 Build tool
Tailwind CSS Styling (CDN)
Supabase Backend & database
jsPDF PDF reports
Lucide React Icons

📊 Default Constants

Constant Value
DEFAULT_COINS_PER_100_USDT 1,000,000
DEFAULT_USDT_RATE 285 PKR
DEFAULT_SELLING_RATE_PER_100K 3,250 PKR
TAKA_SELLING_RATE_PER_100K 3,100 PKR

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

📝 License

This project is open source under the MIT License.


⭐ Star this repo if you find it useful!

About

Finance OS — A specialized profit & conversion calculator for coin trading. Real-time USDT → Coin conversions, profit margin analysis, payroll tracking, transactions ledger, and PDF reporting. Built with React, TypeScript, Vite, Tailwind, and Supabase.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors