Assignment 8 - Advanced API Development with Supabase
Building on the work you did in Assignment 7, this assignment focuses on improving your API by introducing a new table, creating joined endpoints using Supabase, and integrating Supabase's ORM and authentication into your project.
Core Requirements
1. Database Setup with Supabase
-
Set up a Supabase project and connect it to your PostgreSQL database.
-
Add a new table to your database. For example:
- Table Name:
user_profiles
- Schema (add more fields if you want to):
id
: Foreign key (linked to theid
column in theusers
table).date_of_birth
: Date, stores the user's date of birth.bio
: String, stores a short biography of the user.
- Table Name:
-
Create a one-to-one relationship between the
users
table and theuser_profiles
table using a foreign key
2. New API Endpoint with Supabase ORM
-
Create a new endpoint that retrieves data by joining the
users
table with theuser_profiles
table, using Supabase ORM:- GET
/users/profiles
: Retrieve all users and their respective profiles
- GET
-
Frontend Integration
- Update your frontend to fetch and display data from the new
/users/profiles
endpoint.
- Update your frontend to fetch and display data from the new
3. Supabase Authentication
- Enable Authentication
Use Supabase's authentication features to restrict access to certain API endpoints.- Example: Require users to log in before accessing the
/users/profiles
endpoint. - Use Supabase's documentation and guides for adding authentication
- Example: Require users to log in before accessing the
Additional Requirements
1. Refactor Existing Endpoints
- Refactor the endpoints you created in Assignment 7 to use Supabase ORM instead of raw SQL.
2. Extend Your Database Schema
- Add more tables and relationships to enhance your API. For example:
- A
posts
table that stores user-generated posts.
- A
3. Additional API Endpoints
- Enhance your API with more functionality:
- GET
/posts
:Retrieve all posts with their authors. - POST
/posts
: Create a new post. - DELETE
/posts/:id
: Delete a post by ID.
- GET
4. Supabase Authentication in Depth
- Use Supabase's built-in roles and permissions to:
- Allow only authenticated users to create or delete posts.
- Restrict some API endpoints to admin-only access.
Resources
Submission
For feedback from DISC exec
Follow these instructions if you are submitting to get feedback from DISC exec. The deadline for your submission is 1 week after the associated workshop.
-
Database
- Take screenshots of your Supabase database setup and config.
- Include the schema for your new
user_profiles
table. - Include the schema for any tables you added.
- Include the schema for your new
- Take screenshots of your Supabase database setup and config.
-
API Repository
- In your API repository, add a README.md file that explains your approach, key takeaways, and any challenges you encountered during the assignment. This will help your reviewers understand your work in detail.
- Make a pull request from your
hw-8
branch into main. You will submit the link to this PR.
-
Frontend Repository
- Make a pull request from your
hw-8
branch into main. You will submit the link to this PR.
- Make a pull request from your
-
Fill out this Google form
For the Discover Program Application
If you are not submitting for DISC exec feedback, but for your Discover Program Application, follow the submission instructions in the application form.