StockSage is an inventory and invoice management system built with Next.js.
This project requires the following environment variables:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_******
CLERK_SECRET_KEY=sk_test_******
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth/login
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth/register
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard
NEXTAUTH_SECRET=your-secure-secret-key
NEXTAUTH_URL=https://your-deployment-url.vercel.app
NEXTAUTH_DEBUG=false
STRIPE_SECRET_KEY=sk_test_******
STRIPE_PUBLISHABLE_KEY=pk_test_******
STRIPE_WEBHOOK_SECRET=whsec_******
- Create a new project on Vercel
- Connect your repository
- Add the required environment variables in the project settings
- Deploy
# Install dependencies
npm install
# Run the development server
npm run dev
# Build for production
npm run build
# Start production server
npm start- Inventory management
- Invoice generation and tracking
- Customer management
- Financial reporting
- Integration with payment processors
- Next.js 14
- React
- TypeScript
- Tailwind CSS
- Clerk Authentication
- NextAuth.js
- Prisma ORM
- Modern UI with Dark Mode: Fully responsive interface with light and dark mode support, remembering user preference across the application
- Invoice Management: Create, view, and manage invoices with detailed line items
- AI-Powered Invoice Scanner: Upload and automatically extract data from invoice images using Google's Gemini Vision API
- Seamless Invoicing: Create and send professional invoices with Stripe integration and automatic payment tracking
- Inventory Sync: Automatically sync inventory levels with Zoho Inventory when invoices are created
- Compliance Management: Track and manage tax compliance and financial regulations
- Financial Dashboard: Visual analytics for cash flow, payments, and financial health
- Inventory Management: Track stock levels, products, and inventory movements
- User Authentication: Secure login system with guest mode for demonstration
- Dashboard Analytics: Visual representation of sales and inventory data
- Mobile-Optimized: Fully responsive design for creating and managing invoices on any device
- Framework: Next.js 14 with App Router
- Styling: Tailwind CSS with dark mode support
- Authentication: NextAuth.js
- AI Integration: Google Gemini Vision API
- Payment Processing: Stripe API for invoicing
- Inventory Integration: Zoho Inventory API
- PDF Generation: jsPDF for custom invoice templates
- Database: SQLite with Prisma ORM
- State Management: React Context API
- Form Handling: React Hook Form with Zod validation
- UI Components: Custom component library with Tailwind
- Node.js 18.0 or later
- A Gemini API key (for production use of the invoice scanner)
- Stripe account and API keys (for invoicing features)
- Zoho Inventory account and API credentials (for inventory sync)
-
Clone the repository:
git clone https://github.com/yourusername/stocksage.git cd stocksage -
Install dependencies:
npm install
-
Create a
.env.localfile in the root directory with the following environment variables:# Database DATABASE_URL="file:./prisma/dev.db" # NextAuth NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=your_secret_here NEXTAUTH_DEBUG=false # For production use of Gemini Vision API GEMINI_API_KEY=your_gemini_api_key_here # Stripe API STRIPE_SECRET_KEY=your_stripe_secret_key STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret # Zoho Inventory API ZOHO_CLIENT_ID=your_zoho_client_id ZOHO_CLIENT_SECRET=your_zoho_client_secret ZOHO_REFRESH_TOKEN=your_zoho_refresh_token ZOHO_ORGANIZATION_ID=your_zoho_organization_id -
Initialize the database:
npx prisma generate npx prisma db push
-
Start the development server:
npm run dev
-
Open http://localhost:3000 in your browser.
StockSage features a comprehensive dark mode implementation that:
- Respects user system preferences by default
- Allows manual toggling via a theme button in the header
- Persists the selected theme across routes and application sessions
- Provides visually consistent UI components in both light and dark themes
The theme implementation uses React Context API and local storage for persistence, with a smooth transition between themes.
The Invoice Scanner feature allows users to:
- Upload invoice images in various formats (JPG, PNG, PDF, etc.)
- Automatically extract key information using Google's Gemini Vision API
- Review the extracted data with confidence scores
- Edit and correct any information as needed
- Create invoice records from the extracted data
In production, the feature connects to Google's Gemini Vision API to analyze invoice images. For development and demonstration purposes, a mock implementation is provided.
The Automated Invoicing feature provides a complete solution for creating and managing professional invoices:
- Create Professional Invoices: Generate invoices with custom templates and branding
- Stripe Integration: Send invoices directly to customers via Stripe
- Payment Tracking: Automatically track payment status and receive notifications
- Custom PDF Templates: Choose from multiple invoice designs or create your own
- Zoho Inventory Sync: Automatically update inventory levels when invoices are created
- Compliance Management: Track tax compliance and financial regulations
- Compliance Calendar: Get reminders for important filing dates and deadlines
- Compliance Reports: Generate reports for tax and financial compliance
- Financial Visualizations: Interactive charts for cash flow, accounts receivable aging, and payment trends
- Customer Management: Store and manage customer information with payment history
- Mobile Invoice Creation: Create and send invoices from any device with a responsive UI
- Bulk Actions: Process multiple invoices simultaneously for efficient workflow
- Customizable Tax Rules: Configure tax rates based on product categories and locations
The Financial Dashboard provides comprehensive analytics to help businesses understand their financial health:
- Cash Flow Visualization: Track incoming and outgoing payments with interactive charts
- Accounts Receivable Aging: Monitor outstanding payments and identify collection priorities
- Payment Cycle Analysis: Understand payment patterns to improve cash flow predictions
- Revenue Trends: Visualize monthly and quarterly revenue trends with comparative analytics
- Tax Liability Tracking: Monitor accumulated tax obligations for better compliance planning
- Custom Financial Reports: Generate reports for different time periods and financial metrics
The Main Dashboard provides a comprehensive overview of your business at a glance:
- Inventory Summary: View total products, low stock items, and out-of-stock items with quick navigation
- Sales Overview: Monitor today's sales, this week's revenue, and monthly performance metrics
- Recent Activities: Track recent orders, inventory updates, and important alerts in real-time
- Top Selling Products: Identify your best performers with detailed sales metrics and ranking
- Recent Invoices: Monitor recent invoice status with quick access to payment information
- Quick Actions: Access frequently used functions like adding products and creating invoices
All invoicing features are fully responsive and optimized for mobile use:
- On-the-Go Invoice Creation: Create new invoices from any device with a streamlined mobile interface
- Mobile Payment Tracking: Monitor invoice status and payment notifications on mobile
- Optimized Invoice Previews: View and share invoice PDFs on smaller screens
- Responsive Data Tables: View and manage invoice lists with mobile-optimized tables
- Touch-Friendly Controls: Large touch targets and simplified workflows for mobile users
To enable Stripe invoicing:
- Create a Stripe account at stripe.com
- Obtain your API keys from the Stripe Dashboard
- Add your keys to the
.env.localfile - Set up a webhook endpoint in your Stripe Dashboard pointing to
/api/stripe/webhook
To enable inventory synchronization:
- Create a Zoho Inventory account at zoho.com/inventory
- Create a self-client application in the Zoho Developer Console
- Generate API credentials and add them to the
.env.localfile
stocksage/
βββ prisma/ # Prisma schema and migrations
βββ public/ # Static assets
βββ src/
β βββ app/ # Next.js App Router pages
β β βββ api/ # API routes
β β βββ financial/# Financial management pages
β β βββ invoices/ # Invoice management pages
β βββ components/ # Reusable UI components
β β βββ financial/# Financial components
β β βββ invoices/ # Invoice components
β β βββ layout/ # Layout components
β β βββ ui/ # UI components
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utility functions and libraries
β β βββ stripe.ts # Stripe integration
β β βββ zoho.ts # Zoho integration
β β βββ pdfGenerator.ts # PDF generation
β βββ services/ # API service functions
β βββ styles/ # Global styles and Tailwind configuration
β βββ types/ # TypeScript type definitions
βββ .env.example # Example environment variables
βββ next.config.js # Next.js configuration
βββ package.json # Project dependencies
βββ tailwind.config.js# Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
- Create components in the
componentsdirectory - Add pages in the
appdirectory - Update types in the
typesdirectory as needed - Add API routes in the
app/apidirectory
The easiest way to deploy StockSage is using Vercel:
npm install -g vercel
vercelA Dockerfile is provided for containerized deployment:
docker build -t stocksage .
docker run -p 3000:3000 stocksageFor deployment on a custom server:
npm run build
npm startThis project is licensed under the MIT License - see the LICENSE file for details.