Skip to content

light-space/tax-code-generator

Repository files navigation

Tax Code Generator

AI-powered tax code generation workflow using Gemini. Generates tax codes, CSVs, and tax reports for any country through a 4-step guided process.

Tech Stack

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript
  • Auth: Supabase Auth (Google OAuth)
  • Database: Supabase (Postgres)
  • AI: Google Gemini API (gemini-2.5-flash)
  • Styling: Tailwind CSS 3.4 with Axolotl dark theme
  • State: Zustand
  • Package Manager: pnpm

Setup

1. Install dependencies

pnpm install

2. Environment variables

Create .env.local:

NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
GEMINI_API_KEY=your-gemini-api-key

3. Supabase configuration

  • Enable Google OAuth in the Supabase dashboard under Authentication > Providers
  • Database tables and RLS policies are managed via Supabase migrations

4. Run

pnpm dev        # Development server
pnpm build      # Production build
pnpm start      # Production server

How It Works

4-Step Workflow

Each country goes through a sequential workflow:

  1. Tax Codes — Generates a comprehensive list of tax codes for the country
  2. Tax Code CSV — Converts the tax codes into structured CSV format
  3. Tax Report — Analyzes the tax codes and produces a detailed report
  4. Mapped CSV — Combines tax codes with report insights into a final CSV

Each step streams its output from Gemini in real-time. Steps must be completed in order — each step's output is injected into the next step's prompt via {{previous_output}}.

Admin

Visit /admin to edit the prompt templates for each step. Available placeholders:

  • {{country_name}} — The selected country name
  • {{previous_output}} — Output from the previous step

CSV Download

Steps 2 and 4 produce CSV output. A download button appears when these steps complete.

Project Structure

src/
  app/
    page.tsx                    # Main page (country selector, steps, chat)
    actions.ts                  # signOut server action
    actions/
      countries.ts              # Country CRUD server actions
      steps.ts                  # Step message/reset server actions
    admin/
      page.tsx                  # Prompt template editor
      actions.ts                # Prompt template server actions
    api/gemini/
      route.ts                  # Gemini SSE streaming endpoint
    auth/callback/
      route.ts                  # OAuth callback
    login/
      page.tsx                  # Login page
  components/
    chat/
      ChatWindow.tsx            # Main chat pane with blob background
      ChatMessage.tsx           # Message bubble (user/assistant)
      LoadingIndicator.tsx      # Braille spinners + animated line
      useChatStore.ts           # Zustand store
      useChatStream.ts          # SSE streaming hook
    country/
      CountrySelector.tsx       # Country dropdown + create
    steps/
      StepNavigation.tsx        # Step tabs with status badges
  lib/supabase/
    client.ts                   # Browser Supabase client
    server.ts                   # Server Supabase client
  middleware.ts                 # Auth guard
  styles/
    globals.css                 # Tailwind + blob animations
    themes/                     # Axolotl design tokens

Database Schema

Table Purpose
countries User's countries (RLS per user)
country_steps 4 steps per country with status + output
step_messages Chat message history per step
prompt_templates Editable prompts for each step

About

Generates tax codes, reports and mappings with Gemini

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors