Backend take-home tasks usually ask for a small REST API with CRUD and authentication, for example "a notes or products API where users can only manage their own records". Examples here use Laravel, but the checklist applies to Node.js/Express, Django or any other stack.
What reviewers actually check#
- Correct HTTP methods and status codes.
- Validation with helpful error messages.
- Authentication and authorisation (users cannot touch other users' data).
- Clean structure: thin controllers, no business logic in routes.
- Tests for the main flows.
- A README that lets them run everything quickly, plus a live URL if possible.
Step 1: Design the endpoints first#
Write the API contract before coding and put it in the README:
| Method | Endpoint | Auth | Description | Success |
|---|---|---|---|---|
| POST | /api/register | no | create an account, return a token | 201 |
| POST | /api/login | no | return a token | 200 |
| POST | /api/logout | yes | revoke the current token | 204 |
| GET | /api/notes | yes | list my notes (paginated) | 200 |
| POST | /api/notes | yes | create a note | 201 |
| GET | /api/notes/{id} | yes | show one of my notes | 200 |
| PATCH | /api/notes/{id} | yes | update one of my notes | 200 |
| DELETE | /api/notes/{id} | yes | delete one of my notes | 204 |
Use a consistent JSON shape, and return 401 (not logged in), 403 (not your note), 404 (not found) and 422 (validation) correctly.
Step 2: Folder structure#
app/
├── Http/
│ ├── Controllers/Api/
│ │ ├── AuthController.php
│ │ └── NoteController.php
│ ├── Requests/
│ │ ├── StoreNoteRequest.php
│ │ └── UpdateNoteRequest.php
│ └── Resources/
│ └── NoteResource.php
├── Models/
│ ├── Note.php
│ └── User.php
└── Policies/
└── NotePolicy.php
database/
├── factories/NoteFactory.php
└── migrations/xxxx_create_notes_table.php
routes/api.php
tests/Feature/
├── AuthTest.php
└── NoteTest.phpStep 3: Validation, authorisation and resources#
class StoreNoteRequest extends FormRequest
{
public function rules(): array
{
return [
'title' => ['required', 'string', 'max:150'],
'body' => ['nullable', 'string', 'max:5000'],
];
}
}
class NoteController extends Controller
{
public function store(StoreNoteRequest $request): NoteResource
{
$note = $request->user()->notes()->create($request->validated());
return new NoteResource($note); // 201 Created for a new model
}
public function update(UpdateNoteRequest $request, Note $note): NoteResource
{
$this->authorize('update', $note); // NotePolicy: $user->id === $note->user_id
$note->update($request->validated());
return new NoteResource($note);
}
}- Use API Resources so you never leak fields such as passwords or internal flags.
- Use a Policy for ownership checks instead of
ifstatements in every method. - Paginate lists:
NoteResource::collection($request->user()->notes()->latest()->paginate(15)).
Step 4: Authentication#
Use the framework's standard tool: Laravel Sanctum tokens ($user->createToken('api')->plainTextToken), or JWT/sessions in other stacks. Hash passwords (Hash::make / bcrypt), never return them, and rate-limit the login route (throttle:5,1).
Step 5: Tests for the main flows#
it('does not let a user update someone else\'s note', function () {
$owner = User::factory()->create();
$note = Note::factory()->for($owner)->create();
Sanctum::actingAs(User::factory()->create());
$this->patchJson("/api/notes/{$note->id}", ['title' => 'Hacked'])
->assertForbidden();
});
it('validates the title', function () {
Sanctum::actingAs(User::factory()->create());
$this->postJson('/api/notes', ['title' => ''])
->assertUnprocessable()
->assertJsonValidationErrors('title');
});Cover at least: register/login, guests get 401, create/list/update/delete, validation errors and the ownership rule.
Step 6: Commits#
chore: install Laravel and Sanctum
feat: register, login and logout endpoints
feat: notes CRUD with validation and resources
feat: restrict notes to their owner with a policy
test: auth and notes feature tests
docs: README with endpoints and setupStep 7: README template#
# Notes API
Live API: https://notes-api.onrender.com/api
Postman collection: docs/notes.postman_collection.json
## Run locally
```bash
cp .env.example .env
composer install
php artisan key:generate
php artisan migrate --seed
php artisan serve
php artisan test
```
Demo user: demo@example.com / password
## Endpoints
(table from Step 1)
## Decisions and trade-offs
- Sanctum tokens because the brief mentions a mobile client.
- Soft deletes not added: not required by the brief.
## What I would add with more time
- Search and tags
- API documentation with OpenAPIStep 8: Deploy checklist (Render)#
- Push to GitHub and create a Web Service on Render from the repository (Docker or a PHP build), plus a managed database (or any free MySQL/PostgreSQL host).
- Set the environment variables:
APP_KEY,APP_ENV=production,APP_DEBUG=false,DB_*. - Run
php artisan migrate --forceas part of the deploy (a release or start command). - Test every endpoint against the live URL with Postman, including a
401and a422case. - Free instances sleep when idle, so mention in your email that the first request can take up to a minute.
Never commit .env or real credentials, and make sure APP_DEBUG is false in production so stack traces are not exposed.
Step 9: Submit#
Send the repository link, live URL, Postman collection and demo credentials in one short email, before the deadline. List any assumptions and known limitations in the README.