https://github.com/mvreisg/gamebase-backend
RESTful backend for managing a game database, built with modern PHP practices and a DDD-inspired structure.
https://github.com/mvreisg/gamebase-backend
apache api aws composer defuse docker jwt nginx phinx php php-di phpunit predis psr restful slim-framework sodium web
Last synced: 2 months ago
JSON representation
RESTful backend for managing a game database, built with modern PHP practices and a DDD-inspired structure.
- Host: GitHub
- URL: https://github.com/mvreisg/gamebase-backend
- Owner: mvreisg
- License: gpl-3.0
- Created: 2025-01-18T21:05:23.000Z (over 1 year ago)
- Default Branch: dev
- Last Pushed: 2026-04-04T16:35:35.000Z (2 months ago)
- Last Synced: 2026-04-04T19:26:57.263Z (2 months ago)
- Topics: apache, api, aws, composer, defuse, docker, jwt, nginx, phinx, php, php-di, phpunit, predis, psr, restful, slim-framework, sodium, web
- Language: PHP
- Homepage:
- Size: 1.25 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gamebase-Backend
RESTful backend for managing a game database, built with modern PHP practices and a DDD-inspired structure.
This project is designed as a study and portfolio application focusing on:
- Layered architecture
- Secure authentication and encryption
- Containerized development
- Scalable environment configuration
---
## Features
- REST API
- JWT Authentication
- Redis caching
- Database migrations with Phinx
- Encryption (Sodium / Defuse)
- Docker-first development
- Unit testing with PHPUnit
- Environment variables with Dotenv
---
## Tech Stack
- PHP 8.4
- Nginx
- Slim Framework
- PHP-DI
- MariaDB
- Redis
- Docker
- Composer
- PHPUnit
- Phinx
- Dotenv
---
## Project Architecture
The project loosely follows DDD principles:
- **Domain**
- **Application**
- **Infrastructure**
- **Presentation**
---
## Project Status
🚧 Active development.
---
## License
GPL-3.0
---
### Documentation
🚧 *In the future with Swagger*
---
## Running the project
### 1. Environment Configuration
The project uses layered environment files:
```
.env
.env.{environment}.{machine}
```
Example `.env` to run with `Docker` under `development` environment:
```
.env.development.docker
```
Copy all keys from `.env.example` into your environment file and fill in the values.
*The `docker-compose.development.up` and `docker-compose.development.down` scripts are available to ease the `Docker` setup.*
---
### 2. Environment Variables
#### Timezone
```
TIME_ZONE="America/Sao_Paulo"
```
#### Nginx
```
NGINX_PORT="80"
NGINX_EXPOSE_PORT="8081"
```
`NGINX_PORT`: internal container port
`NGINX_EXPOSE_PORT`: host port mapped to container
#### API Consumers
```
API_CONSUMERS_ADDRESSES="http://localhost:8082,http://localhost:8083"
API_CONSUMERS_ADDRESSES_SEPARATOR=","
```
#### Repository (Database)
```
REPOSITORY_ROOT_USERNAME="backend_root"
REPOSITORY_ROOT_PASSWORD="secret"
REPOSITORY_HOST="database"
REPOSITORY_DATABASE="gamebase"
REPOSITORY_USERNAME="user"
REPOSITORY_PASSWORD="password"
REPOSITORY_PORT="3306"
REPOSITORY_CHARSET="utf8mb4"
REPOSITORY_EXPOSE_PORT="3307"
```
#### Encryption Keys
You may keep the default values, but generating your own keys is recommended.
Access:
```
http://localhost:${NGINX_EXPOSE_PORT}/pages/index.php
```
Then click on:
- `Get PHP Defuse Encryption Key`
- `Get Sodium Encryption Key`
Copy the values into:
```
DEFUSE_PHP_ENCRYPTION_KEY=
SODIUM_CRYPTO_SECRETBOX_KEY=
```
⚠️ Keep both values secret (even if unused).
#### JWT Secret
```
JWT_SECRET="your-secret-key"
```
#### Redis
```
REDIS_SCHEME=redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_EXPOSE_PORT=6380
```
---
### 3. Create the Database
Access
```
http://localhost:{$NGINX_EXPOSE_PORT}/pages/index.php
```
Steps:
1. Click on **PDO Database → Create**
2. Verify the database was created
3. Click on **Phinx Startup**
4. Ensure the status is **OK**
---
### Composer Commands
All commands are defined in the `scripts` section of `composer.json`.
---
*Made with ❤️ by Marcus Vinicius Reis Gonçalves*