- Node.js (v18 or higher)
- npm (v9 or higher)
- Visual Studio Code
- Clone the project and install dependencies:
git clone <your-repository-url>
cd finflow
npm install
- Environment Variables:
Create a
.env.local
file in the root directory:
# M-Pesa API Credentials
MPESA_CONSUMER_KEY=your_consumer_key
MPESA_CONSUMER_SECRET=your_consumer_secret
MPESA_PASSKEY=your_passkey
MPESA_SHORTCODE=your_shortcode
MPESA_CALLBACK_URL=your_callback_url
# Database Configuration
DATABASE_URL="postgresql://user:password@localhost:5432/finflow"
# Authentication
NEXTAUTH_SECRET=your_secret_key
NEXTAUTH_URL=http://localhost:3000
- Database Setup:
# Install Prisma CLI
npm install -D prisma
npm install @prisma/client
# Initialize Prisma
npx prisma init
# After setting up your database models, run:
npx prisma generate
npx prisma db push
- Start the development server:
npm run dev
finflow/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── education/ # Education module
│ ├── goals/ # Savings goals module
│ ├── lending/ # P2P lending module
│ └── mpesa/ # M-Pesa integration
├── components/ # Reusable components
├── lib/ # Utility functions
├── prisma/ # Database schema and migrations
└── public/ # Static assets
- Financial Education Platform
- P2P Lending System
- Savings Goals Tracker
- M-Pesa Integration
- User Authentication
- Responsive Design
To fully integrate M-Pesa:
- Register for a Safaricom Developer Account at https://developer.safaricom.co.ke/
- Create a new app to get your API credentials
- Update your
.env.local
file with the credentials - Test the integration using the Sandbox environment
The project uses Prisma with PostgreSQL. Here's the schema setup:
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
name String
email String @unique
password String
balance Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
loans Loan[] @relation("UserLoans")
investments Loan[] @relation("UserInvestments")
savingsGoals SavingsGoal[]
transactions Transaction[]
}
model Loan {
id String @id @default(cuid())
amount Float
interestRate Float
duration Int // Duration in months
status String // Active, Completed, Defaulted
borrowerId String
lenderId String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
borrower User @relation("UserLoans", fields: [borrowerId], references: [id])
lender User? @relation("UserInvestments", fields: [lenderId], references: [id])
}
model SavingsGoal {
id String @id @default(cuid())
title String
targetAmount Float
currentAmount Float @default(0)
deadline DateTime
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
}
model Transaction {
id String @id @default(cuid())
type String // Deposit, Withdrawal, Transfer
amount Float
description String?
userId String
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
}
You can safely remove the following files/directories as they are specific to the StackBlitz environment:
.bolt/
directory and all its contents- Any
.stackblitz
directories or files
-
Install VS Code Extensions:
- Prisma (for database schema)
- ESLint
- Prettier
- Tailwind CSS IntelliSense
-
Install additional dependencies:
npm install @prisma/client @auth/prisma-adapter next-auth axios
- Set up ESLint and Prettier:
npm install -D prettier eslint-config-prettier
- Start the development server:
npm run dev
-
Access the application at
http://localhost:3000
-
For database changes:
npx prisma generate # After schema changes
npx prisma db push # Push changes to database
- For M-Pesa testing:
- Use the Sandbox environment first
- Test all transactions with test credentials
- Move to production only after thorough testing
- Build the application:
npm run build
- Test the production build:
npm start
- Deploy to your preferred hosting platform (Vercel recommended for Next.js applications)
For any issues or questions:
- Check the documentation in the
docs
directory - Review the code comments
- Contact the development team
Remember to never commit sensitive information like API keys or credentials. Always use environment variables for such data.