This guide covers the setup and configuration of authentication, admin panel, contact form, and Firebase integration for the portfolio website.
- Node.js (v16.0.0+)
- npm (v8.0.0+)
- Firebase account
- Basic knowledge of React and TypeScript
- Go to Firebase Console
- Click "Create a project"
- Follow the setup wizard
- Enable Google Analytics (optional)
- Navigate to "Firestore Database" in Firebase Console
- Click "Create database"
- Choose production mode
- Select your preferred location
- Navigate to "Authentication" in Firebase Console
- Click "Get started"
- Enable desired sign-in methods (Email/Password, Google, etc.)
- Go to Project Settings (gear icon)
- Scroll down to "Your apps"
- Click "Web app" (</>) icon
- Register your app
- Copy the configuration object
- Create
src/firebase/env.tsfile:
export const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project-id",
storageBucket: "your-project.appspot.com",
messagingSenderId: "123456789",
appId: "your-app-id"
};- Update the configuration with your actual Firebase values
- The
env.tsfile is already gitignored for security
- Contact form with name, email, and message fields
- Form validation using React Hook Form and Zod
- Data storage in Firestore
- Toast notifications for user feedback
- Responsive design
contacts/
├── {documentId}/
├── name: string
├── email: string
├── message: string
├── createdAt: timestamp
├── isRead: boolean
└── id: string
- Users fill out the contact form at
/contact - Form data is validated client-side
- Successful submissions are stored in Firestore
- Users receive confirmation via toast notification
- Form resets after successful submission
- Login and signup forms
- Form validation
- Tab-based interface
- Loading states
- Toast notifications
- Responsive design
- Note: Currently uses simulated authentication (no actual Firebase Auth integration)
- Login/signup forms collect user data
- Success/error states are simulated with timeouts
- Ready for Firebase Auth integration
- Uncomment Firebase Auth setup in
src/firebase/config.ts - Implement actual authentication logic in
src/pages/Auth.tsx - Add authentication state management
- Protect admin routes
Example integration:
import { signInWithEmailAndPassword, createUserWithEmailAndPassword } from 'firebase/auth';
import { auth } from '@/firebase/config';
// In handleLogin function
const userCredential = await signInWithEmailAndPassword(auth, email, password);- View all contact messages
- Mark messages as read/unread
- Message details view
- Responsive table layout
- Search and filter capabilities
- Currently uses localStorage check for admin status
- Set
isAdmin=truein localStorage to access admin panel - Security Note: Implement proper authentication for production use
Add these rules to secure admin access:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /contacts/{document} {
// Allow read/write for authenticated admin users
allow read, write: if request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
// Allow create for anyone (contact form submissions)
allow create: if true;
}
}
}- Create admin user in Authentication
- Add user document in Firestore:
users/
├── {userId}/
├── email: string
├── isAdmin: boolean
└── createdAt: timestamp
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Contacts collection
match /contacts/{document} {
allow create: if true; // Anyone can submit contact forms
allow read, update, delete: if isAdmin();
}
// Users collection
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
allow read: if isAdmin();
}
// Helper function to check admin status
function isAdmin() {
return request.auth != null &&
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAdmin == true;
}
}
}- Never commit
src/firebase/env.tsto version control - Use environment variables in production
- Keep API keys secure
- Authentication: Implement proper user authentication
- Admin Protection: Add server-side admin verification
- Rate Limiting: Implement contact form rate limiting
- CORS: Configure Firebase CORS settings
- HTTPS: Ensure HTTPS in production
- Monitoring: Set up Firebase monitoring and alerts
- Connect GitHub repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy with automatic builds
- Install Firebase CLI:
npm install -g firebase-tools - Login:
firebase login - Initialize:
firebase init hosting - Build:
npm run build - Deploy:
firebase deploy
| Route | Purpose | Authentication Required |
|---|---|---|
/ |
Home page | No |
/about |
About page | No |
/projects |
Projects showcase | No |
/academics |
Academic background | No |
/contact |
Contact form | No |
/resume |
Resume/CV | No |
/auth |
Login/Signup | No |
/admin |
Admin panel | Yes (localStorage check) |
- Testing Contact Form: Use Firestore emulator for local testing
- Admin Access: Set
localStorage.setItem('isAdmin', 'true')in browser console - Firebase Debugging: Check browser console for Firebase connection status
- Form Validation: Test various input scenarios for robust validation
For issues or questions:
- Check Firebase Console for errors
- Review browser console logs
- Verify Firestore security rules
- Ensure environment configuration is correct
Note: This portfolio uses a modern tech stack with React, TypeScript, Tailwind CSS, and Firebase. Make sure all dependencies are properly installed and configured before deployment.