PayGuard is a secure, robust system for tracking and verifying payments. This application leverages modern web technologies to provide seamless user authentication, efficient payment management, and document verification.
Deadline: January 13th, 2025, 05:00 UTC
Tech Stack:
- Frontend: Next.js (TypeScript, Tailwind CSS, Shadcn UI)
- Backend: Supabase (Auth and Database)
- Core Features: User authentication, admin dashboard, document uploads, payment tracking
- Secure user authentication using Supabase.
- Role-based access control for users and admins.
- Create, track, and manage payments.
- Admins can approve or reject payments.
- Upload and verify documents with real-time status tracking.
- Admins manage and verify uploaded files.
- User Dashboard: Track payment status and manage uploads.
- Admin Dashboard: Monitor and control payments and documents.
- Set up Next.js project with required configurations.
- Installed and configured Supabase SSR (
@supabase/ssr,@supabase/supabase-js). - Established basic project structure and middleware.
- Developed frontend pages using Shadcn components and Tailwind CSS.
- Built reusable components for the frontend.
- Integrated APIs for Supabase authentication flow.
- Data Validation with Zod
- Connected the Supabase Database and Created User with Authetication
- Created APIs for payment processing.
- Store Payment information into Payment Tables.
- Stripe Payment integrated succesfully with a flow.
- Admin Panel: Add functionality of Admin panel.
- Document Upload Functionality: Integrate Supabase Storage for file uploads.
- Dashboards: Build detailed user and admin dashboards.
- Deployment: Deploy the application to production.
payguard/
├── app/
│ ├── auth/ # Authentication Pages
│ ├── (dashboard)/ # User Dashboard Pages
│ ├── admin/ # Admin Dashboard Pages
│ ├── api/ # API Endpoints
│ ├── layout.tsx # Root Layout
│ └── page.tsx # Landing Page
├── components/ # Reusable Components
│ ├── auth/ # Authentication Components
│ ├── dashboard/ # Dashboard Components
│ ├── admin/ # Admin Components
│ ├── layout/ # Layout Components (Header, Footer, Sidebar)
│ ├── ui/ # UI Components (Button, Card, etc.)
│ └── shared/ # Shared Components (Loading Spinner, etc.)
├── lib/ # Utilities and Configuration
│ ├── supabase/ # Supabase Client and Server
│ ├── utils/ # Helper Functions (Auth, Date Formatting)
│ └── validations/ # Data Validation Schemas (zod)
├── public/ # Public Assets (Images, Icons)
├── middleware.ts # Middleware for Authentication
├── next.config.js # Next.js Configuration
├── tailwind.config.ts # Tailwind CSS Configuration
└── tsconfig.json # TypeScript Configuration
| Field | Type | Description |
|---|---|---|
id |
UUID | Primary Key |
email |
VARCHAR | Unique email |
password |
HASHED | Managed by Supabase |
role |
VARCHAR | User role: admin or user |
created_at |
TIMESTAMP | Account creation date |
CREATE TABLE profiles (
id UUID REFERENCES auth.users NOT NULL PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(255) NOT NULL,
role VARCHAR(20) DEFAULT 'user' NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
alter table profiles enable row level security;
create policy "Profiles are viewable, editable, deletable by users who created them."
on profiles for all
using ( auth.uid() = id );| Field | Type | Description |
|---|---|---|
id |
UUID | Primary Key |
title |
VARCHAR | Payment description/title |
amount |
NUMERIC | Payment amount |
status |
VARCHAR | Status: pending, approved, rejected |
user_id |
UUID | Foreign Key (references Users.id) |
created_at |
TIMESTAMP | Payment creation date |
stripe_payment_intent_id |
VARCHAR | Payment intent id |
CREATE TABLE payments (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
title VARCHAR(255) NOT NULL,
amount NUMERIC(10,2) NOT NULL,
status VARCHAR(20) DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected')),
user_id UUID REFERENCES auth.users NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
stripe_payment_intent_id TEXT;
);
alter table payments enable row level security;
create policy "Users can view their own payments"
on payments for select
using ( auth.uid() = user_id );
create policy "Users can create their own payments"
on payments for insert
with check ( auth.uid() = user_id );
create policy "Users can update their own pending payments"
on payments for update
using ( auth.uid() = user_id AND status = 'pending' );
create policy "Admins can view all payments"
on payments for select
using (
auth.uid() IN (
SELECT id FROM profiles WHERE role = 'admin'
)
);
create policy "Admins can update any payment status"
on payments for update
using (
auth.uid() IN (
SELECT id FROM profiles WHERE role = 'admin'
)
);
| Field | Type | Description |
|---|---|---|
id |
UUID | Primary Key |
user_id |
UUID | Foreign Key (references Users.id) |
file_url |
TEXT | File URL in Supabase Storage |
status |
VARCHAR | Status: pending, approved, rejected |
uploaded_at |
TIMESTAMP | Upload date |
- POST
/api/auth/signup: Register users. - POST
/api/auth/login: Login users.
- POST
/api/create-payment: Create a payment request.- Validate input (title, amount).
- Assign the logged-in user as
user_id. - Default status:
pending.
- GET
/api/payment: Retrieve payment records.- Users: View their payments.
- Admins: View all payments.
- PUT
/api/payment/:id: Update payment status (admin only).- Approve or reject payments.
- DELETE
/api/cancel-payment: Cancel a payment request.- Cancel the payment request according to the
user_id.
- Cancel the payment request according to the
- POST
/api/documents: Upload a document.- Validate file type and size (max: 5 MB).
- Store the file in Supabase Storage and save metadata in the
Documentstable. - Default status:
pending.
- PUT
/api/documents/:id: Update verification status (admin only).- Mark documents as
approvedorrejected.
- Mark documents as
- GET
/api/dashboard/payments-summary: Retrieve payment summaries (total payments, breakdown by status). - GET
/api/dashboard/payments: Filter payments by status/date.
-
Clone the repository:
git clone https://github.com/your-repo/payguard.git cd payguard -
Install dependencies:
npm install
-
Configure Supabase:
- Add your Supabase credentials in
.env:NEXT_PUBLIC_SUPABASE_URL=<your-supabase-url> NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-supabase-anon-key>
- Add your Supabase credentials in
-
Start the development server:
npm run dev
-
Access the application at
http://localhost:3000.
- Use Vercel for deploying the frontend.
- Use Supabase for database and authentication.
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit changes:
git commit -m "Add feature name" - Push to the branch:
git push origin feature-name
- Create a pull request.
This project is licensed under the MIT License.