Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
9 changes: 3 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Variables d'environnement pour Docker Compose (racine du projet).
# Copiez ce fichier vers .env : npm run setup
# Gardez les mêmes valeurs que docker/supabase/.env
# =============================================================================
# Docker Compose racine + Supabase legacy (front/ et back/ Next.js)
# =============================================================================

POSTGRES_PASSWORD=postgres
POSTGRES_PORT=54322
Expand All @@ -9,15 +9,12 @@ KONG_PORT=54321
KONG_ADMIN_PORT=54325
STUDIO_PORT=54323

# JWT Secret (au moins 32 caractères)
JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
JWT_EXPIRY=3600

# Clés API Supabase (doivent correspondre à front/.env.local et back/.env.local)
ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3b3ItdjIiLCJyb2xlIjoiYW5vbiIsImlhdCI6MTYwMDAwMDAwMCwiZXhwIjoyMDAwMDAwMDAwfQ.placeholder-anon-key
SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3b3ItdjIiLCJyb2xlIjoic2VydmljZV9yb2xlIiwiaWF0IjoxNjAwMDAwMDAwMCwiZXhwIjoyMDAwMDAwMDAwfQ.placeholder-service-key

# Auth
SITE_URL=http://localhost:3000
OPERATOR_TOKEN=operator-token
ENABLE_EMAIL_SIGNUP=true
Expand Down
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

CHANGELOG.md export-ignore
README.md export-ignore
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ on:
pull_request:

jobs:
api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: mbstring, pdo_sqlite
coverage: none

- name: Install Composer dependencies
run: composer install -d api --no-interaction --prefer-dist

- name: Run API tests
run: cd api && php artisan test

front:
runs-on: ubuntu-latest
steps:
Expand All @@ -25,5 +42,6 @@ jobs:
- name: Build front
run: npm run build -w front
env:
NEXT_PUBLIC_API_URL: http://localhost:8000
NEXT_PUBLIC_SUPABASE_URL: http://localhost:54321
NEXT_PUBLIC_SUPABASE_ANON_KEY: placeholder-anon-key-for-ci
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,20 @@ docker/supabase/volumes/storage/

# Claude Code (réglages personnels, non partagés)
.claude/settings.local.json

