A production-quality web application that helps users estimate oil & gas tax write-off deductions, specifically focusing on Intangible Drilling Costs (IDCs) and their impact on federal and state tax savings.
This tool is for educational and illustrative purposes only and does not constitute tax, legal, or investment advice. Please consult a qualified CPA or tax professional before making decisions.
All calculations are estimates, not guarantees. Actual tax outcomes depend on many factors including at-risk rules, passive activity loss limitations, AMT, and your complete tax situation.
- Multi-Step Questionnaire: Adaptive, agentic questionnaire that collects user tax profile, investment details, and tax rates
- Deterministic Tax Calculations: Core calculation engine (no AI) for:
- IDC deduction calculations
- Federal and state tax savings
- Taxable income before/after
- Effective net cost of investment
- 7-year TDC depreciation schedule
- AI-Powered Explanations: Claude integration for:
- Plain-English narrative explanation of results
- Summary for accountant/CPA review
- Modern UI: Clean, responsive interface built with Next.js, Tailwind CSS, and shadcn/ui
- Framework: Next.js 16 (App Router) with TypeScript
- UI: React, Tailwind CSS, shadcn/ui components
- Forms: react-hook-form + Zod validation
- AI: Anthropic Claude API (for explanations only)
- Testing: Vitest + React Testing Library
- Charts: Recharts (for future enhancements)
All tax calculations are deterministic and implemented in pure TypeScript functions:
calculateOilGasTaxPlan(): Main calculation function- IDC amount = investment × IDC percentage
- Tax savings = IDC amount × tax rates
- TDC depreciation = 7-year straight-line (simplified)
No AI is used for calculations - only for generating explanations.
Claude API is used only for:
- Generating user-friendly narrative explanations
- Creating accountant summaries
The AI receives pre-calculated results and explains them - it does not perform any math.
Simplified 2024 federal tax bracket lookup based on income and filing status. This is for demonstration purposes only.
npm install
# or
pnpm installCreate a .env.local file:
# Anthropic Claude API
ANTHROPIC_API_KEY=your-api-key-here
ANTHROPIC_MODEL=claude-3-5-sonnet-20241022Get your API key from: https://console.anthropic.com/
npm run devnpm testFor UI testing:
npm run test:uiog-tax-planner/
├── app/
│ ├── page.tsx # Landing page
│ ├── plan/
│ │ └── page.tsx # Multi-step questionnaire
│ ├── results/
│ │ └── page.tsx # Results dashboard
│ └── api/
│ └── explain/
│ └── route.ts # AI explanation endpoint
├── components/
│ ├── forms/ # Questionnaire step components
│ ├── layout/ # Layout components
│ └── ui/ # shadcn/ui components
├── lib/
│ ├── calculations/
│ │ ├── taxPlanner.ts # Core tax calculation logic
│ │ └── taxPlanner.test.ts
│ ├── ai/
│ │ └── anthropicClient.ts # Claude API integration
│ ├── config/
│ │ └── taxBrackets.ts # Tax bracket lookup
│ └── validation/
│ └── schemas.ts # Zod validation schemas
└── types/
└── planner.ts # TypeScript type definitions
- Typically 70-85% of investment (user-configurable)
- Deductible in the year incurred (Year 1)
- Provides immediate tax benefit
- Remaining percentage of investment (100% - IDC%)
- Depreciated over 7 years using straight-line method (simplified)
- Provides ongoing tax benefits
- Federal rate: User-provided or approximated from income/filing status
- State rate: User-provided or approximated from state lookup
- Rates applied to IDC deduction for Year 1 savings
- Only federal rate applied to TDC depreciation (simplified)
This tool does NOT account for:
- At-risk rules
- Passive activity loss limitations
- Alternative Minimum Tax (AMT)
- State-specific deduction rules
- Timing differences
- Phase-outs and other complexities
This is illustrative only. Real tax calculations require professional analysis.
- TypeScript strict mode: All code is fully typed
- ESLint + Prettier: Enforced code style
- Unit tests: Core calculation logic is tested
- Component tests: Critical UI flows are tested
- New calculation logic: Add to
lib/calculations/taxPlanner.ts - New form step: Create component in
components/forms/ - New API endpoint: Add route handler in
app/api/ - New UI component: Use shadcn/ui or create in
components/
# Run all tests
npm test
# Run with UI
npm run test:ui
# Run with coverage
npm run test:coveragenpm run build
npm start[Your License Here]
For questions about:
- Tax calculations: Consult a qualified CPA or tax professional
- Technical issues: Check the code comments and test files
- IRS rules: See IRS Publication 535 (Business Expenses) and consult a tax professional
Remember: This tool provides educational estimates only. Always consult a qualified tax professional before making tax planning decisions.