{"id":28023813,"url":"https://github.com/samuelrubiodev/active-case-server","last_synced_at":"2026-04-02T18:52:48.194Z","repository":{"id":288451737,"uuid":"967762429","full_name":"samuelrubiodev/active-case-server","owner":"samuelrubiodev","description":"Backend server for the Active Case game","archived":false,"fork":false,"pushed_at":"2025-05-04T13:02:39.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T01:34:16.361Z","etag":null,"topics":["ai","express","expressjs","js","openrouter","postgresql","rest-api","server","supabase","unity"],"latest_commit_sha":null,"homepage":"https://github.com/samuelrubiodev/CasoAbierto","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelrubiodev.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}},"created_at":"2025-04-17T00:54:16.000Z","updated_at":"2025-05-04T13:02:42.000Z","dependencies_parsed_at":"2025-04-18T06:20:22.100Z","dependency_job_id":"9555cb08-5746-48f9-80f2-0f25cc6db0cf","html_url":"https://github.com/samuelrubiodev/active-case-server","commit_stats":null,"previous_names":["samuelrubiodev/active-case-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samuelrubiodev/active-case-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelrubiodev%2Factive-case-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelrubiodev%2Factive-case-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelrubiodev%2Factive-case-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelrubiodev%2Factive-case-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelrubiodev","download_url":"https://codeload.github.com/samuelrubiodev/active-case-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelrubiodev%2Factive-case-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263083592,"owners_count":23411163,"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","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":["ai","express","expressjs","js","openrouter","postgresql","rest-api","server","supabase","unity"],"created_at":"2025-05-11T01:28:46.239Z","updated_at":"2025-12-30T22:19:22.677Z","avatar_url":"https://github.com/samuelrubiodev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕵️‍♂️ Active Case Server\n\nThis is the backend for Caso Abierto, a police‑investigation game built in Unity. It generates AI‑powered cases, stores them in PostgreSQL, generates representative images, and exposes a REST API for the game client.\nFull project (Unity + this server): [CasoAbierto](https://github.com/samuelrubiodev/CasoAbierto)\n\n---\n\n## 🚀 What it does\n\n- **Generate new cases** via OpenRouter\n- **Persist cases** (players, evidence, timeline, characters) in PostgreSQL  \n- **Generate case images** via Together AI and store the binary in the database  \n- **Serve images** on demand as `image/png`  \n- **Expose** API endpoints for Unity (or any HTTP client) to create and fetch data\n\n---\n\n## 📦 Technologies\n\n- **Node.js** + **Express** for the HTTP server  \n- **postgres** (npm package) for PostgreSQL queries  \n- **OpenRouter** for AI text generation  \n- **Together AI** for image generation  \n\n---\n\n## ⚙️ Installation\n\n1. **Clone** this repo  \n   ```bash\n   git clone https://github.com/samuelrubiodev/active-case-server.git\n   cd active‑case‑server\n2. **Install dependencies**\n   ```bash\n   npm install\n3. **Copy environment file**\n   ```bash\n   cp .env.example .env.local\n4. **Edit** `.env.local` **with your keys and database URL**\n   ```dotenv\n    DATABASE_URL=postgres://user:pass@host:port/db\n    DATABASE_URL= # For example: postgresql://postgres:password@localhost:5432/mydb\n    OPENROUTER_API= # For get API key, visit https://openrouter.ai/settings/keys\n    OPENROUTER_URL=https://openrouter.ai/api/v1\n    OPENROUTER_MODEL=google/gemini-2.0-flash-001\n    TOGETHER_API= # For get API key, visit https://together.xyz\n    IMAGE_MODEL_FREE=black-forest-labs/FLUX.1-schnell-Free\n5. **In supabase go into your project and execute these lines of code from the [database](./database.sql) file**\n5. **Start the server**\n     ```bash\n     npm run devStart\n  The API will listen on port 3001 by default (configurable in src/server/server.js).\n\n---\n\n## API Endpoints\n\n1. ### Case routes\n\n| Method | Path | Description |\n|--------|------|-------------| \n| POST   | `/case/new`| Generate a new AI case, persist it (without image and case data) and return `{caseID}` \n| POST   | `/case/:ID`| Fetch all data for case `ID` (player, evidence, timeline, characters, etc.)\n| GET    | `/case/:ID/image` |  The image of case in binary (`image/png`)\n\n2. ### Player routes\n\n| Method | Path | Description |\n|--------|------|-------------| \n| GET    | `/players/:playerID/case`| Get all cases for player `playerID` \n| GET   | `/players/new`| Create a new player (returns new ID)\n\n## 🤝 Contributing\n\nFeel free to open issues or pull requests — any improvements to schema validation, error‑handling, or performance optimizations are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelrubiodev%2Factive-case-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelrubiodev%2Factive-case-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelrubiodev%2Factive-case-server/lists"}