Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 Sparkfund β€” Crowdfunding Platform

Sparkfund is a full-stack MERN crowdfunding platform where Creators launch campaigns, Supporters back them with platform credits, and Admins keep the whole system honest. Built as a role-based application with three distinct dashboards, real credit accounting, and a full moderation workflow.

πŸ”— Live Site: https://spark-fund-client.vercel.app

πŸ”— Client Repository: https://github.com/Avishek-Pratyay/SparkFund-Client

πŸ”— Server Repository: https://github.com/Avishek-Pratyay/SparkFund-Server

πŸ”‘ Admin Credentials

  • Email: admin@gmailcom
  • Password: Admin123

✨ Features

  • Three role-based dashboards β€” Supporter, Creator, and Admin each get a purpose-built sidebar, home page, and permission set, enforced server-side with JWT + role middleware, not just hidden in the UI.
  • Dual authentication β€” register/login with email and password, or sign in instantly with Google; passwords are hashed with bcrypt and sessions are stateless JWTs stored client-side.
  • Starting credit grants β€” new Supporters receive 50 credits and new Creators receive 20 credits automatically on registration, granted exactly once.
  • Full campaign lifecycle β€” Creators submit campaigns as "pending"; Admins approve, reject, or suspend them; approved campaigns become visible to Supporters until their deadline passes.
  • Credit-hold contribution system β€” a Supporter's credits are held the moment they contribute and only released to the campaign (or refunded) once the Creator approves or rejects it.
  • Automatic refund cascade β€” deleting a campaign refunds every Supporter whose contribution had already been approved, so no one loses credits to a cancelled project.
  • Stripe-powered credit purchases β€” four credit packages (100–1500 credits) checked out through Stripe, with an automatic dummy-payment fallback so the flow is fully testable without live Stripe keys.
  • Transparent withdrawal economics β€” Creators withdraw earnings at a fixed 20-credits-per-dollar rate once they've raised a 200-credit minimum, with Admin-side "Payment Success" confirmation before credits are deducted.
  • Real-time-style notifications β€” every approval, rejection, and withdrawal confirmation writes a notification the recipient sees in a floating bell popover, sorted newest-first and dismissible by clicking anywhere on the page.
  • Campaign reporting & moderation β€” Supporters can flag suspicious campaigns; Admins review, suspend, or remove them from a dedicated Reports table.
  • imgBB-powered image uploads β€” campaign cover images and profile pictures upload directly to imgBB, with a manual URL fallback if no API key is configured.
  • Paginated contribution history β€” a Supporter's full contribution history is paginated server-side rather than loaded all at once.
  • Resilient private routing β€” reloading the browser on any dashboard route does not bounce the user back to the login page, since the auth check resolves before route guards make a decision.
  • Fully responsive β€” the marketing pages, campaign browsing, and every dashboard table adapt cleanly from mobile through desktop, including a collapsible sidebar drawer on small screens.

πŸ› οΈ Tech Stack

Client

  • React 18 + Vite
  • React Router v6
  • Tailwind CSS
  • Firebase Authentication (Google sign-in)
  • Axios
  • Swiper (hero slider & testimonials)
  • Stripe.js / React Stripe.js
  • React Hot Toast

Server

  • Node.js + Express
  • MongoDB + Mongoose
  • JSON Web Tokens (JWT) for stateless auth
  • bcryptjs for password hashing
  • Stripe (PaymentIntents API)

Hosting

  • Client: Vercel
  • Server: Render

πŸ“‚ Project Structure

crowdfunding-platform/
β”œβ”€β”€ client/          # React + Vite frontend
β”‚   └── src/
β”‚       β”œβ”€β”€ api/          # axios instances (public + secured)
β”‚       β”œβ”€β”€ components/   # Navbar, Footer, notification bell, etc.
β”‚       β”œβ”€β”€ context/      # Auth context
β”‚       β”œβ”€β”€ hooks/        # useAuth, useAxiosSecure, useRole
β”‚       β”œβ”€β”€ layouts/      # MainLayout, DashboardLayout
β”‚       β”œβ”€β”€ pages/         # Home, Auth, Campaigns, Dashboard (per role)
β”‚       β”œβ”€β”€ providers/    # AuthProvider
β”‚       └── routes/       # Route definitions, PrivateRoute, RoleRoute
└── server/          # Express + MongoDB backend
    β”œβ”€β”€ config/           # Database connection
    β”œβ”€β”€ middleware/       # verifyToken, verifyRole
    β”œβ”€β”€ models/           # User, Campaign, Contribution, Withdrawal, Payment, Notification, Report
    β”œβ”€β”€ routes/           # REST endpoints, grouped by resource
    β”œβ”€β”€ utils/            # Notification helper
    └── seedAdmin.js      # One-time script to create/promote an admin account

πŸš€ Getting Started Locally

Prerequisites

  • Node.js 18+
  • A MongoDB Atlas cluster (or local MongoDB)
  • A Firebase project with Google sign-in enabled
  • (Optional) imgBB API key and Stripe test keys

1. Clone and install

git clone https://github.com/your-username/sparkfund-server.git server
git clone https://github.com/your-username/sparkfund-client.git client

2. Server setup

cd server
npm install

Create a .env file in server/:

PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_long_random_secret
STRIPE_SECRET_KEY=your_stripe_secret_key
CLIENT_URL=http://localhost:5173
npm run dev

3. Client setup

cd client
npm install

Create a .env file in client/:

VITE_API_URL=http://localhost:5000/api

VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id

VITE_IMGBB_API_KEY=your_imgbb_api_key
VITE_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
npm run dev

The client runs at http://localhost:5173, the server at http://localhost:5000.

4. Create an admin account

There is no public admin registration option by design. After registering a normal account through the app, promote it from the server/ folder:

node seedAdmin.js admin@example.com "YourPassword123" "Admin Name"

Log out and back in on the client to see the Admin dashboard.


🌐 Deployment Notes

  • Client (Vercel): set all VITE_* environment variables in the Vercel project settings, and point VITE_API_URL at your deployed server's /api path. Redeploy after changing any env var β€” Vite bakes them in at build time.
  • Server (Render): set MONGODB_URI, JWT_SECRET, STRIPE_SECRET_KEY, and CLIENT_URL in the Render dashboard. CLIENT_URL must match your Vercel URL exactly, with no trailing slash, or the browser will block requests with a CORS error.

πŸ“„ License

This project was built as a technical assessment and is provided as-is for educational and portfolio purposes.

About

πŸš€Full-stack MERN crowdfunding platform with role-based dashboards (Supporter, Creator, Admin), credit-based contributions, Stripe payments, and a complete campaign approval workflow.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages