{"id":32033603,"url":"https://github.com/glinharesb/forgottenserver-graphql-api","last_synced_at":"2026-05-05T17:33:01.190Z","repository":{"id":318569581,"uuid":"1071846045","full_name":"glinharesb/forgottenserver-graphql-api","owner":"glinharesb","description":"Modern GraphQL API for The Forgotten Server v1.4.2 - Built with Go and gqlgen","archived":false,"fork":false,"pushed_at":"2025-10-07T23:25:18.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-28T12:51:25.049Z","etag":null,"topics":["api","forgottenserver","game-server","golang","gqlgen","graphql","graphql-api","mmorpg","mysql","opentibia","otserver","tfs"],"latest_commit_sha":null,"homepage":"","language":"Go","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/glinharesb.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-07T22:31:02.000Z","updated_at":"2025-10-07T23:25:21.000Z","dependencies_parsed_at":"2025-10-08T00:30:51.435Z","dependency_job_id":"d74f5b82-c69f-4eb1-a2b4-395921cd1981","html_url":"https://github.com/glinharesb/forgottenserver-graphql-api","commit_stats":null,"previous_names":["glinharesb/forgottenserver-graphql-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/glinharesb/forgottenserver-graphql-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glinharesb%2Fforgottenserver-graphql-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glinharesb%2Fforgottenserver-graphql-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glinharesb%2Fforgottenserver-graphql-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glinharesb%2Fforgottenserver-graphql-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glinharesb","download_url":"https://codeload.github.com/glinharesb/forgottenserver-graphql-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glinharesb%2Fforgottenserver-graphql-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32660318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"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":["api","forgottenserver","game-server","golang","gqlgen","graphql","graphql-api","mmorpg","mysql","opentibia","otserver","tfs"],"created_at":"2025-10-17T03:29:44.724Z","updated_at":"2026-05-05T17:33:01.185Z","avatar_url":"https://github.com/glinharesb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forgotten Server GraphQL API\n\n[![CI](https://github.com/glinharesb/forgottenserver-graphql-api/workflows/CI/badge.svg)](https://github.com/glinharesb/forgottenserver-graphql-api/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/glinharesb/forgottenserver-graphql-api)](https://goreportcard.com/report/github.com/glinharesb/forgottenserver-graphql-api)\n[![codecov](https://codecov.io/gh/glinharesb/forgottenserver-graphql-api/branch/main/graph/badge.svg)](https://codecov.io/gh/glinharesb/forgottenserver-graphql-api)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/glinharesb/forgottenserver-graphql-api)](https://go.dev/)\n\nA modern, type-safe GraphQL API for [The Forgotten Server (TFS)](https://github.com/otland/forgottenserver), built with Go and gqlgen. This API provides a complete interface for managing accounts, players, guilds, houses, and marketplace operations in your OTServer.\n\n**Compatible with:** [TFS v1.4.2](https://github.com/otland/forgottenserver/tree/v1.4.2)\n\n## Features\n\n- **🔐 Account Management** - Complete CRUD operations for accounts, bans, and storage\n- **👥 Player System** - Player creation, statistics, deaths tracking, and storage management\n- **🏰 Guild System** - Guild management with ranks, memberships, invites, and war tracking\n- **🏠 House Management** - House listings, bidding system, and ownership tracking\n- **💰 Market System** - Marketplace offers and transaction history\n- **🏙️ Town System** - Town management and positioning\n- **✅ Full Test Coverage** - Comprehensive unit tests with mocked database\n- **🚀 Type-Safe** - Generated types and resolvers using gqlgen\n- **📊 GraphQL Playground** - Interactive API exploration and testing\n\n## Tech Stack\n\n- **[Go 1.24+](https://go.dev/)** - Programming language\n- **[gqlgen](https://gqlgen.com/)** - GraphQL server library and code generator\n- **[MySQL](https://www.mysql.com/)** - Database (compatible with TFS schema)\n- **[sqlx](https://github.com/jmoiron/sqlx)** - Enhanced SQL database driver\n- **[Chi](https://github.com/go-chi/chi)** - HTTP router\n- **[go-sqlmock](https://github.com/DATA-DOG/go-sqlmock)** - SQL mock driver for testing\n\n## Prerequisites\n\n- Go 1.24 or higher\n- MySQL 5.7+ or MariaDB 10.2+\n- [The Forgotten Server v1.4.2](https://github.com/otland/forgottenserver/tree/v1.4.2) database schema\n\n## Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/glinharesb/forgottenserver-graphql-api.git\n   cd forgottenserver-graphql-api\n   ```\n\n2. **Install dependencies**\n   ```bash\n   go mod download\n   ```\n\n3. **Set up the database**\n\n   This API requires a TFS v1.4.2 database. Set up your database using the schema from [TFS v1.4.2](https://github.com/otland/forgottenserver/tree/v1.4.2):\n   ```bash\n   mysql -u username -p database_name \u003c forgottenserver/schema.sql\n   ```\n\n4. **Configure environment**\n\n   Copy the example environment file and configure it:\n   ```bash\n   cp .env.example .env\n   ```\n\n   Edit `.env` with your database credentials:\n   ```env\n   DB_HOST=localhost\n   DB_PORT=3306\n   DB_USER=your_username\n   DB_PASSWORD=your_password\n   DB_NAME=your_database\n   SERVER_PORT=8080\n   ```\n\n5. **Run the server**\n   ```bash\n   make run\n   ```\n\n   Or build and run manually:\n   ```bash\n   go build -o server ./cmd/server\n   ./server\n   ```\n\nThe API will be available at `http://localhost:8080/graphql` with an interactive playground at `http://localhost:8080/`\n\n## Project Structure\n\n```\n.\n├── cmd/\n│   └── server/          # Application entry point\n├── internal/\n│   ├── config/          # Configuration management\n│   ├── database/        # Database connection\n│   ├── graph/           # GraphQL schema and resolvers\n│   │   ├── model/       # Generated GraphQL models\n│   │   └── *.graphqls   # GraphQL schema definitions\n│   └── models/          # Business logic and repositories\n│       ├── account.go\n│       ├── player.go\n│       ├── guild.go\n│       ├── house.go\n│       ├── market.go\n│       └── ...\n├── .env.example        # Example environment configuration\n├── gqlgen.yml          # GraphQL code generation config\n├── Makefile            # Build and development commands\n└── README.md\n```\n\n## GraphQL Schema\n\n### Queries\n\n```graphql\ntype Query {\n  # Accounts\n  account(id: ID!): Account\n  accounts(limit: Int = 10): [Account!]!\n\n  # Players\n  player(id: ID!): Player\n  players(accountId: ID!): [Player!]!\n\n  # Guilds\n  guild(id: ID!): Guild\n  guilds: [Guild!]!\n  guildWars(guildId: ID): [GuildWar!]!\n\n  # Houses\n  house(id: ID!): House\n  houses(townId: ID): [House!]!\n\n  # Market\n  marketOffers(itemType: Int): [MarketOffer!]!\n  marketHistory(playerId: ID!): [MarketHistory!]!\n\n  # Towns\n  town(id: ID!): Town\n  towns: [Town!]!\n}\n```\n\n### Mutations\n\n```graphql\ntype Mutation {\n  # Accounts\n  createAccount(input: CreateAccountInput!): Account!\n  banAccount(input: BanAccountInput!): AccountBan!\n\n  # Players\n  createPlayer(input: CreatePlayerInput!): Player!\n\n  # Guilds\n  createGuild(input: CreateGuildInput!): Guild!\n  inviteToGuild(guildId: ID!, playerId: ID!): Boolean!\n  acceptGuildInvite(guildId: ID!, playerId: ID!): Boolean!\n\n  # Houses\n  bidHouse(houseId: ID!, playerId: ID!, bidAmount: Int!): House!\n\n  # Market\n  createMarketOffer(input: CreateMarketOfferInput!): MarketOffer!\n\n  # Towns\n  createTown(input: CreateTownInput!): Town!\n}\n```\n\n## Example Queries\n\n### Get Account with Players\n\n```graphql\nquery GetAccount {\n  account(id: \"1\") {\n    id\n    name\n    email\n    players {\n      id\n      name\n      level\n      vocation\n    }\n  }\n}\n```\n\n### Create New Player\n\n```graphql\nmutation CreatePlayer {\n  createPlayer(input: {\n    name: \"Warrior\"\n    accountId: 1\n    sex: 1\n    vocation: 4\n  }) {\n    id\n    name\n    level\n    health\n    healthMax\n  }\n}\n```\n\n### Get Guild Information\n\n```graphql\nquery GetGuild {\n  guild(id: \"1\") {\n    id\n    name\n    owner {\n      id\n      name\n    }\n    ranks {\n      id\n      name\n      level\n    }\n    members {\n      player {\n        name\n        level\n      }\n      rank {\n        name\n      }\n    }\n  }\n}\n```\n\n### Search Market Offers\n\n```graphql\nquery GetMarketOffers {\n  marketOffers(itemType: 2160) {\n    id\n    player {\n      name\n    }\n    amount\n    price\n    created\n  }\n}\n```\n\n## Development\n\n### Available Make Commands\n\n```bash\nmake build          # Build the application\nmake run            # Run the application\nmake test           # Run all tests\nmake test-coverage  # Run tests with coverage report\nmake generate       # Regenerate GraphQL code\nmake clean          # Clean build artifacts\nmake tidy           # Tidy Go modules\nmake docker-build   # Build Docker image\n```\n\n### Running Tests\n\n```bash\n# Run all tests\nmake test\n\n# Run tests with coverage\nmake test-coverage\n\n# Run tests for specific package\ngo test ./internal/models/...\n```\n\n### Regenerating GraphQL Code\n\nAfter modifying the GraphQL schema (`internal/graph/schema.graphqls`):\n\n```bash\nmake generate\n```\n\nThis will regenerate:\n- Resolver interfaces\n- Model types\n- GraphQL execution code\n\n## Testing\n\nThe project includes comprehensive test coverage with mocked database operations:\n\n- **Model Tests** - Unit tests for all repository methods\n- **Resolver Tests** - Integration tests for GraphQL resolvers\n- **Mock Database** - Using go-sqlmock for isolated testing\n\nExample test output:\n```\n✓ 27 tests in internal/graph\n✓ 30 tests in internal/models\n```\n\n## Database Schema\n\nThe API is compatible with the [TFS v1.4.2](https://github.com/otland/forgottenserver/tree/v1.4.2) database schema. Key tables include:\n\n- `accounts` - User accounts\n- `players` - Player characters\n- `guilds` - Guild information\n- `guild_ranks` - Guild hierarchy\n- `guild_membership` - Player-guild relationships\n- `houses` - House data\n- `market_offers` - Active market listings\n- `market_history` - Completed transactions\n- `towns` - Town locations\n- `player_deaths` - Death history\n\n## Configuration\n\nConfigure the application using environment variables or a `.env` file:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `DB_HOST` | MySQL host | `localhost` |\n| `DB_PORT` | MySQL port | `3306` |\n| `DB_USER` | Database user | `root` |\n| `DB_PASSWORD` | Database password | - |\n| `DB_NAME` | Database name | `forgottenserver` |\n| `SERVER_PORT` | API server port | `8080` |\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n### Development Guidelines\n\n- Write tests for new features\n- Follow Go best practices and conventions\n- Update documentation when adding new queries/mutations\n- Run `make lint` before committing\n- Ensure all tests pass with `make test`\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [The Forgotten Server](https://github.com/otland/forgottenserver) - The OTServer distribution this API is built for\n- [gqlgen](https://gqlgen.com/) - GraphQL library for Go\n- [Open Tibia](https://otland.net/) - Community and resources\n\n## Support\n\n- 📖 [GraphQL Playground](http://localhost:8080/) - Interactive API documentation\n- 🐛 [Issue Tracker](https://github.com/glinharesb/forgottenserver-graphql-api/issues)\n- 💬 [Discussions](https://github.com/glinharesb/forgottenserver-graphql-api/discussions)\n\n---\n\nBuilt with ❤️ for the Open Tibia community\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglinharesb%2Fforgottenserver-graphql-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglinharesb%2Fforgottenserver-graphql-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglinharesb%2Fforgottenserver-graphql-api/lists"}