Files
promote/backend
2025-03-11 17:54:57 +08:00
..
2025-03-11 17:54:57 +08:00
2025-03-11 13:05:51 +08:00
2025-03-11 17:54:57 +08:00
2025-03-07 18:04:27 +08:00
2025-03-11 17:54:57 +08:00
2025-03-07 18:04:27 +08:00
2025-03-07 18:04:27 +08:00
2025-03-07 18:04:27 +08:00
2025-03-07 18:04:27 +08:00

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

Getting Started

Prerequisites

  • Node.js 18+
  • pnpm
  • Redis
  • ClickHouse
  • Supabase account

Installation

  1. Clone the repository
  2. Install dependencies:
cd backend
pnpm install
  1. Create a .env file based on the .env.example file
  2. Start the development server:
pnpm dev

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login a user
  • GET /api/auth/verify - Verify a token

Analytics

  • POST /api/analytics/view - Track a view event
  • POST /api/analytics/like - Track a like/unlike event
  • POST /api/analytics/follow - Track a follow/unfollow event
  • GET /api/analytics/content/:id - Get analytics for a content
  • GET /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.