Skip to content

useoutline/analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Analytics Platform Monorepo

A comprehensive analytics platform built with modern technologies including TypeScript, Nuxt 3, Elysia, and MongoDB.

πŸ—οΈ Architecture

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

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository:
git clone <repository-url>
cd analytics-monorepo
  1. Install dependencies:
bun install
  1. Set up environment variables:
cp packages/server/.env.example packages/server/.env
# Edit the .env file with your MongoDB connection string

πŸ“¦ Package Scripts

Development

  • bun dev - Runs console in dev mode, builds SDK, and runs server in dev mode
  • bun run-console - Runs console dashboard in development mode
  • bun run-website - Runs website in development mode
  • bun run-server - Runs server in development mode with watch

Building

  • bun build - Builds console, builds SDK, and starts server in production
  • bun build-console - Builds console for production
  • bun build-sdk - Builds SDK (ESM + CJS)
  • bun build-website - Builds website for production

Production

  • bun start-server - Starts server in production using PM2

Development Tools

  • bun lint - Runs ESLint across all packages
  • bun lint:fix - Fixes ESLint issues automatically
  • bun type-check - Runs TypeScript type checking across all packages

πŸ”§ Package Details

SDK (@analytics/sdk)

  • Technology: TypeScript + Vite
  • Output: ESM and CJS builds
  • Features: Client-side event tracking, user identification, page tracking
  • Port: N/A (library)

Console (@analytics/console)

  • Technology: Nuxt 3 + Tailwind CSS + ECharts
  • Port: 3000 (dev)
  • Features: Real-time analytics dashboard, data visualization, event monitoring

Website (@analytics/website)

  • Technology: Nuxt 3 + Tailwind CSS
  • Port: 3002 (dev)
  • Features: Marketing landing page, product information

Server (@analytics/server)

  • Technology: Elysia + MongoDB + Mongoose
  • Port: 3001
  • Features: Event collection API, analytics aggregation, real-time data processing

🌐 API Endpoints

Events

  • POST /events - Track events
  • GET /events - Retrieve events with filtering

Analytics

  • GET /analytics/overview - Get analytics overview
  • GET /analytics/events/:eventName - Get analytics for specific event
  • GET /analytics/users/:userId - Get user analytics

Health

  • GET /health - Health check endpoint
  • GET / - API status

πŸ“Š Data Models

Event Schema

{
  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
}

πŸ”§ Development

Working with Individual Packages

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 dev

Adding Dependencies

Use Bun workspaces to add dependencies:

# Add to specific package
bun add <package> --cwd packages/sdk

# Add dev dependency to root
bun add -D <package>

πŸš€ Deployment

Production Setup

  1. Build all packages:
bun run build-console
bun run build-sdk
bun run build-website
  1. Start the server:
bun run start-server

Environment Variables

Server 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

πŸ§ͺ Testing

# Run all tests
bun test

# Run tests for specific package
bun test --cwd packages/sdk

πŸ“ License

MIT License

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

πŸ“ž Support

For support, please open an issue in the GitHub repository.

About

A full monorepo for the analytics solution, which consist of SDK, Console, Apis and website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages