{"id":31729740,"url":"https://github.com/nntin/d-back","last_synced_at":"2025-10-09T07:16:15.261Z","repository":{"id":315745161,"uuid":"1058878849","full_name":"NNTin/d-back","owner":"NNTin","description":"An ambient life simulation driven by (mock) user activity within a(n imaginary) Discord server http://hermes.nntin.xyz/dzone/","archived":false,"fork":false,"pushed_at":"2025-10-05T18:25:47.000Z","size":143,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-05T18:50:55.774Z","etag":null,"topics":["allure","discord","hacktoberfest","python","vercel","websockets"],"latest_commit_sha":null,"homepage":"https://d-back.vercel.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NNTin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-09-17T17:10:54.000Z","updated_at":"2025-10-05T18:25:50.000Z","dependencies_parsed_at":"2025-09-20T13:25:25.617Z","dependency_job_id":"d48f13e0-e3fa-426d-a81d-57fd041fd784","html_url":"https://github.com/NNTin/d-back","commit_stats":null,"previous_names":["nntin/d-back"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/NNTin/d-back","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NNTin%2Fd-back","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NNTin%2Fd-back/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NNTin%2Fd-back/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NNTin%2Fd-back/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NNTin","download_url":"https://codeload.github.com/NNTin/d-back/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NNTin%2Fd-back/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000989,"owners_count":26082972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["allure","discord","hacktoberfest","python","vercel","websockets"],"created_at":"2025-10-09T07:16:11.064Z","updated_at":"2025-10-09T07:16:15.253Z","avatar_url":"https://github.com/NNTin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# d-back  \n\n![Last Commit](https://img.shields.io/github/last-commit/NNTin/d-back) \n![Open Pull Requests](https://img.shields.io/github/issues-pr/NNTin/d-back)\n![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)\n![Stars](https://img.shields.io/github/stars/NNTin/d-back)\n![Contributors](https://img.shields.io/github/contributors/NNTin/d-back)\n![Build Status](https://github.com/NNTin/d-back/actions/workflows/test.yml/badge.svg)\n![PyPI](https://img.shields.io/pypi/v/d-back)\n\n\n\nWelcome to **d-back** – the backend service that powers the magical **d-zone** ambient life simulation!\n\n## 🎯 Project Overview\n\n**d-zone** is an ambient life simulation where the presence and activity of users in a Discord server subtly influence a living digital environment. Think of it as a digital terrarium that reacts to your community's energy!\n\n**d-back** serves as the intelligent bridge between Discord servers and the beautiful [d-zone frontend](https://nntin.github.io/d-zone/).  \nIt provides real-time user data through WebSocket connections, creating an immersive experience where every Discord user becomes part of a living, breathing digital ecosystem.\n\nCurrently, d-back uses sophisticated mock data to simulate user activity, making it perfect for development, testing, and demonstration purposes.\n\n## ✨ Features\n\n- 🔌 **WebSocket Server**: Real-time communication with the d-zone frontend\n- 👥 **User Activity Simulation**: Mock Discord user data with realistic presence states\n- 🎨 **Role Color Support**: Beautiful user representation with Discord role colors  \n- 🌐 **Multi-Server Support**: Handle multiple Discord servers simultaneously\n- 📊 **Status Tracking**: Monitor online, idle, DND, and offline user states\n- 🔒 **OAuth2 Ready**: Built-in support for Discord OAuth2 authentication\n- 📁 **Static File Serving**: Serve frontend assets directly from the backend\n- 🚀 **Easy Configuration**: Simple command-line options and programmatic setup\n- 🧪 **Development Friendly**: Comprehensive mock data for testing and development\n\n## 🛠️ Installation\n\n### Step-by-Step Setup\n\n1. **Clone the repository:**\n   ```bash\n   git clone https://github.com/NNTin/d-back.git\n   cd d-back\n   ```\n\n2. **Create a virtual environment (recommended):**\n   ```bash\n   # On Windows\n   python -m venv .venv\n   .venv\\Scripts\\activate\n\n   # On macOS/Linux  \n   python3 -m venv .venv\n   source .venv/bin/activate\n   ```\n\n3. **Install the package:**\n   ```bash\n   # Install in development mode (recommended for contributors)\n   pip install -e .\n\n   # Or install directly from requirements\n   pip install -r requirements.txt\n   ```\n\n4. **Verify installation:**\n   ```bash\n   d_back --version\n   ```\n\n## 🚀 Usage\n\n### Quick Start\n\nThe simplest way to get d-back running:\n\n```bash\n# Start the server with default settings (localhost:3000)\nd_back\n\n# Or run as a Python module\npython -m d_back\n```\n\n### Command Line Options\n\n```bash\n# Custom host and port\nd_back --host 0.0.0.0 --port 8080\n\n# Serve custom static files\nd_back --static-dir ./my-frontend-build\n\n# Get help\nd_back --help\n```\n\n### Programmatic Usage\n\nUse d-back in your Python projects:\n\n```python\nimport asyncio\nfrom d_back.server import WebSocketServer\n\nasync def main():\n    # Create server instance\n    server = WebSocketServer(port=3000, host=\"localhost\")\n    \n    # Optional: Set up custom callbacks\n    server.on_get_user_data = my_user_data_callback\n    server.on_get_server_data = my_server_data_callback\n    \n    # Start the server\n    print(\"Starting d-back server...\")\n    await server.start()\n\n# Run the server\nasyncio.run(main())\n```\n\n### Testing the WebSocket Connection\n\nYou can test the server using any WebSocket client:\n\n```javascript\n// JavaScript example for testing\nconst socket = new WebSocket('ws://localhost:3000');\n\nsocket.onopen = () =\u003e {\n    console.log('Connected to d-back!');\n    // Request user data for a mock server\n    socket.send(JSON.stringify({\n        type: 'get_user_data',\n        serverId: '232769614004748288'\n    }));\n};\n\nsocket.onmessage = (event) =\u003e {\n    const data = JSON.parse(event.data);\n    console.log('Received:', data);\n};\n```\n\n## ⚙️ Configuration\n\n### Command Line Arguments\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `--port` | `3000` | Port to run the WebSocket server on |\n| `--host` | `localhost` | Host to bind the server to |\n| `--static-dir` | Built-in | Directory to serve static files from |\n| `--version` | - | Show version information |\n\n### Mock Server Configuration\n\nd-back comes with pre-configured mock Discord servers for testing:\n\n- **D-World Server** (`232769614004748288`): Main development server with active users\n- **Docs Server** (`482241773318701056`): Documentation server  \n- **OAuth2 Server** (`123456789012345678`): Protected server for OAuth testing\n- **My Repos Server** (`987654321098765432`): Repository showcase server\n\n### Environment Variables\n\nWhile d-back doesn't currently use environment variables for configuration, you can extend it easily:\n\n```python\nimport os\nfrom d_back.server import WebSocketServer\n\n# Example: Use environment variables\nport = int(os.getenv('D_BACK_PORT', 3000))\nhost = os.getenv('D_BACK_HOST', 'localhost')\n\nserver = WebSocketServer(port=port, host=host)\n```\n\n### Custom Data Providers\n\nReplace mock data with your own:\n\n```python\nfrom d_back.server import WebSocketServer\n\nasync def my_user_data_provider(server_id):\n    # Your custom logic here\n    return {\n        \"user123\": {\n            \"uid\": \"user123\",\n            \"username\": \"MyUser\",\n            \"status\": \"online\",\n            \"roleColor\": \"#ff6b6b\"\n        }\n    }\n\nserver = WebSocketServer()\nserver.on_get_user_data = my_user_data_provider\n```\n\n## 📜 License\n\nThis project is licensed under the MIT License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnntin%2Fd-back","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnntin%2Fd-back","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnntin%2Fd-back/lists"}