Skip to content

ikemboi/FinLink

Repository files navigation

FinFlow - Financial Management Platform

Prerequisites

  • Node.js (v18 or higher)
  • npm (v9 or higher)
  • Visual Studio Code

Setup Instructions

  1. Clone the project and install dependencies:
git clone <your-repository-url>
cd finflow
npm install
  1. 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
  1. 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
  1. Start the development server:
npm run dev

Project Structure

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

Features

  • Financial Education Platform
  • P2P Lending System
  • Savings Goals Tracker
  • M-Pesa Integration
  • User Authentication
  • Responsive Design

M-Pesa Integration

To fully integrate M-Pesa:

  1. Register for a Safaricom Developer Account at https://developer.safaricom.co.ke/
  2. Create a new app to get your API credentials
  3. Update your .env.local file with the credentials
  4. Test the integration using the Sandbox environment

Database Schema

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])
}

Files to Remove

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

Additional Setup Steps

  1. Install VS Code Extensions:

    • Prisma (for database schema)
    • ESLint
    • Prettier
    • Tailwind CSS IntelliSense
  2. Install additional dependencies:

npm install @prisma/client @auth/prisma-adapter next-auth axios
  1. Set up ESLint and Prettier:
npm install -D prettier eslint-config-prettier

Development Workflow

  1. Start the development server:
npm run dev
  1. Access the application at http://localhost:3000

  2. For database changes:

npx prisma generate  # After schema changes
npx prisma db push   # Push changes to database
  1. For M-Pesa testing:
  • Use the Sandbox environment first
  • Test all transactions with test credentials
  • Move to production only after thorough testing

Deployment

  1. Build the application:
npm run build
  1. Test the production build:
npm start
  1. Deploy to your preferred hosting platform (Vercel recommended for Next.js applications)

Support

For any issues or questions:

  1. Check the documentation in the docs directory
  2. Review the code comments
  3. Contact the development team

Remember to never commit sensitive information like API keys or credentials. Always use environment variables for such data.

Releases

No releases published

Packages

No packages published

Languages