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 apps/backend/.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

[compose.yaml]
indent_size = 4
65 changes: 65 additions & 0 deletions apps/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mariadb
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=backend
DB_USERNAME=root
DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
# CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
11 changes: 11 additions & 0 deletions apps/backend/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

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

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
24 changes: 24 additions & 0 deletions apps/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db
1 change: 0 additions & 1 deletion apps/backend/README.md
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
Here will be the backend
94 changes: 94 additions & 0 deletions apps/backend/app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Auth;
use Tymon\JWTAuth\Facades\JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;

class AuthController extends Controller
{
public function register(Request $request)
{
$request->validate([
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);

$user = User::create([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);

try {
$token = JWTAuth::fromUser($user);
} catch (JWTException $e) {
return response()->json(['error' => 'Could not create token'], 500);
}

return response()->json([
'token' => $token,
'user' => $user,
], 201);
}

public function login(Request $request)
{
$credentials = $request->only('email', 'password');

try {
if (!$token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'Invalid credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'Could not create token'], 500);
}

return response()->json([
'token' => $token,
'expires_in' => auth('api')->factory()->getTTL() * 60,
]);
}

public function logout()
{
try {
JWTAuth::invalidate(JWTAuth::getToken());
} catch (JWTException $e) {
return response()->json(['error' => 'Failed to logout, please try again'], 500);
}

return response()->json(['message' => 'Successfully logged out']);
}

public function getUser()
{
try {
$user = Auth::user();
if (!$user) {
return response()->json(['error' => 'User not found'], 404);
}
return response()->json($user);
} catch (JWTException $e) {
return response()->json(['error' => 'Failed to fetch user profile'], 500);
}
}

public function updateUser(Request $request)
{
try {
$user = Auth::user();
$user->update($request->only(['first_name', 'last_name', 'email']));
return response()->json($user);
} catch (JWTException $e) {
return response()->json(['error' => 'Failed to update user'], 500);
}
}
}
8 changes: 8 additions & 0 deletions apps/backend/app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Http\Controllers;

abstract class Controller
{
//
}
22 changes: 22 additions & 0 deletions apps/backend/app/Http/Middleware/JwtMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Tymon\JWTAuth\Facades\JWTAuth;
use Exception;
use Illuminate\Http\Request;

class JwtMiddleware
{
public function handle(Request $request, Closure $next)
{
try {
JWTAuth::parseToken()->authenticate();
} catch (Exception $e) {
return response()->json(['error' => 'Unauthorized'], 401);
}

return $next($request);
}
}
21 changes: 21 additions & 0 deletions apps/backend/app/Models/AiRating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class AiRating extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $aiRating) {
if (empty($aiRating->id)) {
$aiRating->id = (string) Str::uuid();
}
});
}
}
20 changes: 20 additions & 0 deletions apps/backend/app/Models/Chapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Chapter extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $chapter) {
if (empty($chapter->id)) {
$chapter->id = (string) Str::uuid();
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for Str class. Add use Illuminate\Support\Str; at the top of the file.

Copilot uses AI. Check for mistakes.
}
});
}
}
20 changes: 20 additions & 0 deletions apps/backend/app/Models/Criterion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Criterion extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $criterion) {
if (empty($criterion->id)) {
$criterion->id = (string) Str::uuid();
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for Str class. Add use Illuminate\Support\Str; at the top of the file.

Copilot uses AI. Check for mistakes.
}
});
}
}
20 changes: 20 additions & 0 deletions apps/backend/app/Models/Glossary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Glossary extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $glossary) {
if (empty($glossary->id)) {
$glossary->id = (string) Str::uuid();
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for Str class. Add use Illuminate\Support\Str; at the top of the file.

Copilot uses AI. Check for mistakes.
}
});
}
}
20 changes: 20 additions & 0 deletions apps/backend/app/Models/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Image extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $image) {
if (empty($image->id)) {
$image->id = (string) Str::uuid();
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for Str class. Add use Illuminate\Support\Str; at the top of the file.

Copilot uses AI. Check for mistakes.
}
});
}
}
20 changes: 20 additions & 0 deletions apps/backend/app/Models/Project.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Project extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $project) {
if (empty($project->id)) {
$project->id = (string) Str::uuid();
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for Str class. Add use Illuminate\Support\Str; at the top of the file.

Copilot uses AI. Check for mistakes.
}
});
}
}
20 changes: 20 additions & 0 deletions apps/backend/app/Models/Section.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Section extends Model
{
protected $keyType = 'string';
public $incrementing = false;

protected static function booted()
{
static::creating(function (self $section) {
if (empty($section->id)) {
$section->id = (string) Str::uuid();
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement for Str class. Add use Illuminate\Support\Str; at the top of the file.

Copilot uses AI. Check for mistakes.
}
});
}
}
Loading
Loading