A comprehensive analytics platform built with modern technologies including TypeScript, Nuxt 3, Elysia, and MongoDB.
This monorepo contains four main packages:
- SDK (
@analytics/sdk) - TypeScript SDK for client-side analytics tracking - Console (
@analytics/console) - Nuxt 3 dashboard for analytics visualization - Website (
@analytics/website) - Nuxt 3 landing page - Server (
@analytics/server) - Elysia API server with MongoDB
- Clone the repository:
git clone <repository-url>
cd analytics-monorepo- Install dependencies:
bun install- Set up environment variables:
cp packages/server/.env.example packages/server/.env
# Edit the .env file with your MongoDB connection stringbun dev- Runs console in dev mode, builds SDK, and runs server in dev modebun run-console- Runs console dashboard in development modebun run-website- Runs website in development modebun run-server- Runs server in development mode with watch
bun build- Builds console, builds SDK, and starts server in productionbun build-console- Builds console for productionbun build-sdk- Builds SDK (ESM + CJS)bun build-website- Builds website for production
bun start-server- Starts server in production using PM2
bun lint- Runs ESLint across all packagesbun lint:fix- Fixes ESLint issues automaticallybun type-check- Runs TypeScript type checking across all packages
- Technology: TypeScript + Vite
- Output: ESM and CJS builds
- Features: Client-side event tracking, user identification, page tracking
- Port: N/A (library)
- Technology: Nuxt 3 + Tailwind CSS + ECharts
- Port: 3000 (dev)
- Features: Real-time analytics dashboard, data visualization, event monitoring
- Technology: Nuxt 3 + Tailwind CSS
- Port: 3002 (dev)
- Features: Marketing landing page, product information
- Technology: Elysia + MongoDB + Mongoose
- Port: 3001
- Features: Event collection API, analytics aggregation, real-time data processing
POST /events- Track eventsGET /events- Retrieve events with filtering
GET /analytics/overview- Get analytics overviewGET /analytics/events/:eventName- Get analytics for specific eventGET /analytics/users/:userId- Get user analytics
GET /health- Health check endpointGET /- API status
{
event: string // Event name
properties?: object // Event properties
userId?: string // User identifier
sessionId?: string // Session identifier
timestamp: Date // Event timestamp
userAgent?: string // Browser user agent
ip?: string // Client IP address
}Each package can be developed independently:
# Work on SDK
cd packages/sdk
bun install
bun dev
# Work on Console
cd packages/console
bun install
bun dev
# Work on Website
cd packages/website
bun install
bun dev
# Work on Server
cd packages/server
bun install
bun devUse Bun workspaces to add dependencies:
# Add to specific package
bun add <package> --cwd packages/sdk
# Add dev dependency to root
bun add -D <package>- Build all packages:
bun run build-console
bun run build-sdk
bun run build-website- Start the server:
bun run start-serverServer environment variables (packages/server/.env):
PORT=3001
NODE_ENV=production
MONGODB_URI=mongodb://localhost:27017/analytics
JWT_SECRET=your-secret-key
ALLOWED_ORIGINS=https://yourdomain.com# Run all tests
bun test
# Run tests for specific package
bun test --cwd packages/sdk- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
For support, please open an issue in the GitHub repository.