# 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](https://honojs.dev/) - **Authentication**: [Supabase Auth](https://supabase.com/docs/guides/auth) + JWT - **Database**: - [Supabase (PostgreSQL)](https://supabase.com/) for main data - [ClickHouse](https://clickhouse.com/) for analytics events - **Caching**: [Redis](https://redis.io/) - **Task Queue**: [BullMQ](https://docs.bullmq.io/) ## Getting Started ### Prerequisites - Node.js 18+ - pnpm - Redis - ClickHouse - Supabase account ### Installation 1. Clone the repository 2. Install dependencies: ```bash cd backend pnpm install ``` 3. Create a `.env` file based on the `.env.example` file 4. Start the development server: ```bash 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 ```bash pnpm build ``` ### Start Production Server ```bash pnpm start ``` ### Linting ```bash pnpm lint ``` ### Testing ```bash 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.