-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Welcome to the Supabase Ads Website Project!
This project is designed to create a simple ads website where users can register with social accounts, post ads, view ads, and have different roles like user, public, and administrator.
- User authentication with social accounts
- Role-based access control
- CRUD operations for ads
- Real-time updates
- Admin interface
- Frontend: (React/Vue/Angular)
- Backend: Supabase (PostgreSQL, Auth, Storage)
- Hosting: (Vercel/Netlify/Other)
- Node.js and npm installed
- Supabase account
- Git installed
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env
file in the root directory and add your Supabase project URL and anon key:REACT_APP_SUPABASE_URL=your-supabase-url REACT_APP_SUPABASE_ANON_KEY=your-supabase-anon-key
npm start
This will start the development server. Open http://localhost:3000 to view it in the browser.
/src
/components # React components
/pages # Page components
/services # Supabase client and API calls
/styles # CSS/SCSS files
/utils # Utility functions
.env # Environment variables
package.json # Project dependencies and scripts
README.md # Project documentation
Column | Type | Description |
---|---|---|
id | UUID | Primary key, references auth.users |
username | Text | Unique username |
created_at | Timestamp | Auto-generated creation time |
Column | Type | Description |
---|---|---|
id | UUID | Primary key, auto-generated |
user_id | UUID | References profiles(id) |
title | Text | Ad title |
description | Text | Ad description |
created_at | Timestamp | Auto-generated creation time |
To enable social providers:
- Navigate to the "Authentication" tab in your Supabase dashboard.
- Enable desired social providers (e.g., Google, Facebook).
To enable email/password authentication:
- Navigate to the "Authentication" tab in your Supabase dashboard.
- Enable email/password sign-in.
-
Public can view their own profile:
create policy "Public can view their own profile." on profiles for select using (auth.uid() = id);
-
Public can view all ads:
create policy "Public can view all ads." on ads for select using (true);
-
Users can insert their own ads:
create policy "Users can insert their own ads." on ads for insert using (auth.role() = 'user');
-
Admins can do anything:
create policy "Admins can do anything." on profiles, ads for all using (auth.role() = 'admin');
const { data: ads, error } = await supabase
.from('ads')
.select('*');
const { data, error } = await supabase
.from('ads')
.insert([
{ user_id: user.id, title: 'Ad Title', description: 'Ad Description' }
]);
const { data, error } = await supabase
.from('ads')
.update({ title: 'Updated Title' })
.eq('id', 'ad-id');
const { data, error } = await supabase
.from('ads')
.delete()
.eq('id', 'ad-id');
-
Build the project:
npm run build
-
Deploy to Vercel/Netlify:
Follow the platform-specific instructions to deploy your build folder.
- Create an admin interface for managing users and ads.
- Restrict access using role-based access control.
This wiki structure provides a comprehensive guide for setting up and developing your ads website project using Supabase. You can adapt and expand it based on your specific needs and updates to the project.
footer