API Overview
Welcome to the API documentation hub. This section contains comprehensive information about the backend services powering the portfolio ecosystem, including authentication, feedback management, analytics, and admin capabilities.
🚀 Backend API Service
The portfolio backend is an Express.js service providing RESTful APIs for:
- User Authentication - Sign up, sign in, password management
- Feedback Management - Public submissions with admin oversight
- Analytics Tracking - Website metrics and event tracking
- Admin Operations - Health monitoring, logs, and metrics
- User Management - CRUD operations for users and roles
Base URL: http://localhost:3001 (development)
Production: Contact for production endpoint
Documentation: Backend API Reference
🔐 Authentication
The API uses Supabase Auth with JWT tokens for secure authentication.
Supported Methods
- Supabase Auth - Email/password authentication
- JWT Tokens - Access and refresh tokens
- Admin Tokens - Legacy admin authentication
- Social Auth - Google, GitHub (via Supabase)
Quick Start
# Sign up
curl -X POST http://localhost:3001/api/auth/signup \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepass123",
"name": "John Doe"
}'
# Sign in
curl -X POST http://localhost:3001/api/auth/signin \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepass123"
}'
# Use access token
curl http://localhost:3001/api/users/me \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"📡 API Endpoints
Authentication Routes
POST /api/auth/signup- Register new userPOST /api/auth/signin- Sign in with credentialsPOST /api/auth/signout- End sessionPOST /api/auth/reset-password- Request password resetPOST /api/auth/update-password- Update passwordGET /api/auth/me- Get current user
Feedback Routes
POST /api/feedback- Submit feedback (public)GET /api/feedback/get-feedback- Retrieve feedback (admin)PUT /api/feedback/:id- Update feedback status (admin)
Analytics Routes
GET /api/analytics- Get all analyticsGET /api/analytics/website/:id- Get by websiteGET /api/analytics/date-range- Query date rangePOST /api/analytics- Create analytics entry
Admin Routes
GET /api/admin/health- System health checkGET /api/admin/metrics- Request metricsGET /api/admin/logs- Application logsGET /api/admin/users- User management
🔍 Rate Limits
Protection against abuse with rate limiting:
| Endpoint Type | Rate Limit | Window |
|---|---|---|
| Authentication | 10/min | Per IP |
| Feedback | 5/15min | Per IP |
| Analytics | 100/min | Per API key |
| Admin | 100/min | Per token |
⚠️ Error Handling
All API errors follow a consistent JSON format:
{
"success": false,
"error": "Error message",
"details": {
"field": ["Validation error"]
},
"statusCode": 400
}Common Status Codes
- 200 - Success
- 201 - Created
- 400 - Bad Request (validation)
- 401 - Unauthorized
- 403 - Forbidden
- 404 - Not Found
- 429 - Rate Limited
- 500 - Server Error
🛠️ Setup & Development
Prerequisites
- Node.js 20+
- pnpm 10.20.0+
- Supabase account
Quick Setup
cd Backend
pnpm install
cp .env.example .env
# Configure .env with your credentials
pnpm dev