git clone <your-repository-url>
cd finflow
npm install
.env.local
file in the root directory:
```env
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_URL=”postgresql://user:password@localhost:5432/finflow”
NEXTAUTH_SECRET=your_secret_key NEXTAUTH_URL=http://localhost:3000
3. Database Setup:
```bash
# 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
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
To fully integrate M-Pesa:
.env.local
file with the credentialsThe 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.stackblitz
directories or filesnpm install @prisma/client @auth/prisma-adapter next-auth axios
npm install -D prettier eslint-config-prettier
npm run dev
Access the application at http://localhost:3000
npx prisma generate # After schema changes
npx prisma db push # Push changes to database
npm run build
npm start
For any issues or questions:
docs
directoryRemember to never commit sensitive information like API keys or credentials. Always use environment variables for such data.