{"id":39854635,"url":"https://github.com/stepandel/pm-indexer-gamma","last_synced_at":"2026-01-18T13:48:40.108Z","repository":{"id":319190631,"uuid":"1077882115","full_name":"stepandel/pm-indexer-gamma","owner":"stepandel","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-17T22:45:24.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-18T03:43:20.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stepandel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-16T22:04:27.000Z","updated_at":"2025-10-17T22:45:25.000Z","dependencies_parsed_at":"2025-10-18T11:22:36.146Z","dependency_job_id":"9cedd0d2-c6bf-479e-b4ad-41d42a756c20","html_url":"https://github.com/stepandel/pm-indexer-gamma","commit_stats":null,"previous_names":["stepandel/pm-indexer-gamma"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/stepandel/pm-indexer-gamma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepandel%2Fpm-indexer-gamma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepandel%2Fpm-indexer-gamma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepandel%2Fpm-indexer-gamma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepandel%2Fpm-indexer-gamma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stepandel","download_url":"https://codeload.github.com/stepandel/pm-indexer-gamma/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stepandel%2Fpm-indexer-gamma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28536911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T13:04:05.990Z","status":"ssl_error","status_checked_at":"2026-01-18T13:01:44.092Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-18T13:48:40.023Z","updated_at":"2026-01-18T13:48:40.094Z","avatar_url":"https://github.com/stepandel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prediction Markets Monorepo\n\nA TypeScript monorepo for prediction market data processing and analysis. Built with modern tools (pnpm + Turborepo) for scalable multi-platform indexing and future expansion.\n\n## Features\n\n- **🏗️ Monorepo Architecture**: Turborepo + pnpm for optimal developer experience\n- **🚀 Multi-platform Indexing**: Index data from Polymarket and Kalshi\n- **📦 Shared Libraries**: Reusable platform abstractions and utilities\n- **🔄 Database Isolation**: Each platform uses its own database schema\n- **⚡ Fast Builds**: Turborepo caching and parallel execution\n- **🚆 Railway-ready**: Independent deployments per app/platform\n\n## Prerequisites\n\n- **Node.js** 18+\n- **pnpm** 8+ (install with `npm install -g pnpm`)\n\n## Installation\n\n```bash\npnpm install\n```\n\n## Configuration\n\nCopy `.env.example` to `.env` and configure:\n\n```bash\ncp .env.example .env\n```\n\n### Environment Variables\n\n**Platform Selection** (required):\n- `PLATFORM` - Which platform to index (`polymarket` or `kalshi`)\n\n**API Configuration**:\n- `POLYMARKET_API_URL` - Polymarket API endpoint (default: `https://gamma-api.polymarket.com`)\n- `KALSHI_API_URL` - Kalshi API endpoint (default: `https://api.elections.kalshi.com`)\n\n**Database \u0026 Infrastructure**:\n- `DATABASE_URL` - PostgreSQL connection string (required)\n- `LOG_LEVEL` - Logging level (`debug`, `info`, `warn`, `error`)\n- `CRON_SCHEDULE` - Cron schedule for local testing (default: `*/5 * * * *`)\n\n## Development\n\n### Database Setup\n\nStart the development database:\n```bash\npnpm db:setup\n```\n\nRun migrations:\n```bash\npnpm db:migrate:deploy\n```\n\n### Building \u0026 Running\n\nBuild all packages:\n```bash\npnpm build\n```\n\nRun type checking:\n```bash\npnpm typecheck\n```\n\n### Run Apps Locally\n\nRun Polymarket indexer:\n```bash\nPLATFORM=polymarket pnpm --filter @prediction-markets/indexer start\n```\n\nRun Kalshi indexer:\n```bash\nPLATFORM=kalshi pnpm --filter @prediction-markets/indexer start\n```\n\nDevelopment mode (with file watching):\n```bash\npnpm --filter @prediction-markets/indexer dev\n```\n\n## Railway Deployment\n\nThe monorepo supports deploying each app independently to Railway. Each app has its own `railway.json` configuration.\n\n### Indexer App Deployment\n\nDeploy **separate Railway services** for each platform from the same repository:\n\n#### Polymarket Indexer Service\n1. Create a new Railway service\n2. Connect to your GitHub repository\n3. Set Railway configuration to use `apps/indexer/railway.json`\n4. Set environment variables:\n   ```\n   PLATFORM=polymarket\n   DATABASE_URL=\u003cyour-database-url\u003e\n   POLYMARKET_API_URL=https://gamma-api.polymarket.com (optional)\n   LOG_LEVEL=info (optional)\n   ```\n\n#### Kalshi Indexer Service\n1. Create another Railway service\n2. Connect to the same GitHub repository\n3. Set Railway configuration to use `apps/indexer/railway.json`\n4. Set environment variables:\n   ```\n   PLATFORM=kalshi\n   DATABASE_URL=\u003csame-database-url\u003e\n   KALSHI_API_URL=https://api.elections.kalshi.com (optional)\n   LOG_LEVEL=info (optional)\n   ```\n\n### Railway Command\nThe indexer uses this start command in Railway:\n```\npnpm --filter @prediction-markets/indexer start\n```\n\n### Option 2: Single Service with Manual Platform Switch\n\nDeploy one service and manually change the `PLATFORM` environment variable when you want to switch platforms.\n\n### Database Schema\n\nBoth platforms use the same PostgreSQL database with separate schemas:\n- **Polymarket data**: `polymarket` schema (tables: `markets`, `market_events`, `tags`, etc.)\n- **Kalshi data**: `kalshi` schema (tables: `events`, `markets`)\n\n### Benefits of Multi-Service Deployment\n\n- **Independent scaling**: Scale each platform service separately based on data volume\n- **Isolated failures**: If one platform fails, the other continues running\n- **Independent schedules**: Run different cron schedules for each platform\n- **Resource optimization**: Allocate different resources per platform\n\n## Monorepo Structure\n\n```\nprediction-markets-monorepo/\n├── apps/                          # Deployable applications\n│   └── indexer/                   # Multi-platform indexer app\n│       ├── src/\n│       │   └── index.ts           # Entry point with platform selection\n│       ├── package.json           # App-specific dependencies\n│       ├── railway.json           # Railway deployment config\n│       └── tsconfig.json          # App-specific TypeScript config\n│\n├── packages/                      # Shared libraries\n│   ├── shared/                    # Core shared utilities and platform code\n│   │   ├── src/\n│   │   │   ├── lib/               # Shared utilities\n│   │   │   │   ├── database.ts    # Database connection\n│   │   │   │   ├── http-client.ts # HTTP utilities\n│   │   │   │   └── logger.ts      # Logging\n│   │   │   ├── platforms/         # Platform abstractions\n│   │   │   │   ├── base/          # Base interfaces and classes\n│   │   │   │   ├── polymarket/    # Polymarket implementation\n│   │   │   │   ├── kalshi/        # Kalshi implementation\n│   │   │   │   └── platform-registry.ts\n│   │   │   ├── config/            # Configuration management\n│   │   │   └── index.ts           # Barrel exports\n│   │   ├── package.json\n│   │   └── tsconfig.json\n│   │\n│   └── tsconfig/                  # Shared TypeScript configurations\n│       ├── base.json              # Base TypeScript config\n│       ├── node.json              # Node.js specific config\n│       └── package.json\n│\n├── prisma/                        # Database (shared across all apps)\n│   ├── migrations/                # Database migrations\n│   └── schema.prisma             # Multi-platform schema\n│\n├── package.json                   # Root package.json (workspace config)\n├── pnpm-workspace.yaml           # pnpm workspace configuration\n├── turbo.json                     # Turborepo configuration\n├── docker-compose.yml            # Local development database\n└── tsconfig.json                  # Root TypeScript config\n```\n\n## Database Schemas\n\n### Polymarket Schema (`polymarket.*`)\n- `markets` - Market data with pricing and metadata\n- `market_events` - Event data with descriptions and properties\n- `tags` - Categorization tags\n- `market_tags` - Market-to-tag relationships\n- `market_event_tags` - Event-to-tag relationships\n\n### Kalshi Schema (`kalshi.*`)\n- `events` - Event data with tickers and categories\n- `markets` - Market data with pricing and settlement info\n\n## API Integration\n\n### Polymarket\n- **Base URL**: `https://gamma-api.polymarket.com`\n- **Endpoints**: `/markets`, `/events`\n- **Pagination**: Offset-based with batching\n\n### Kalshi\n- **Base URL**: `https://api.elections.kalshi.com`\n- **Endpoints**: `/trade-api/v2/events?with_nested_markets=true`\n- **Pagination**: Cursor-based with 200 items per request\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepandel%2Fpm-indexer-gamma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepandel%2Fpm-indexer-gamma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepandel%2Fpm-indexer-gamma/lists"}