Skip to content

Commit d301292

Browse files
committed
docs: add comprehensive setup documentation and environment configuration
1 parent c38b789 commit d301292

File tree

5 files changed

+560
-10
lines changed

5 files changed

+560
-10
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Supabase Configuration
2+
VITE_SUPABASE_URL=your_supabase_project_url
3+
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
4+
5+
# API Configuration
6+
VITE_API_BASE_URL=https://portfolio-tracker-backend-y7ne.onrender.com/api

EMAIL_TEMPLATES_SETUP.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# 📧 Email Templates Setup Guide
2+
3+
This guide will help you implement the beautiful, aesthetic email templates for your Portfolio Tracker project in Supabase.
4+
5+
## 🎨 Template Overview
6+
7+
We've created three stunning email templates:
8+
9+
1. **Confirm Signup** - Welcome new users with feature highlights
10+
2. **Reset Password** - Secure password reset with security tips
11+
3. **Magic Link** - Passwordless authentication with benefits showcase
12+
13+
## 🚀 Implementation Steps
14+
15+
### Step 1: Access Supabase Email Templates
16+
17+
1. Go to your [Supabase Dashboard](https://supabase.com/dashboard)
18+
2. Select your Portfolio Tracker project
19+
3. Navigate to **Authentication****Email Templates**
20+
21+
### Step 2: Configure Confirm Signup Template
22+
23+
1. Click on **"Confirm signup"** template
24+
2. Replace the default content with the content from `email-templates/confirm-signup.html`
25+
3. **Important**: Replace `{{ .Email }}` with `{{ .Email }}` (Supabase uses this format)
26+
4. Replace `{{ .ConfirmationURL }}` with `{{ .ConfirmationURL }}`
27+
5. Click **Save**
28+
29+
### Step 3: Configure Reset Password Template
30+
31+
1. Click on **"Reset password"** template
32+
2. Replace the default content with the content from `email-templates/reset-password.html`
33+
3. Replace `{{ .Email }}` with `{{ .Email }}`
34+
4. Replace `{{ .ConfirmationURL }}` with `{{ .ConfirmationURL }}`
35+
5. Click **Save**
36+
37+
### Step 4: Configure Magic Link Template
38+
39+
1. Click on **"Magic link"** template
40+
2. Replace the default content with the content from `email-templates/magic-link.html`
41+
3. Replace `{{ .Email }}` with `{{ .Email }}`
42+
4. Replace `{{ .ConfirmationURL }}` with `{{ .ConfirmationURL }}`
43+
5. Click **Save**
44+
45+
## 🎯 Template Features
46+
47+
### ✨ Design Highlights
48+
49+
- **Modern Gradient Headers**: Each template has a unique color scheme
50+
- **Responsive Design**: Works perfectly on mobile and desktop
51+
- **Brand Consistency**: Matches your Portfolio Tracker theme
52+
- **Professional Typography**: Clean, readable fonts
53+
- **Interactive Elements**: Hover effects and smooth transitions
54+
55+
### 🔧 Customization Options
56+
57+
#### Colors & Branding
58+
- **Confirm Signup**: Blue gradient (#3b82f6 to #1d4ed8)
59+
- **Reset Password**: Red gradient (#ef4444 to #dc2626)
60+
- **Magic Link**: Purple gradient (#8b5cf6 to #7c3aed)
61+
62+
#### Content Sections
63+
- **Welcome Messages**: Personalized greetings
64+
- **Feature Highlights**: Showcase key benefits
65+
- **Security Information**: Important safety reminders
66+
- **Call-to-Action Buttons**: Clear, prominent CTAs
67+
- **Footer Links**: Support and social media
68+
69+
## 📱 Mobile Optimization
70+
71+
All templates are fully responsive and include:
72+
- Mobile-first design approach
73+
- Optimized typography for small screens
74+
- Touch-friendly button sizes
75+
- Proper spacing for mobile viewing
76+
77+
## 🔒 Security Features
78+
79+
### Built-in Security Elements
80+
- **Expiration Notices**: Clear time limits for links
81+
- **Security Warnings**: Alerts for unintended requests
82+
- **Privacy Information**: Data protection notices
83+
- **Support Contacts**: Easy access to help
84+
85+
### Template Variables
86+
- `{{ .Email }}` - User's email address
87+
- `{{ .ConfirmationURL }}` - Secure confirmation link
88+
- `{{ .TokenHash }}` - Security token (if needed)
89+
- `{{ .SiteURL }}` - Your application URL
90+
91+
## 🎨 Customization Guide
92+
93+
### Changing Colors
94+
To modify the color scheme, update these CSS variables:
95+
96+
```css
97+
/* Confirm Signup - Blue Theme */
98+
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
99+
100+
/* Reset Password - Red Theme */
101+
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
102+
103+
/* Magic Link - Purple Theme */
104+
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
105+
```
106+
107+
### Updating Content
108+
- **Company Name**: Replace "Portfolio Tracker" with your brand
109+
- **Support Email**: Update `[email protected]`
110+
- **Social Links**: Add your actual social media URLs
111+
- **Features**: Customize the feature highlights for your app
112+
113+
### Adding Your Logo
114+
Replace the SVG icon in the header with your actual logo:
115+
116+
```html
117+
<div class="logo">
118+
<!-- Replace with your logo -->
119+
<img src="your-logo-url.png" alt="Your Brand" style="width: 32px; height: 32px;">
120+
</div>
121+
```
122+
123+
## 📊 Testing Your Templates
124+
125+
### 1. Enable Email Confirmations
126+
1. Go to **Authentication****Settings**
127+
2. Enable **"Enable email confirmations"**
128+
3. Set **Site URL** to your domain
129+
4. Add redirect URLs for your app
130+
131+
### 2. Test Each Template
132+
1. **Signup Test**: Create a new account
133+
2. **Password Reset Test**: Use "Forgot Password" feature
134+
3. **Magic Link Test**: Enable magic link authentication
135+
136+
### 3. Preview Templates
137+
Use Supabase's built-in preview feature to see how templates look before sending.
138+
139+
## 🚨 Troubleshooting
140+
141+
### Common Issues
142+
143+
#### Template Not Loading
144+
- Check for syntax errors in HTML
145+
- Ensure all CSS is properly formatted
146+
- Verify template variables are correct
147+
148+
#### Styling Issues
149+
- Test in different email clients
150+
- Use inline CSS for better compatibility
151+
- Avoid complex CSS animations
152+
153+
#### Links Not Working
154+
- Verify `{{ .ConfirmationURL }}` is properly set
155+
- Check redirect URLs in Supabase settings
156+
- Test link expiration times
157+
158+
### Email Client Compatibility
159+
- **Gmail**: Full support
160+
- **Outlook**: Good support (some CSS limitations)
161+
- **Apple Mail**: Full support
162+
- **Mobile Apps**: Responsive design works well
163+
164+
## 📈 Best Practices
165+
166+
### Content Guidelines
167+
- Keep subject lines under 50 characters
168+
- Use clear, action-oriented language
169+
- Include your brand name in subject lines
170+
- Test with different email addresses
171+
172+
### Design Guidelines
173+
- Use high contrast for readability
174+
- Keep images under 1MB
175+
- Use web-safe fonts as fallbacks
176+
- Test on multiple devices
177+
178+
### Security Guidelines
179+
- Never include sensitive data in emails
180+
- Use HTTPS for all links
181+
- Implement proper link expiration
182+
- Monitor for suspicious activity
183+
184+
## 🎉 Success Metrics
185+
186+
Track these metrics to measure template effectiveness:
187+
- **Open Rates**: Aim for 20-30%
188+
- **Click-Through Rates**: Target 2-5%
189+
- **Conversion Rates**: Measure signup completions
190+
- **Bounce Rates**: Keep under 5%
191+
192+
## 📞 Support
193+
194+
If you need help with the templates:
195+
1. Check the Supabase documentation
196+
2. Review email client compatibility guides
197+
3. Test with different email providers
198+
4. Contact Supabase support if needed
199+
200+
---
201+
202+
**🎨 Your Portfolio Tracker now has beautiful, professional email templates that will enhance user experience and build trust with your users!**

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Render](https://img.shields.io/badge/Render-46E3B7?style=for-the-badge&logo=render&logoColor=white)](https://portfolio-tracker-backend-y7ne.onrender.com/api)
77
[![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)](https://reactjs.org/)
88
[![Vite](https://img.shields.io/badge/Vite-646CFF?style=for-the-badge&logo=vite&logoColor=white)](https://vitejs.dev/)
9-
[![MySQL](https://img.shields.io/badge/MySQL-4479A1?style=for-the-badge&logo=mysql&logoColor=white)](https://www.mysql.com/)
9+
[![Supabase](https://img.shields.io/badge/Supabase-3ECF8E?style=for-the-badge&logo=supabase&logoColor=white)](https://supabase.com/)
1010
[![TailwindCSS](https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwind-css&logoColor=white)](https://tailwindcss.com/)
1111
[![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
1212
[![Finnhub](https://img.shields.io/badge/Finnhub-1B1B1B?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMyA2aDJsMTUgMk0xNyA2djE0TTcgMTZoMTAiLz48L3N2Zz4=)](https://finnhub.io/)
@@ -41,7 +41,7 @@
4141

4242
- Node.js 14+
4343
- npm or yarn
44-
- MySQL
44+
- Supabase account
4545
- Finnhub API Key (get one at [finnhub.io](https://finnhub.io/))
4646

4747
### Frontend Setup
@@ -73,15 +73,18 @@ npm install
7373

7474
2. Configure `.env`:
7575
```env
76-
DATABASE_URL=mysql://user:password@localhost:3306/portfolio_tracker
76+
SUPABASE_URL=your_supabase_url
77+
SUPABASE_KEY=your_supabase_anon_key
7778
PORT=5000
78-
NODE_ENV=development
7979
FINNHUB_API_KEY=your_finnhub_api_key
8080
```
8181

82-
3. Run migrations and start:
82+
3. Set up Supabase:
83+
- Follow the instructions in `backend/SUPABASE_SETUP.md`
84+
85+
4. Test connection and start:
8386
```bash
84-
npm run migrate
87+
npm run init-db
8588
npm start
8689
```
8790

@@ -142,8 +145,7 @@ Visit our [API Documentation](https://hackstyx.github.io/portfolio-tracker/)
142145
### 🛠 Backend
143146
- **Runtime**: [Node.js](https://nodejs.org/) - JavaScript runtime
144147
- **Framework**: [Express](https://expressjs.com/) - Web framework for Node.js
145-
- **Database**: [MySQL](https://www.mysql.com/) - Open-source relational database
146-
- **ORM**: [Sequelize](https://sequelize.org/) - Modern TypeScript and Node.js ORM
148+
- **Database**: [Supabase](https://supabase.com/) - Open source Firebase alternative
147149
- **Market Data**: [Finnhub](https://finnhub.io/) - Real-time RESTful APIs for stocks
148150
- **API Documentation**: [Github Pages](https://hackstyx.github.io/portfolio-tracker/)
149151

@@ -156,8 +158,8 @@ Visit our [API Documentation](https://hackstyx.github.io/portfolio-tracker/)
156158
- Containerized deployment
157159
- Automatic scaling
158160
- Built-in monitoring
159-
- **Database Hosting**: [Railway](https://railway.app/)
160-
- Managed MySQL database
161+
- **Database Hosting**: [Supabase](https://supabase.com/)
162+
- PostgreSQL database
161163
- Automated backups
162164
- High availability
163165

SUPABASE_AUTH_SETUP.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Supabase Authentication Setup
2+
3+
This guide will help you set up Supabase authentication for the Portfolio Tracker application.
4+
5+
## Prerequisites
6+
7+
1. A Supabase account (sign up at [supabase.com](https://supabase.com))
8+
2. A Supabase project created
9+
10+
## Setup Steps
11+
12+
### 1. Create a Supabase Project
13+
14+
1. Go to [supabase.com](https://supabase.com) and sign in
15+
2. Click "New Project"
16+
3. Choose your organization
17+
4. Enter a project name (e.g., "portfolio-tracker")
18+
5. Enter a database password
19+
6. Choose a region close to your users
20+
7. Click "Create new project"
21+
22+
### 2. Get Your Project Credentials
23+
24+
1. In your Supabase dashboard, go to Settings > API
25+
2. Copy the following values:
26+
- **Project URL** (looks like: `https://your-project-id.supabase.co`)
27+
- **anon public** key (starts with `eyJ...`)
28+
29+
### 3. Configure Environment Variables
30+
31+
1. Create a `.env` file in the root of your project
32+
2. Add the following variables:
33+
34+
```env
35+
VITE_SUPABASE_URL=https://your-project-id.supabase.co
36+
VITE_SUPABASE_ANON_KEY=your_anon_key_here
37+
VITE_API_BASE_URL=https://portfolio-tracker-backend-y7ne.onrender.com/api
38+
```
39+
40+
### 4. Configure Authentication Settings
41+
42+
1. In your Supabase dashboard, go to Authentication > Settings
43+
2. Configure the following:
44+
45+
#### Site URL
46+
- Set to `http://localhost:5173` for development
47+
- Set to your production URL for production
48+
49+
#### Redirect URLs
50+
Add these redirect URLs:
51+
- `http://localhost:5173/dashboard`
52+
- `http://localhost:5173/`
53+
- Your production URLs when deployed
54+
55+
### 5. Email Templates (Optional)
56+
57+
1. Go to Authentication > Email Templates
58+
2. Customize the email templates for:
59+
- Confirm signup
60+
- Reset password
61+
- Magic link
62+
63+
### 6. Enable Email Confirmation (Recommended)
64+
65+
1. Go to Authentication > Settings
66+
2. Enable "Enable email confirmations"
67+
3. This ensures users verify their email before accessing the app
68+
69+
## Features Implemented
70+
71+
### Authentication Functions
72+
- **Sign Up**: Users can create accounts with email, password, and name
73+
- **Sign In**: Users can sign in with email and password
74+
- **Sign Out**: Users can sign out and return to homepage
75+
- **Password Reset**: Users can request password reset emails
76+
- **Email Verification**: Users receive confirmation emails (if enabled)
77+
78+
### Protected Routes
79+
- All dashboard routes (`/dashboard`, `/portfolio`, `/watchlist`, etc.) are protected
80+
- Unauthenticated users are redirected to the homepage
81+
- Loading states are shown during authentication checks
82+
83+
### User Experience
84+
- Form validation and error handling
85+
- Loading states during authentication
86+
- Success/error messages
87+
- Automatic redirect to dashboard after successful login
88+
- Persistent sessions across browser refreshes
89+
90+
## Testing the Setup
91+
92+
1. Start the development server: `npm run dev`
93+
2. Navigate to `http://localhost:5173`
94+
3. Try creating a new account
95+
4. Try signing in with the created account
96+
5. Test the logout functionality
97+
98+
## Troubleshooting
99+
100+
### Common Issues
101+
102+
1. **"Invalid API key" error**
103+
- Check that your `VITE_SUPABASE_ANON_KEY` is correct
104+
- Make sure you're using the "anon public" key, not the service role key
105+
106+
2. **"Invalid redirect URL" error**
107+
- Add your localhost URL to the redirect URLs in Supabase settings
108+
- Make sure the URL matches exactly (including protocol and port)
109+
110+
3. **Email not received**
111+
- Check spam folder
112+
- Verify email templates are configured in Supabase
113+
- Check Supabase logs for email delivery issues
114+
115+
4. **Authentication not working**
116+
- Verify environment variables are loaded correctly
117+
- Check browser console for errors
118+
- Ensure Supabase project is active and not paused
119+
120+
### Getting Help
121+
122+
- Check the [Supabase documentation](https://supabase.com/docs)
123+
- Review the [Supabase Auth documentation](https://supabase.com/docs/guides/auth)
124+
- Check the browser console for detailed error messages

0 commit comments

Comments
 (0)