Add comprehensive project documentation for ClinicPro in CLAUDE.md and README.md

- Introduced CLAUDE.md for internal guidance on project structure, commands, and architecture.
- Created README.md with detailed project overview, technology stack, directory structure, setup instructions, API endpoints, authentication flow, and external services.
This commit is contained in:
hamed
2026-06-10 11:12:15 +03:30
parent c7ae591e49
commit e9075e8c92
18 changed files with 3533 additions and 142 deletions
+353 -9
View File
@@ -12,12 +12,14 @@ use App\Doctor\Repository\DoctorRepository;
use App\Shared\Constant\ErrorCodes;
use App\Shared\Controller\BaseController;
use App\Shared\Service\FileValidatorService;
use OpenApi\Attributes as OA;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;
use Symfony\Component\Security\Http\Attribute\IsGranted;
#[OA\Tag(name: 'Doctors')]
class DoctorController extends BaseController
{
public function __construct(
@@ -31,6 +33,51 @@ class DoctorController extends BaseController
// ── Doctor CRUD ───────────────────────────────────────────────────────────
#[OA\Post(
path: '/api/v1/doctor',
summary: 'Create a new doctor profile',
security: [['bearerAuth' => []]],
requestBody: new OA\RequestBody(
required: true,
content: new OA\JsonContent(
required: ['title'],
properties: [
new OA\Property(property: 'title', type: 'string', description: 'Doctor name (also accepted as "name")'),
new OA\Property(property: 'gender', type: 'string', nullable: true),
new OA\Property(property: 'medical_system_code', type: 'string', nullable: true),
new OA\Property(property: 'degree', type: 'string', nullable: true),
new OA\Property(property: 'info', type: 'string', nullable: true),
new OA\Property(
property: 'specialties',
type: 'array',
items: new OA\Items(type: 'integer'),
nullable: true,
),
new OA\Property(
property: 'doctor_services',
type: 'array',
items: new OA\Items(type: 'integer'),
nullable: true,
),
]
)
),
responses: [
new OA\Response(
response: 201,
description: 'Doctor created successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', description: 'Doctor detail object'),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 409, description: 'Doctor profile already exists'),
new OA\Response(response: 422, description: 'Validation error'),
]
)]
#[Route('/api/v1/doctor', methods: ['POST'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function create(Request $request, #[CurrentUser] User $user): JsonResponse
@@ -61,6 +108,26 @@ class DoctorController extends BaseController
return $this->success(['data' => $doctor->toDetailArray()], 201);
}
#[OA\Get(
path: '/api/v1/doctor/{uuid}',
summary: 'Get a doctor by UUID',
parameters: [
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: 200,
description: 'Doctor detail',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', description: 'Doctor detail object'),
]
)
),
new OA\Response(response: 404, description: 'Doctor not found'),
]
)]
#[Route('/api/v1/doctor/{uuid}', methods: ['GET'])]
public function show(string $uuid): JsonResponse
{
@@ -72,6 +139,39 @@ class DoctorController extends BaseController
return $this->success(['data' => $doctor->toDetailArray()]);
}
#[OA\Get(
path: '/api/v1/doctors',
summary: 'List doctors with optional filters (paginated)',
parameters: [
new OA\Parameter(name: 'page', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 1)),
new OA\Parameter(name: 'limit', in: 'query', required: false, schema: new OA\Schema(type: 'integer', default: 20)),
new OA\Parameter(name: 'search', in: 'query', required: false, schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'specialty_id', in: 'query', required: false, schema: new OA\Schema(type: 'integer')),
new OA\Parameter(name: 'city_id', in: 'query', required: false, schema: new OA\Schema(type: 'integer')),
new OA\Parameter(name: 'state_id', in: 'query', required: false, schema: new OA\Schema(type: 'integer')),
],
responses: [
new OA\Response(
response: 200,
description: 'Paginated doctor list',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'array', items: new OA\Items(type: 'object')),
new OA\Property(
property: 'meta',
properties: [
new OA\Property(property: 'totalRecords', type: 'integer'),
new OA\Property(property: 'totalPages', type: 'integer'),
new OA\Property(property: 'currentPage', type: 'integer'),
],
type: 'object'
),
]
)
),
]
)]
#[Route('/api/v1/doctors', methods: ['GET'])]
public function list(Request $request): JsonResponse
{
@@ -86,6 +186,53 @@ class DoctorController extends BaseController
);
}
#[OA\Patch(
path: '/api/v1/doctor/{uuid}',
summary: 'Update a doctor profile',
security: [['bearerAuth' => []]],
requestBody: new OA\RequestBody(
required: false,
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'title', type: 'string', nullable: true),
new OA\Property(property: 'gender', type: 'string', nullable: true),
new OA\Property(property: 'medical_system_code', type: 'string', nullable: true),
new OA\Property(property: 'degree', type: 'string', nullable: true),
new OA\Property(property: 'info', type: 'string', nullable: true),
new OA\Property(
property: 'specialties',
type: 'array',
items: new OA\Items(type: 'integer'),
nullable: true,
),
new OA\Property(
property: 'doctor_services',
type: 'array',
items: new OA\Items(type: 'integer'),
nullable: true,
),
]
)
),
parameters: [
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: 200,
description: 'Doctor updated successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', description: 'Doctor detail object'),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 403, description: 'Forbidden'),
new OA\Response(response: 404, description: 'Doctor not found'),
]
)]
#[Route('/api/v1/doctor/{uuid}', methods: ['PATCH'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function update(string $uuid, Request $request, #[CurrentUser] User $user): JsonResponse
@@ -108,6 +255,31 @@ class DoctorController extends BaseController
return $this->success(['data' => $doctor->toDetailArray()]);
}
#[OA\Delete(
path: '/api/v1/doctor/{uuid}',
summary: 'Delete a doctor (ROLE_ADMIN only)',
security: [['bearerAuth' => []]],
parameters: [
new OA\Parameter(name: 'uuid', in: 'path', required: true, schema: new OA\Schema(type: 'string')),
],
responses: [
new OA\Response(
response: 200,
description: 'Doctor deleted successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', properties: [
new OA\Property(property: 'message', type: 'string'),
]),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 403, description: 'Forbidden — ROLE_ADMIN required'),
new OA\Response(response: 404, description: 'Doctor not found'),
]
)]
#[Route('/api/v1/doctor/{uuid}', methods: ['DELETE'])]
#[IsGranted('ROLE_ADMIN')]
public function delete(string $uuid): JsonResponse
@@ -123,6 +295,52 @@ class DoctorController extends BaseController
// ── File Upload ───────────────────────────────────────────────────────────
#[OA\Post(
path: '/file/upload/clinic_pro/doctor/field_image',
summary: 'Upload a doctor profile image (raw binary)',
security: [['bearerAuth' => []]],
requestBody: new OA\RequestBody(
required: true,
content: new OA\MediaType(
mediaType: 'application/octet-stream',
schema: new OA\Schema(type: 'string', format: 'binary')
)
),
parameters: [
new OA\Parameter(
name: 'Content-Disposition',
in: 'header',
required: true,
description: 'Must include filename, e.g. attachment; filename="photo.jpg"',
schema: new OA\Schema(type: 'string')
),
],
responses: [
new OA\Response(
response: 200,
description: 'File uploaded successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(
property: 'data',
properties: [
new OA\Property(property: 'fid', type: 'integer'),
new OA\Property(property: 'uuid', type: 'string', format: 'uuid'),
new OA\Property(property: 'url', type: 'string'),
new OA\Property(property: 'filename', type: 'string'),
new OA\Property(property: 'filemime', type: 'string'),
new OA\Property(property: 'filesize', type: 'integer'),
],
type: 'object'
),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 422, description: 'Invalid file'),
]
)]
#[Route('/file/upload/clinic_pro/doctor/field_image', methods: ['POST'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function uploadImage(Request $request): JsonResponse
@@ -171,6 +389,39 @@ class DoctorController extends BaseController
// ── Doctor Addresses ──────────────────────────────────────────────────────
#[OA\Post(
path: '/api/v1/clinic-pro/doctor-address',
summary: 'Create a new doctor address',
security: [['bearerAuth' => []]],
requestBody: new OA\RequestBody(
required: false,
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'name', type: 'string', nullable: true),
new OA\Property(property: 'address', type: 'string', nullable: true),
new OA\Property(property: 'telephone', type: 'string', nullable: true),
new OA\Property(property: 'latitude', type: 'number', format: 'float', nullable: true),
new OA\Property(property: 'longitude', type: 'number', format: 'float', nullable: true),
]
)
),
responses: [
new OA\Response(
response: 201,
description: 'Address created successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', description: 'Address object'),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 403, description: 'Forbidden'),
new OA\Response(response: 404, description: 'Doctor not found'),
new OA\Response(response: 422, description: 'Validation error'),
]
)]
#[Route('/api/v1/clinic-pro/doctor-address', methods: ['POST'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function createAddress(Request $request, #[CurrentUser] User $user): JsonResponse
@@ -201,6 +452,28 @@ class DoctorController extends BaseController
return $this->success(['data' => $address->toArray()], 201);
}
#[OA\Get(
path: '/api/v1/clinic-pro/doctor-address/{id}',
summary: 'Get a doctor address by ID',
security: [['bearerAuth' => []]],
parameters: [
new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer')),
],
responses: [
new OA\Response(
response: 200,
description: 'Address detail',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', description: 'Address object'),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 404, description: 'Address not found'),
]
)]
#[Route('/api/v1/clinic-pro/doctor-address/{id}', methods: ['GET'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function showAddress(int $id): JsonResponse
@@ -213,6 +486,41 @@ class DoctorController extends BaseController
return $this->success(['data' => $address->toArray()]);
}
#[OA\Patch(
path: '/api/v1/clinic-pro/doctor-address/{id}',
summary: 'Update a doctor address',
security: [['bearerAuth' => []]],
requestBody: new OA\RequestBody(
required: false,
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'name', type: 'string', nullable: true),
new OA\Property(property: 'address', type: 'string', nullable: true),
new OA\Property(property: 'telephone', type: 'string', nullable: true),
new OA\Property(property: 'latitude', type: 'number', format: 'float', nullable: true),
new OA\Property(property: 'longitude', type: 'number', format: 'float', nullable: true),
]
)
),
parameters: [
new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer')),
],
responses: [
new OA\Response(
response: 200,
description: 'Address updated successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', description: 'Address object'),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 403, description: 'Forbidden'),
new OA\Response(response: 404, description: 'Address not found'),
]
)]
#[Route('/api/v1/clinic-pro/doctor-address/{id}', methods: ['PATCH'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function updateAddress(int $id, Request $request, #[CurrentUser] User $user): JsonResponse
@@ -233,6 +541,31 @@ class DoctorController extends BaseController
return $this->success(['data' => $address->toArray()]);
}
#[OA\Delete(
path: '/api/v1/clinic-pro/doctor-address/{id}',
summary: 'Delete a doctor address',
security: [['bearerAuth' => []]],
parameters: [
new OA\Parameter(name: 'id', in: 'path', required: true, schema: new OA\Schema(type: 'integer')),
],
responses: [
new OA\Response(
response: 200,
description: 'Address deleted successfully',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'object', properties: [
new OA\Property(property: 'message', type: 'string'),
]),
]
)
),
new OA\Response(response: 401, description: 'Unauthorized'),
new OA\Response(response: 403, description: 'Forbidden'),
new OA\Response(response: 404, description: 'Address not found'),
]
)]
#[Route('/api/v1/clinic-pro/doctor-address/{id}', methods: ['DELETE'])]
#[IsGranted('IS_AUTHENTICATED_FULLY')]
public function deleteAddress(int $id, #[CurrentUser] User $user): JsonResponse
@@ -250,6 +583,26 @@ class DoctorController extends BaseController
return $this->success(['message' => 'آدرس با موفقیت حذف شد']);
}
#[OA\Get(
path: '/api/v1/clinic-pro/doctor-addresses/{doctorId}',
summary: 'List all addresses for a doctor',
parameters: [
new OA\Parameter(name: 'doctorId', in: 'path', required: true, schema: new OA\Schema(type: 'integer')),
],
responses: [
new OA\Response(
response: 200,
description: 'Array of address objects',
content: new OA\JsonContent(
properties: [
new OA\Property(property: 'success', type: 'boolean', example: true),
new OA\Property(property: 'data', type: 'array', items: new OA\Items(type: 'object')),
]
)
),
new OA\Response(response: 404, description: 'Doctor not found'),
]
)]
#[Route('/api/v1/clinic-pro/doctor-addresses/{doctorId}', methods: ['GET'])]
public function listAddresses(int $doctorId): JsonResponse
{
@@ -263,15 +616,6 @@ class DoctorController extends BaseController
return $this->success(['data' => $addresses]);
}
// ── Clinic/Doctor list (stub — implemented fully in Task 06) ──────────────
#[Route('/api/v1/clinic/doctor-list/{clinicUuid}', methods: ['GET'])]
public function clinicDoctorList(string $clinicUuid): JsonResponse
{
// Full implementation in Task 06 (Clinic entity not yet created)
return $this->success(['data' => []]);
}
// ── Helpers ───────────────────────────────────────────────────────────────
private function hydrateDoctor(Doctor $doctor, array $data): void