Backend REST API for ArtConnect CRM Platform - A comprehensive art collection management system.
- Node.js - Runtime environment
- Express.js - Web framework
- TypeScript - Type-safe JavaScript
- Prisma ORM - Database toolkit
- PostgreSQL (Supabase) - Relational database
- Firebase Admin SDK - Authentication (JWT validation from Firebase Auth)
- Zod - Schema validation
artconnect-backend/
├── src/
│ ├── config/ # Configuration files (database, firebase)
│ ├── controllers/ # Request handlers (lean, calls services)
│ ├── middlewares/ # Express middlewares (auth, validation, error handling)
│ ├── routes/ # API routes
│ ├── schemas/ # Zod validation schemas
│ ├── services/ # Business logic (database interactions, complex logic)
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Utility functions
│ ├── tests/ # Integration tests
│ └── index.ts # Application entry point
├── prisma/
│ └── schema.prisma # Database schema
├── docs/ # Project documentation
├── .env # Environment variables (not committed)
├── .env.example # Environment variables template
├── tsconfig.json # TypeScript configuration
├── nodemon.json # Nodemon configuration
└── package.json # Dependencies and scripts
npm installCopy .env.example to .env and update the values:
cp .env.example .envUpdate the following in .env:
DATABASE_URL- Your Supabase Transaction URL (port 6543)DIRECT_URL- Your Supabase Session URL (port 5432) for migrationsFIREBASE_PROJECT_ID,FIREBASE_PRIVATE_KEY,FIREBASE_CLIENT_EMAIL- Firebase Admin SDK credentialsCORS_ORIGIN- Comma-separated list of allowed origins (e.g.,http://localhost:5173,http://localhost:3000)
Important: Frontend expects backend on port 3000 with /api prefix for all routes.
Make sure your Supabase/PostgreSQL instance is running, then:
# Generate Prisma Client
npm run prisma:generate
# Run migrations to create database tables
npm run prisma:migrate
# Seed the database with initial data (Optional)
npm run prisma:seed
# (Optional) Open Prisma Studio to view your database
npm run prisma:studionpm run devServer will start on http://localhost:3000
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm start- Start production servernpm run prisma:generate- Generate Prisma Clientnpm run prisma:migrate- Run database migrationsnpm run prisma:studio- Open Prisma Studio (database GUI)npm test- Run integration tests
This backend validates JWT tokens from Firebase Auth (Google Sign-In).
Frontend Flow:
- User signs in with Google on frontend (Firebase Auth)
- Frontend receives Firebase JWT token
- Frontend calls
POST /api/auth/syncwith the token to sync user to database. - Frontend sends requests with
Authorization: Bearer <token>header for protected routes. - Backend validates token using Firebase Admin SDK.
User ID Strategy:
The database User.id is the Firebase UID. This ensures strict 1:1 mapping between Auth and DB.
- User - User accounts (Primary Key = Firebase UID)
- Artwork - Art pieces in collection
- Contact - Collectors, galleries, museums, dealers
- SalesDeal - Sales pipeline management
- Activity - Activity timeline/logging
See prisma/schema.prisma or docs/DATABASE_SCHEMA.md for detailed schema.
GET /api/health - Check API status
# Auth
POST /api/auth/sync - Sync Firebase user to DB
GET /api/auth/profile - Get user profile
PUT /api/auth/profile - Update user profile
# Artworks
GET /api/artworks
POST /api/artworks
GET /api/artworks/:id
PUT /api/artworks/:id
DELETE /api/artworks/:id
# Contacts
GET /api/contacts
POST /api/contacts
GET /api/contacts/:id
PUT /api/contacts/:id
DELETE /api/contacts/:id
# Sales Pipeline
GET /api/sales
POST /api/sales
GET /api/sales/:id
PUT /api/sales/:id/stage
DELETE /api/sales/:id
# Analytics
GET /api/analytics/dashboard
GET /api/analytics/sales-performance
- Frontend: artconnect-frontend
- Vue 3 + TypeScript + Tailwind CSS + Firebase Auth
ISC
Built with ❤️ for artists and collectors