-
Clone the repository:
git clone https://github.com/mohammad-md-ahmad/astudio_test.git
-
Install dependencies:
- install kool.dev tool to manage the docker containers
curl -fsSL https://kool.dev/install | bash
- install kool.dev tool to manage the docker containers
-
Set up environment variables:
- Inside the
.env.examplefile in the root directory - Modify the following variables if necessary to set custom ports for the app and db containers:
KOOL_APP_PORT KOOL_DATABASE_PORT - Modify the following variables if necessary to set db connection configs and credentials:
DB_DATABASE DB_USERNAME DB_PASSWORD
- Inside the
-
Start the setup:
kool run setup
-
Start the server:
kool start
-
Create a Laravel Passport client:
kool run artisan passport:client --personal
http://localhost/api
The API uses Laravel Passport for authentication. All endpoints except login and register require authentication using Bearer token.
- Method: POST
- Endpoint:
/register - Description: Register a new user
- Authentication: Not required
- Method: POST
- Endpoint:
/login - Description: Login to get access token
- Authentication: Not required
- Method: POST
- Endpoint:
/logout - Description: Invalidate the current access token
- Authentication: Required
All the following endpoints require authentication with Bearer token.
- Method: GET
- Endpoint:
/users - Description: Retrieve all users
- Authentication: Required
- Method: GET
- Endpoint:
/users/{user} - Description: Retrieve a specific user
- Authentication: Required
- Method: POST
- Endpoint:
/users - Description: Create a new user
- Authentication: Required
- Method: PUT
- Endpoint:
/users/{user} - Description: Update an existing user
- Authentication: Required
- Method: DELETE
- Endpoint:
/users/{user} - Description: Delete a user
- Authentication: Required
- Method: GET
- Endpoint:
/projects - Description: Retrieve all projects
- Authentication: Required
- Method: GET
- Endpoint:
/projects/{project} - Description: Retrieve a specific project
- Authentication: Required
- Method: POST
- Endpoint:
/projects - Description: Create a new project
- Authentication: Required
- Method: PUT
- Endpoint:
/projects/{project} - Description: Update an existing project
- Authentication: Required
- Method: DELETE
- Endpoint:
/projects/{project} - Description: Delete a project
- Authentication: Required
- Method: GET
- Endpoint:
/projects/{project}/users - Description: Get users associated with a specific project
- Authentication: Required
- Method: GET
- Endpoint:
/projects/users - Description: Get all project-user associations
- Authentication: Required
- Method: POST
- Endpoint:
/projects/{project}/users - Description: Associate a user with a project
- Authentication: Required
- Method: DELETE
- Endpoint:
/projects/{project}/users - Description: Remove a user from a project
- Authentication: Required
- Method: GET
- Endpoint:
/timesheets - Description: Retrieve all timesheets
- Authentication: Required
- Method: GET
- Endpoint:
/timesheets/{timesheet} - Description: Retrieve a specific timesheet
- Authentication: Required
- Method: POST
- Endpoint:
/timesheets - Description: Create a new timesheet
- Authentication: Required
- Method: PUT
- Endpoint:
/timesheets/{timesheet} - Description: Update an existing timesheet
- Authentication: Required
- Method: DELETE
- Endpoint:
/timesheets/{timesheet} - Description: Delete a timesheet
- Authentication: Required
- Method: GET
- Endpoint:
/attributes - Description: Retrieve all attributes
- Authentication: Required
- Method: GET
- Endpoint:
/attributes/{attribute} - Description: Retrieve a specific attribute
- Authentication: Required
- Method: POST
- Endpoint:
/attributes - Description: Create a new attribute
- Authentication: Required
- Method: PUT
- Endpoint:
/attributes/{attribute} - Description: Update an existing attribute
- Authentication: Required
- Method: DELETE
- Endpoint:
/attributes/{attribute} - Description: Delete an attribute
- Authentication: Required
Request:
curl -X POST \
'http://localhost/api/login' \
-H 'Content-Type: application/json' \
-d '{
"email": "[email protected]",
"password": "P@$$w0rdrand"
}'Response:
{
"message": "User has been logged in successfully!",
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
"user": {
"id": 1,
"first_name": "Mohammad",
"last_name": "Ahmad",
"email": "[email protected]",
"created_at": "2025-03-16T18:15:54.000000Z",
"updated_at": "2025-03-16T18:17:48.000000Z",
"tokens": [
{
"id": "1c22f0ea0e336c7d87d0064cbedf3546f7eaf29e42ea4160aa98cdb9f957b709db4cd679a49eb82b",
"user_id": 1,
"client_id": 1,
"name": "apiAccessToken",
"scopes": [],
"revoked": true,
"created_at": "2025-03-16T18:32:10.000000Z",
"updated_at": "2025-03-16T19:07:04.000000Z",
"expires_at": "2026-03-16T18:32:10.000000Z"
}
]
}
}
}Request:
curl -X POST \
'http://localhost/api/projects' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"name": "project 4",
"status": "Active"
}'Response:
{
"message": "Project has been created successfully!",
"data": {
"name": "project 4",
"status": "Active",
"updated_at": "2025-03-16T19:09:03.000000Z",
"created_at": "2025-03-16T19:09:03.000000Z",
"id": 6
}
}Use the following test credentials for development and testing purposes:
Test User: [email protected]
Password: P@$$w0rdrand
Note: These credentials are for testing purposes only. In production, use secure credentials and never share API keys publicly.