{"id":50736934,"url":"https://github.com/ali-haggag7/logic-arena","last_synced_at":"2026-06-10T15:00:27.237Z","repository":{"id":349427579,"uuid":"1202070308","full_name":"Ali-Haggag7/logic-arena","owner":"Ali-Haggag7","description":"⚔️ Logic Arena — Competitive real-time robot battle simulator. Program your robot using AliScript, a custom scripting language, and fight in 3D arenas. Built with Next.js, NestJS, and React Three Fiber.","archived":false,"fork":false,"pushed_at":"2026-06-04T21:01:24.000Z","size":10868,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T23:03:10.854Z","etag":null,"topics":["game","monorepo","nestjs","nextjs","pnpm","programming-game","react-three-fiber","robotics","typescript","websocket"],"latest_commit_sha":null,"homepage":"https://logicarena.dev","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/Ali-Haggag7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-05T14:58:28.000Z","updated_at":"2026-06-04T21:01:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3092883-18d8-4e86-9dc4-c8a47827f83e","html_url":"https://github.com/Ali-Haggag7/logic-arena","commit_stats":null,"previous_names":["ali-haggag7/logic-arena"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ali-Haggag7/logic-arena","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ali-Haggag7%2Flogic-arena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ali-Haggag7%2Flogic-arena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ali-Haggag7%2Flogic-arena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ali-Haggag7%2Flogic-arena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ali-Haggag7","download_url":"https://codeload.github.com/Ali-Haggag7/logic-arena/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ali-Haggag7%2Flogic-arena/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34157453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["game","monorepo","nestjs","nextjs","pnpm","programming-game","react-three-fiber","robotics","typescript","websocket"],"created_at":"2026-06-10T15:00:18.565Z","updated_at":"2026-06-10T15:00:27.212Z","avatar_url":"https://github.com/Ali-Haggag7.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n```\n██╗      ██████╗  ██████╗ ██╗ ██████╗     █████╗ ██████╗ ███████╗███╗   ██╗ █████╗\n██║     ██╔═══██╗██╔════╝ ██║██╔════╝    ██╔══██╗██╔══██╗██╔════╝████╗  ██║██╔══██╗\n██║     ██║   ██║██║  ███╗██║██║         ███████║██████╔╝█████╗  ██╔██╗ ██║███████║\n██║     ██║   ██║██║   ██║██║██║         ██╔══██║██╔══██╗██╔══╝  ██║╚██╗██║██╔══██║\n███████╗╚██████╔╝╚██████╔╝██║╚██████╗    ██║  ██║██║  ██║███████╗██║ ╚████║██║  ██║\n╚══════╝ ╚═════╝  ╚═════╝ ╚═╝ ╚═════╝    ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝\n```\n\n**v3.4.0 | Program your robot. Outsmart your opponent. Dominate the arena.**\n\n[![TypeScript](https://img.shields.io/badge/TypeScript-97.5%25-3178C6?style=flat-square\u0026logo=typescript)](https://www.typescriptlang.org/)\n[![Next.js](https://img.shields.io/badge/Next.js-16-black?style=flat-square\u0026logo=next.js)](https://nextjs.org/)\n[![NestJS](https://img.shields.io/badge/NestJS-11-E0234E?style=flat-square\u0026logo=nestjs)](https://nestjs.com/)\n[![Three.js](https://img.shields.io/badge/Three.js-r3f-black?style=flat-square\u0026logo=three.js)](https://threejs.org/)\n[![Prisma](https://img.shields.io/badge/Prisma-ORM-2D3748?style=flat-square\u0026logo=prisma)](https://www.prisma.io/)\n[![Socket.io](https://img.shields.io/badge/Socket.io-Realtime-010101?style=flat-square\u0026logo=socket.io)](https://socket.io/)\n[![PWA](https://img.shields.io/badge/PWA-Ready-5A0FC8?style=flat-square\u0026logo=pwa)](https://logicarena.dev)\n[![Docker](https://img.shields.io/badge/Docker-Containerized-2496ED?style=flat-square\u0026logo=docker)](https://www.docker.com/)\n[![Live](https://img.shields.io/badge/Live-logicarena.dev-22d3ee?style=flat-square\u0026logo=vercel)](https://logicarena.dev)\n\n[**Live Demo (v3.4.0)**](https://logicarena.dev) · [**Documentation**](#project-documentation) · [**Report Bug**](https://github.com/Ali-Haggag7/logic-arena/issues)\n\n\u003c/div\u003e\n\n---\n\n## What is Logic Arena?\n\nLogic Arena is a **competitive coding platform** where developers write scripts in **AliScript** — a custom domain-specific language — to control autonomous robots that battle in a physics-driven 3D arena. Think LeetCode meets StarCraft.\n\n\u003e *\"The best robot isn't the fastest — it's the most intelligent.\"*\n\nUnlike traditional games, **you don't play Logic Arena with a keyboard or a gamepad**. You program your robot's behavior before the match, and watch your logic execute in real-time against opponents. Every win is a proof of your algorithmic thinking.\n\n---\n\n## ✨ Core Features\n\n### 🤖 AliScript v3 — Custom Combat Language\nWrite robot behavior scripts using Logic Arena's custom language. Supports **Dictionaries, State Machines, Dot Notation**, advanced sensory arrays, and **Swarm Intelligence** via a secure broadcast protocol. Strict server-side execution sandboxing limits script size, logic timeouts (TLE quotas), whitelisted commands, and applies execution rate limiting. Mobile players can use the intuitive **Block Editor** to drag and drop logic instead of typing code.\n\n### ⚡ Real-Time Physics, FOV, and Super Powers\nFeatures vector-based physics, collision detection, and projectile simulations running at 20 ticks/second. Robots possess an FOV (Field of View) and SCAN system tracking 15-degree rotation behavior. Equip **Tactical Super Powers** like SHIELD, CLOAK, DASH, TELEPORT, MINE, or TAUNT to turn the tide. All tactical choices consume points through a robust Energy \u0026 STASIS system.\n\n### 🎮 3D Arena Renderer \u0026 Garage\nThe battle arena is rendered in **Three.js / React Three Fiber** — a full 3D environment with dynamic lighting, obstacle geometry, AAA robot meshes, and particle effects synchronized via **Socket.io**. Unlock and equip unique custom robot chassis models in the **Garage**.\n\n### 💼 Economy \u0026 Black Market\nEarn progression through battles and campaigns, and spend your currency in the **Black Market (Vault)** to unlock custom paints, premium tracer rounds, and elite chassis models. Equip items using a high-fidelity 3D interactive viewer.\n\n### 🏆 Global Leaderboard \u0026 Spectator Mode\nWatch top-tier players clash in real time. The **Spectator Mode** features a zero-payload overhead architecture allowing users to securely \"watch\" live matches directly from the Global Leaderboard, complete with live viewer counts.\n\n### 🌍 Diverse Game Modes\n- **COMBAT**: The classic deathmatch (1v1, FFA).\n- **CAPTURE**: Area control mechanics for tactical positioning.\n- **SURVIVAL**: Endless waves of obstacles and NPC enemies.\n- **RACING**: Waypoint checkpoint navigation.\n- **CAMPAIGN**: Algorithmic Warfare challenges against pre-programmed boss bots.\n\n### 🛡️ Enterprise-Grade Security\nBuilt with a 4-Layer security architecture:\n1. **Perimeter:** HttpOnly Cookies, Redis global \u0026 route-specific rate limiting (300 req/min for Admin, 60 req/min for Public).\n2. **Database:** Prisma ORM payload protection and sanitization.\n3. **Execution:** AliScript AST Sandbox hardening \u0026 memory TLE quotas.\n4. **Frontend:** React XSS DOM protection.\n\n### 📱 PWA Support \u0026 Multi-Theme System\nToggle between Cyberpunk, Light, and Obsidian Ember themes. Fully Progressive Web App support ensures it's installable locally with offline pages, safe-area mapping, and a frictionless mobile-first dashboard experience featuring an exclusive Drag-and-Drop Block IDE.\n\n### 📊 Admin Command Center\nA comprehensive dashboard featuring live KPI cards, data tables, memory gauges, and charts for User and Match analytics, alongside a full Community Feedback workflow hub.\n\n---\n\n## 🏗️ Architecture\n\nLogic Arena is a **pnpm monorepo** with distinct decoupled packages:\n\n```text\nlogic-arena/\n├── apps/\n│   ├── client/          # Next.js 16 — Frontend (App Router, PWA)\n│   └── server/          # NestJS 11 — Backend API + WebSocket\n└── packages/\n    ├── engine/          # Shared Game Engine (TypeScript, 20 TPS Physics)\n    └── logic-parser/    # AST Parser \u0026 AliScript Evaluator + Block Compiler\n```\n\n### Data Flow\n\n```text\n[Player writes AliScript v3 (Text or Blocks)] \n        ↓\n[Client sends script via API payload]\n        ↓\n[Server parses \u0026 evaluates AST securely in Sandbox]\n        ↓\n[Game Engine: physics tick every 50ms (20 ticks/sec)]\n        ↓\n[State delta broadcast to Match Room + Spectators]\n        ↓\n[React Three Fiber renders the frame using Interpolation]\n        ↓\n[Snapshot saved to database / Redis every tick]\n```\n\n### Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| Frontend | Next.js 16, React Three Fiber, Framer Motion, TailwindCSS, @dnd-kit |\n| Backend | NestJS 11, Socket.io, JWT Auth, Cloudinary (Avatars), Nodemailer |\n| Production / Scaling | Docker + Nginx, Redis (Upstash) for presence + rate limiting |\n| Packages / Engine | Custom typescript physics engine, AST logic-parser |\n| Database | PostgreSQL + Prisma ORM |\n| PWA Integration | Service Worker, webmanifest |\n| Monorepo | pnpm workspaces |\n\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n- Node.js 18+\n- pnpm 8+\n- PostgreSQL database\n- Redis instance\n\n### Installation\n\n```bash\n# Clone the repo\ngit clone https://github.com/Ali-Haggag7/logic-arena.git\ncd logic-arena\n\n# Install all dependencies\npnpm install\n\n# Set up environment variables\ncp apps/server/.env.example apps/server/.env\n# Fill in DATABASE_URL, DIRECT_URL, JWT_SECRET, REDIS_URL, CLOUDINARY keys\n```\n\n### Database \u0026 Redis Setup\n\n```bash\ncd apps/server\nnpx prisma db push\nnpx prisma generate\n\n# Ensure your Redis instance is ready and accessible based on your REDIS_URL\n```\n\n### Running the Project\n\n```bash\n# Start the full stack development environment synchronously\npnpm run dev:all\n```\n\nOpen [http://localhost:3000](http://localhost:3000) — register an account and enter the arena.\n\n---\n\n## 🎮 How to Play\n\n1. **Register** an account and log in.\n2. Go to **Lobby** and challenge an opponent or join the **Campaign**.\n3. Open the **Script Console** inside the arena (use the Block Editor on mobile!).\n4. Write your AliScript strategy:\n\n```text\nIF GET_DISTANCE(ENEMY) \u003c 400\n  FIRE\nEND\nMOVE_FAST\n```\n\n5. Hit **EXECUTE** — your robot follows your logic in real-time.\n6. Check the **Leaderboard** to track your global ranking and combat analytics.\n\n---\n\n## 📜 AliScript v3 Reference\n\n| Category | Commands / Operators |\n|----------|-------------|\n| **Movement** | `MOVE`, `MOVE_FAST`, `BACKUP`, `STOP`, `PATHFIND` |\n| **Actions** | `FIRE`, `BURST_FIRE`, `SCAN`, `WAIT` |\n| **Abilities**| `USE_SHIELD`, `USE_CLOAK`, `USE_DASH`, `USE_TELEPORT`, `USE_MINE`, `USE_TAUNT` |\n| **Variables/Data** | `SET`, Dictionaries (`state.mode = \"attack\"`), Arrays |\n| **Control Flow** | `IF` / `ELSE` / `END`, `WHILE` / `DO` / `END`, `FOR` |\n| **Logic/Operators** | `AND`, `OR`, `NOT`, `!=`, `\u003c=`, `\u003e=`, parentheses grouping |\n| **Sensing** | `GET_DISTANCE()`, `GET_HEALTH()`, `GET_ENERGY()`, `RAYCAST()` |\n| **Functions** | `FUNCTION`, `CALL` |\n| **Swarm/Comms** | `BROADCAST`, `RECEIVE` |\n\n---\n\n## 📁 Project Documentation\n\n| Document | Description |\n|----------|-------------|\n| [System Architecture](./docs/system-architecture.md) | Data flow, backend services, security model |\n| [Script Sandboxing](./docs/script-sandboxing.md) | Server-side AST script isolation \u0026 TLE quotas |\n| [ERD Diagram](./docs/erd-diagram.md) | Full PostgreSQL database schema |\n| [Game Rules](./docs/game-rules.md) | Physics, combat, abilities, modes, Energy system |\n| [Folder Structure](./docs/folder-structure.md) | Monorepo layout and architectural conventions |\n| [AliScript Language](./docs/aliscript-language.md) | Complete language syntax and reference guide |\n| [Rotation System Guide](./docs/rotation-system-guide.md) | Deep dive into robot FOV and scanner mechanics |\n\n---\n\n## 🗺️ Roadmap Progress\n\n- [x] Custom AliScript language engine (v3)\n- [x] Real-time multiplayer with Socket.io\n- [x] 3D arena renderer (Three.js / R3F)\n- [x] OAuth + JWT authentication system\n- [x] Match history, Radar charts \u0026 Combat Analytics\n- [x] Match replay system (2D Canvas)\n- [x] Tournament bracket system\n- [x] Dictionaries, Arrays, State Machines \u0026 Functions\n- [x] Swarm Intelligence (Broadcast protocol)\n- [x] Black Market \u0026 Economy System\n- [x] Robot Garage (Custom AAA 3D Models)\n- [x] Docker + Redis for production scale\n- [x] Live Spectator Mode \u0026 Viewer counts\n- [x] PWA support \u0026 Mobile-first Block Editor dashboard\n- [x] LeetCode-style Campaign Mode\n- [x] Dynamic Game Modes (RACING, CAPTURE, SURVIVAL)\n- [x] Tactical Super Powers\n- [x] Admin Command Center \u0026 Throttling\n- [x] 4-Layer Architecture Security Hardening\n- [ ] Fog of War\n- [ ] University competition launch\n- [ ] Multi-team bracket stress testing\n\n---\n\u003cdiv align=\"center\"\u003e\n\n## 👨‍💻 Author\n\n**Ali Haggag** — Computer Science Student, building the future of competitive programming education.\n\n[![GitHub](https://img.shields.io/badge/GitHub-Ali--Haggag7-181717?style=flat-square\u0026logo=github)](https://github.com/Ali-Haggag7)\n[![Gmail](https://img.shields.io/badge/Gmail-Ali--Haggag7-red?style=flat-square\u0026logo=gmail)](mailto:ali.haggag2005@gmail.com)\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-Ali--Haggag7-0077B5?style=flat-square\u0026logo=linkedin)](https://www.linkedin.com/in/ali-haggag7/)\n[![Portfolio](https://img.shields.io/badge/Portfolio-Ali--Haggag7-180d2f?style=flat-square\u0026logo=portfolio)](https://alihaggag.me/)\n\n---\n\n**Logic Arena** — *Where code becomes combat.*\n\n⭐ Star this repo if it impressed you\n\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fali-haggag7%2Flogic-arena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fali-haggag7%2Flogic-arena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fali-haggag7%2Flogic-arena/lists"}