Zapnote Backend is a robust Node.js/TypeScript API server designed to power the Zapnote application, a collaborative knowledge management and AI-assisted platform. It provides RESTful endpoints for user management, workspace collaboration, AI-powered chat, knowledge base operations, search functionality, and whiteboard features.
- User Management: Authentication, user profiles, and access control
- Workspace Collaboration: Multi-user workspaces with role-based permissions
- AI-Powered Chat: Intelligent conversations with AI assistance
- Knowledge Base: Document and content management with embeddings
- Advanced Search: Vector-based search across knowledge and content
- Whiteboard: Collaborative drawing and diagramming tools
- Real-time Communication: WebSocket support for live updates
- Queue Processing: Background job processing for heavy tasks
- Content Scraping: Automated data extraction from various sources
The backend follows a modular architecture with clear separation of concerns:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Client Apps │ │ Zapnote API │ │ External APIs │
│ │◄──►│ │◄──►│ │
│ - Web Frontend │ │ - Express Server│ │ - Gemini AI │
│ │ │ - REST Endpoints│ │ - Firebase Auth │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Middleware │ │ Services │ │ Database │
│ │ │ │ │ │
│ - Auth │◄──►│ - AI Services │◄──►│ - Prisma ORM │
│ - Rate Limiting │ │ - Queue Service │ │ - PostgreSQL │
│ - Validation │ │ - Scraper │ └─────────────────┘
└─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐
│ Cache & Queue │ │ File Storage │
│ │ │ │
│ - Redis Cache │ │ - Firebase │
│ - QStash Queue │ │ - Local Files │
└─────────────────┘ └─────────────────┘
- API Layer: Express.js server handling HTTP requests and WebSocket connections
- Business Logic: Modular services for chat, knowledge, search, and more
- Data Layer: Prisma ORM with PostgreSQL database and Redis caching
- AI Integration: Gemini AI for embeddings, summarization, and chat
- Authentication: Firebase Authentication with custom middleware
- Background Processing: Queue system for async tasks like scraping and AI processing
- Runtime: Node.js
- Language: TypeScript
- Framework: Express.js
- Database: PostgreSQL with Prisma ORM
- Cache: Redis
- Authentication: Firebase Auth
- AI: Google Gemini
- Queue: QStash
- WebSockets: Socket.io
- Scraping: Custom scrapers for Twitter, YouTube, and generic sites
- Node.js (v18+)
- PostgreSQL database
- Redis server
- Firebase project with authentication enabled
- Google Gemini API key
-
Clone the repository:
git clone <repository-url> cd zapnote-backend
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile with the following variables:NODE_ENV=development PORT=3001 DATABASE_URL=postgresql://user:password@localhost:5432/zapnote REDIS_URL=redis://localhost:6379 FIREBASE_PROJECT_ID=your-project-id GEMINI_API_KEY=your-gemini-key QSTASH_TOKEN=your-qstash-token FRONTEND_URL=http://localhost:3000 -
Run database migrations:
npx prisma migrate deploy
-
Start the development server:
npm run dev
The API will be available at http://localhost:3001.
GET /health- Health check endpointPOST /api/test/seed- Seed test data (development only)
/api/v1/users/*- User management/api/v1/workspaces/*- Workspace operations/api/v1/workspaces/:workspaceId/chat/*- Chat functionality/api/v1/workspaces/:workspaceId/search/*- Search operations/api/v1/workspaces/:workspaceId/spaces/*- Whiteboard features/api/v1/knowledge/*- Knowledge base management
src/
├── app.ts # Main Express app
├── server.ts # Server startup
├── config/ # Configuration files
├── middleware/ # Express middleware
├── modules/ # Feature modules
│ ├── chat/
│ ├── knowledge/
│ ├── search/
│ ├── user/
│ ├── whiteboard/
│ └── workspace/
├── services/ # Shared services
├── types/ # TypeScript types
└── utils/ # Utility functions
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm start- Start production servernpm test- Run testsnpm run lint- Run ESLint
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License.