linqapp-backend
v1.0.0
Published
LinqApp Backend - AI Data Collection and Storage Platform
Maintainers
Readme
LinqApp Backend
Backend API server for LinqApp - AI Data Collection and Storage Platform.
Project Structure
backend/
├── src/
│ ├── config/
│ │ └── supabase.js # Supabase client configuration
│ ├── routes/
│ │ ├── auth.js # Authentication routes
│ │ ├── workspaces.js # Workspace management routes
│ │ ├── data.js # Data management routes
│ │ └── external-apps.js # External app integration routes
│ └── index.js # Main Express server
├── package.json
├── .gitignore
└── README.mdSetup Instructions
Prerequisites
- Node.js (v18 or higher)
- npm or yarn
- Supabase account
1. Install Dependencies
cd backend
npm install2. Supabase Project Setup
You need to create a new Supabase project on their website. Follow these steps:
A. Create Supabase Project
- Go to supabase.com
- Sign in or create an account
- Click "New Project"
- Choose your organization
- Enter project details:
- Name:
linqapp - Database Password: Choose a strong password (save this!)
- Region: Choose closest to your location
- Name:
- Click "Create new project"
- Wait for the project to be created (takes 2-3 minutes)
B. Get Project Configuration
Once your project is ready:
- Go to Settings → API
- Copy the following values:
- Project URL (looks like:
https://xxxxx.supabase.co) - Anon public key (starts with
eyJhbGc...) - Service role key (starts with
eyJhbGc...)
- Project URL (looks like:
C. Configure Google OAuth
- Go to Authentication → Providers
- Find "Google" and click the toggle to enable it
- Add your Google OAuth credentials:
- You'll need to create a Google OAuth app at console.developers.google.com
- Add the callback URL:
https://your-project-ref.supabase.co/auth/v1/callback
3. Environment Configuration
- Create a
.envfile in the backend directory:
# Copy the example file
cp .env.example .env- Fill in your
.envfile with the values from Supabase:
# Supabase Configuration
SUPABASE_URL=https://your-project-ref.supabase.co
SUPABASE_ANON_KEY=your_anon_key_here
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here
# Database Configuration
DATABASE_URL=your_database_url_from_supabase
# Authentication Configuration
JWT_SECRET=your_random_jwt_secret_here
GOOGLE_CLIENT_ID=your_google_oauth_client_id
GOOGLE_CLIENT_SECRET=your_google_oauth_client_secret
GOOGLE_OAUTH_REDIRECT_URL=https://bdoprzphzdkfljanmzzc.supabase.co/auth/v1/callback
# OpenAI Configuration (for Phase 1G)
OPENAI_API_KEY=your_openai_api_key
# Application Configuration
NODE_ENV=development
PORT=3000
API_BASE_URL=http://localhost:3000
# Encryption Configuration
MASTER_ENCRYPTION_KEY=your_random_32_char_key_here
# File Upload Configuration
MAX_FILE_SIZE=10485760
ALLOWED_FILE_TYPES=image/jpeg,image/png,image/gif,audio/mpeg,audio/wav,audio/ogg
# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
# Logging Configuration
LOG_LEVEL=info4. Start the Development Server
npm run devThe server will start on http://localhost:3000
5. Test the Setup
Visit http://localhost:3000/health - you should see:
{
"status": "OK",
"message": "LinqApp Backend is running",
"timestamp": "2024-01-XX...",
"environment": "development"
}6. Test Route Endpoints
All route placeholders should be working:
GET /api/auth/test→ "Auth routes working"GET /api/workspaces/test→ "Workspace routes working"GET /api/data/test→ "Data routes working"GET /api/external-apps/test→ "External apps routes working"
Next Steps
This completes Subphase 1A: Infrastructure Setup.
Next we'll implement:
- Subphase 1B: Authentication System with Google OAuth
- Subphase 1C: Database Schema Design
- Subphase 1D: Encryption System
- And so on...
Available Scripts
npm run dev- Start development server with nodemonnpm start- Start production servernpm run db:start- Start local Supabase (when using local development)npm run db:stop- Stop local Supabasenpm run db:status- Check Supabase statusnpm run db:reset- Reset databasenpm run db:generate-types- Generate TypeScript types from database
Environment Variables Needed
Make sure you have all these environment variables set up:
- ✅
SUPABASE_URL- From Supabase dashboard - ✅
SUPABASE_ANON_KEY- From Supabase dashboard - ✅
SUPABASE_SERVICE_ROLE_KEY- From Supabase dashboard - ⏳
GOOGLE_CLIENT_ID- From Google OAuth setup - ⏳
GOOGLE_CLIENT_SECRET- From Google OAuth setup - ⏳
OPENAI_API_KEY- For AI processing (Phase 1G) - ⚠️
JWT_SECRET- Generate a random string - ⚠️
MASTER_ENCRYPTION_KEY- Generate a random 32-character string
Troubleshooting
Common Issues
"Missing Supabase environment variables"
- Check that your
.envfile exists and has the correct Supabase values
- Check that your
CORS errors
- Make sure
ALLOWED_ORIGINSincludes your frontend URL
- Make sure
Connection refused
- Verify your Supabase project URL is correct
- Check if Supabase project is active
Getting Help
If you encounter issues:
- Check the console logs for detailed error messages
- Verify all environment variables are set correctly
- Test the Supabase connection directly in their dashboard
