Promote Backend API
Backend API for the Promote platform, built with Hono.js, Supabase, ClickHouse, Redis, and BullMQ.
Features
- Authentication: JWT-based authentication with Supabase Auth
- Analytics Tracking: Track views, likes, and followers using ClickHouse
- Caching: Redis for fast API responses
- Task Scheduling: BullMQ for background processing
Tech Stack
- Framework: Hono.js
- Authentication: Supabase Auth + JWT
- Database:
- Supabase (PostgreSQL) for main data
- ClickHouse for analytics events
- Caching: Redis
- Task Queue: BullMQ
Getting Started
Prerequisites
- Node.js 18+
- pnpm
- Redis
- ClickHouse
- Supabase account
Installation
- Clone the repository
- Install dependencies:
cd backend
pnpm install
- Create a
.envfile based on the.env.examplefile - Start the development server:
pnpm dev
API Endpoints
Authentication
POST /api/auth/register- Register a new userPOST /api/auth/login- Login a userGET /api/auth/verify- Verify a token
Analytics
POST /api/analytics/view- Track a view eventPOST /api/analytics/like- Track a like/unlike eventPOST /api/analytics/follow- Track a follow/unfollow eventGET /api/analytics/content/:id- Get analytics for a contentGET /api/analytics/user/:id- Get analytics for a user
Development
Build
pnpm build
Start Production Server
pnpm start
Linting
pnpm lint
Testing
pnpm test
Project Structure
backend/
├── src/
│ ├── config/ # Configuration files
│ ├── controllers/ # Route controllers
│ ├── middlewares/ # Middleware functions
│ ├── models/ # Data models
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ ├── utils/ # Utility functions
│ └── index.ts # Entry point
├── .env # Environment variables
├── package.json # Dependencies and scripts
└── tsconfig.json # TypeScript configuration
License
This project is licensed under the ISC License.