A modern, cross-platform desktop application for managing personal finances, expenses, and payroll. Built with Electron and Next.js, this application combines the power of web technologies with native desktop capabilities.
- Create and manage monthly salary entries
- Track income across different time periods
- Budget allocation and monitoring
- Detailed payroll history with filtering capabilities
- Categorized expense management
- Custom expense categories (auto-create or manual)
- Quantity-based expense tracking
- Notes and additional details for each expense
- Due date tracking for pending payments
- Real-time expense overview
- Budget vs. actual spending visualization
- Category-wise expense breakdown
- Interactive charts and statistics
- Secure user registration and login
- Password hashing with bcrypt
- Session management with NextAuth.js
- Protected routes and API endpoints
- Clean, intuitive interface built with Radix UI
- Dark/light theme support
- Responsive design with Tailwind CSS
- Smooth animations and transitions
- Accessible components following WAI-ARIA guidelines
- Framework: Next.js 16.0.1 (App Router)
- UI Library: React 19.2.0
- UI Components: Radix UI primitives
- Styling: Tailwind CSS 4.1.16
- Charts: Recharts
- Forms: React Hook Form + Zod validation
- Icons: Lucide React
- Date Handling: date-fns
- Theming: next-themes
- Desktop Framework: Electron 39.0.0
- API Routes: Next.js API Routes
- Authentication: NextAuth.js
- Database: SQLite (local.db)
- ORM: Drizzle ORM
- Password Hashing: bcrypt
- Language: TypeScript
- Build Tool: electron-builder
- Database Management: Drizzle Kit
- Process Management: Concurrently
- Linting: ESLint
electron-nextjs-project/
โโโ app/ # Next.js App Router
โ โโโ (pages)/ # Route groups
โ โ โโโ auth/ # Authentication pages
โ โ โ โโโ login/ # Login page
โ โ โ โโโ signup/ # Sign up page
โ โ โโโ dashboard/ # Protected dashboard routes
โ โ โโโ page.tsx # Main dashboard
โ โ โโโ layout.tsx # Dashboard layout with sidebar
โ โ โโโ payroll/ # Payroll management
โ โ โ โโโ page.tsx # Payroll list
โ โ โ โโโ [id]/ # Individual payroll details
โ โ โโโ expense-types/ # Expense categories
โ โโโ api/ # API Routes
โ โ โโโ auth/ # Authentication endpoints
โ โ โโโ expense/ # Expense CRUD operations
โ โ โโโ expense-type/ # Category management
โ โ โโโ salary/ # Payroll operations
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Landing/home page
โ โโโ globals.css # Global styles
โโโ components/ # Reusable React components
โ โโโ ui/ # UI component library (Radix UI)
โ โโโ theme-provider.tsx # Theme context provider
โโโ context/ # React Context providers
โ โโโ auth-context.tsx # Authentication state
โ โโโ confirm-context.tsx # Confirmation dialogs
โโโ db/ # Database configuration
โ โโโ schema.ts # Drizzle ORM schema definitions
โโโ drizzle/ # Database migrations
โโโ hooks/ # Custom React hooks
โ โโโ use-mobile.ts # Mobile detection hook
โโโ lib/ # Utility functions
โโโ main/ # Electron main process
โ โโโ main.js # Electron entry point
โ โโโ preload.js # Preload script
โโโ models/ # TypeScript models/types
โ โโโ AuthSignup.ts # Signup model
โ โโโ Expense.ts # Expense model
โ โโโ ExpenseCategory.ts # Category model
โ โโโ Payroll.ts # Payroll model
โโโ navigation/ # Navigation components
โ โโโ sidebar.component.tsx # Dashboard sidebar
โโโ services/ # Business logic layer
โ โโโ expense.service.ts # Expense operations
โ โโโ expense-type.service.ts # Category operations
โ โโโ salary.service.ts # Payroll operations
โ โโโ user.service.ts # User operations
โ โโโ generic.service.ts # Shared utilities
โ โโโ index.ts # Service exports
โโโ public/ # Static assets
โโโ local.db # SQLite database file
โโโ drizzle.config.ts # Drizzle Kit configuration
โโโ next.config.ts # Next.js configuration
โโโ tsconfig.json # TypeScript configuration
โโโ tailwind.config.js # Tailwind CSS configuration
โโโ components.json # shadcn/ui configuration
โโโ package.json # Dependencies and scripts
- User authentication and profile information
- Fields:
id,name,email,passwordHash
- Monthly income/budget entries
- Fields:
id,month,year,day,title,totalBudget,userId - Relationships: Many-to-One with Users
- Custom expense categories
- Fields:
id,name,auto,active,userId - Auto-creation capability for expenses
- Individual expense records
- Fields:
id,title,amount,quantity,note,withDue,dueDate,expensesCategoryId,salaryId - Relationships: Many-to-One with Categories and Salary
Ensure you have the following installed:
- Node.js (v20 or higher)
- npm or yarn or pnpm or bun
- Clone the repository:
git clone <repository-url>
cd electron-nextjs-project- Install dependencies:
npm install
# or
yarn install
# or
pnpm install
# or
bun install- Set up environment variables:
Create a .env or .env.local file in the root directory:
# Database
DB_FILE_NAME=./local.db
# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3001
NEXTAUTH_SECRET=your-secret-key-here
# Node Environment
NODE_ENV=development- Initialize the database:
# Generate migrations
npx drizzle-kit generate
# Apply migrations
npx drizzle-kit migrateStart both the Next.js development server and Electron app:
npm run devThis command uses concurrently to run:
- Next.js dev server on
http://localhost:3001(yellow console output) - Electron app (blue console output)
The application will automatically:
- Open in an Electron window
- Enable hot module reloading
- Open DevTools for debugging
- Next.js Development Server:
http://localhost:3001 - Production Mode:
http://localhost:3000
Note: The Electron main process is configured to use port 3001 in development mode.
npm run buildThis command:
- Creates an optimized Next.js production build
- Packages the application with Electron Builder
- Generates platform-specific installers
Add to package.json for custom build settings:
{
"build": {
"appId": "com.expensetracker.app",
"productName": "Expense Tracker",
"directories": {
"output": "dist"
},
"files": [
"main/**/*",
"out/**/*",
"node_modules/**/*",
"package.json"
],
"win": {
"target": ["nsis"]
},
"mac": {
"target": ["dmg"]
},
"linux": {
"target": ["AppImage", "deb"]
}
}
}Generate migrations after schema changes:
npx drizzle-kit generateApply migrations:
npx drizzle-kit migrateOpen Drizzle Studio (Database GUI):
npx drizzle-kit studio- Development:
./local.db(SQLite file in project root) - Production: Application data directory
POST /api/auth/signup- User registrationPOST /api/auth/[...nextauth]- NextAuth.js handlersGET /api/auth/session- Get current session
GET /api/salary- List all payrollsPOST /api/salary- Create new payrollGET /api/salary/[id]- Get payroll detailsPUT /api/salary/[id]- Update payrollDELETE /api/salary/[id]- Delete payrollGET /api/salary/tiles- Dashboard statistics
GET /api/expense- List expenses (supports filtering by salaryId)POST /api/expense- Create expenseGET /api/expense/[id]- Get expense detailsPUT /api/expense/[id]- Update expenseDELETE /api/expense/[id]- Delete expenseGET /api/expense/salary/[id]- Get expenses for specific payroll
GET /api/expense-type- List all categoriesPOST /api/expense-type- Create categoryGET /api/expense-type/[id]- Get category detailsPUT /api/expense-type/[id]- Update categoryDELETE /api/expense-type/[id]- Delete category
This project uses a comprehensive UI component library built on:
- Radix UI - Unstyled, accessible components
- Tailwind CSS - Utility-first styling
- shadcn/ui - Component patterns
Available components include:
- Forms (Input, Select, Checkbox, Radio, etc.)
- Data Display (Tables, Cards, Charts)
- Feedback (Alerts, Dialogs, Toasts)
- Navigation (Sidebar, Breadcrumbs, Menus)
- Overlays (Modals, Popovers, Tooltips)
- Password Hashing: bcrypt with salt rounds
- Session Management: Secure JWT tokens
- CSRF Protection: Built-in with NextAuth.js
- Content Security Policy: Configured in Electron
- Context Isolation: Enabled in Electron
- SQL Injection Prevention: Parameterized queries with Drizzle ORM
Both Next.js and Electron support hot reloading:
- Frontend changes reload automatically
- Backend/API changes require server restart
- Electron main process changes require app restart
- Frontend: Use React DevTools in Electron window
- Backend: Console logs appear in terminal
- Electron: Main process logs in terminal, renderer in DevTools
# Run linter
npm run lint
# Format code (if configured)
npm run format- electron-serve: Serves Next.js production build in Electron
- drizzle-orm: Type-safe SQL query builder
- next-auth: Authentication for Next.js
- react-hook-form: Form state management
- zod: Schema validation
- sonner: Toast notifications
- recharts: Chart visualization
- lucide-react: Icon library
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run linting:
npm run lint - Test the application:
npm run dev - Commit your changes:
git commit -m "feat: your feature" - Push to branch:
git push origin feature/your-feature - Open a Pull Request
Follow conventional commits:
feat:New featuresfix:Bug fixesdocs:Documentation changesstyle:Code style changesrefactor:Code refactoringtest:Test additions/changeschore:Build process or auxiliary tool changes
This project is private and proprietary. All rights reserved.
- Development server runs on port 3001 (not the default 3000)
- Image optimization is disabled for Electron compatibility
- SQLite database is stored in project root (consider moving for production)
- Export functionality (CSV, PDF reports)
- Multi-currency support
- Recurring expenses
- Budget alerts and notifications
- Data backup and restore
- Advanced analytics and forecasting
- Receipt image attachments
- Cloud sync capabilities
- Mobile companion app
For questions, issues, or feature requests, please open an issue on the repository.
Built with โค๏ธ using Electron, Next.js, and React