# Laravel (api/)
api/vendor/
api/public/build
api/public/hot
api/public/storage
api/storage/*.key
api/database/database.sqlite
api/bootstrap/cache/*.php
api/.env
api/node_modules/
api/.phpunit.result.cache
/auth.json
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api/resources/js/components/ui/*
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ Site cible : [swor.fr](https://swor.fr)

## Architecture

Monorepo npm avec workspaces :
Monorepo avec **deux applications autonomes** ([ADR 0002](docs/adr/0002-frontend-api-separes.md)) :

```
swor/
├── front/ # Application principale (Next.js, port 3000)
├── back/ # Back-office admin (Next.js, port 3001)
├── supabase/ # Migrations et seeds SQL
└── docker/ # Supabase auto-hébergé, compose racine
├── api/ # Backend Laravel (API JSON + Filament à venir)
├── front/ # Application joueur (Next.js, port 3000)
├── back/ # Back-office legacy (Next.js, port 3001 — remplacé par Filament)
├── supabase/ # Migrations SQL legacy
└── docker/ # Compose (Supabase, services)
```

| Service | Port | Description |
|----------------|-------|--------------------------------------|
| Front | 3000 | Application utilisateur |
| Back-office | 3001 | Interface d’administration |
| Supabase API | 54321 | Kong (REST, Auth, Realtime, Storage) |
| Supabase Studio| 54323 | Interface de gestion de la BDD |
| API Laravel | 8000 | Auth, métier, JSON (`/api/v1/`) |
| Front | 3000 | Application utilisateur (Next.js) |
| Back-office | 3001 | Admin legacy (en cours de remplacement)|
| Supabase API | 54321 | Kong legacy (migration en cours) |
| PostgreSQL | 54322 | Base de données |

Voir [docs/LARAVEL.md](docs/LARAVEL.md) pour le démarrage local API + front.

## Prérequis

- [Node.js](https://nodejs.org/) 20+ (voir `.nvmrc`)
Expand All @@ -58,7 +61,8 @@ Les fichiers d’exemple :

| Fichier | Destination | Usage |
|---------|-------------|-------|
| `.env.example` | `.env` | Docker Compose à la racine |
| `.env.example` | `.env` | Docker Compose racine (Supabase legacy) |
| `api/.env.example` | `api/.env` | API Laravel |
| `docker/supabase/env.example` | `docker/supabase/.env` | Stack Supabase |
| `front/env.local.example` | `front/.env.local` | Application front |
| `back/env.local.example` | `back/.env.local` | Back-office |
Expand Down
38 changes: 38 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# =============================================================================
# Laravel API (voir docs/LARAVEL.md)
# =============================================================================

APP_NAME=Swor
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost:8000
FRONTEND_URL=http://localhost:3000

SANCTUM_STATEFUL_DOMAINS=localhost:3000,localhost:8000,127.0.0.1:3000,127.0.0.1:8000
SESSION_DOMAIN=localhost

APP_LOCALE=fr
APP_FALLBACK_LOCALE=fr
APP_FAKER_LOCALE=fr_FR

LOG_CHANNEL=stack
LOG_LEVEL=debug

# Postgres local — base dédiée Laravel (distincte du schéma Supabase sur `postgres`)
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=54322
DB_DATABASE=swor
DB_USERNAME=postgres
DB_PASSWORD=postgres

SESSION_DRIVER=database
SESSION_LIFETIME=120

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database

VITE_APP_NAME="${APP_NAME}"
57 changes: 57 additions & 0 deletions api/app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Actions\Fortify;

use App\Enums\UserRole;
use App\Models\Profile;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use Laravel\Fortify\Contracts\CreatesNewUsers;

class CreateNewUser implements CreatesNewUsers
{
use PasswordValidationRules;

/**
* Validate and create a newly registered user.
*
* @param array<string, string> $input
*
* @throws ValidationException
*/
public function create(array $input): User
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'username' => ['required', 'string', 'max:255', 'alpha_dash', Rule::unique(Profile::class, 'username')],
'email' => [
'required',
'string',
'email',
'max:255',
Rule::unique(User::class),
],
'password' => $this->passwordRules(),
])->validate();

return DB::transaction(function () use ($input) {
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
]);

Profile::create([
'id' => $user->id,
'username' => $input['username'],
'role' => UserRole::User,
]);

return $user;
});
}
}
19 changes: 19 additions & 0 deletions api/app/Actions/Fortify/PasswordValidationRules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Actions\Fortify;

use Illuminate\Contracts\Validation\Rule;
use Illuminate\Validation\Rules\Password;

trait PasswordValidationRules
{
/**
* Get the validation rules used to validate passwords.
*
* @return array<int, Rule|array<mixed>|string>
*/
protected function passwordRules(): array
{
return ['required', 'string', Password::default(), 'confirmed'];
}
}
32 changes: 32 additions & 0 deletions api/app/Actions/Fortify/ResetUserPassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Actions\Fortify;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use Laravel\Fortify\Contracts\ResetsUserPasswords;

class ResetUserPassword implements ResetsUserPasswords
{
use PasswordValidationRules;

/**
* Validate and reset the user's forgotten password.
*
* @param array<string, string> $input
*
* @throws ValidationException
*/
public function reset(User $user, array $input): void
{
Validator::make($input, [
'password' => $this->passwordRules(),
])->validate();

$user->forceFill([
'password' => Hash::make($input['password']),
])->save();
}
}
35 changes: 35 additions & 0 deletions api/app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Actions\Fortify;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use Laravel\Fortify\Contracts\UpdatesUserPasswords;

class UpdateUserPassword implements UpdatesUserPasswords
{
use PasswordValidationRules;

/**
* Validate and update the user's password.
*
* @param array<string, string> $input
*
* @throws ValidationException
*/
public function update(User $user, array $input): void
{
Validator::make($input, [
'current_password' => ['required', 'string', 'current_password:web'],
'password' => $this->passwordRules(),
], [
'current_password.current_password' => __('The provided password does not match your current password.'),
])->validateWithBag('updatePassword');

$user->forceFill([
'password' => Hash::make($input['password']),
])->save();
}
}
Loading
Loading