Skip to content
qsontPublic

About

πŸ“¦ Containerized CRUD app

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Customer Records CRUD App

Overview

A full-stack CRUD application for managing customer records, built for a technical assessment project. It allows creating, viewing, updating, and deleting customer records, with fast full-text search powered by Elasticsearch.

The backend is containerized with Docker Compose and consists of 4 services:

  • api β€” Laravel backend handling all business logic and CRUD operations
  • controller β€” Nginx, acting as the load balancer in front of the API
  • database β€” PostgreSQL, the primary data store for customer records
  • searcher β€” Elasticsearch, a searchable mirror of customer data kept in sync automatically whenever a record is created, updated, or deleted

Whenever a customer record changes in PostgreSQL, an Eloquent model observer automatically pushes that change to Elasticsearch via Laravel's built-in HTTP client β€” no third-party sync package (e.g. Laravel Scout) is used.

The React frontend runs separately from Docker and talks to the backend over HTTP.


Prerequisites

Before starting, make sure you have the following installed:

  • Docker Desktop (includes Docker Compose, because that's more convenient)
  • Node.js (v18 or later recommended) and npm (I personally used pnpm), for running Vite + React

PHP, Composer, and Postgres all run inside Docker.


1. Clone the repository

git clone <this-repository-url>
cd tech-crud

2. Set up environment variables

Copy the example environment file for the backend:

cp api/.env.example api/.env

The Docker Compose file already injects the correct database and Elasticsearch connection values (host, port, credentials) into the api container at runtime, so the defaults in api/.env for those specific keys will be overridden automatically β€” no manual editing required to get the app running locally.


3. Build and start the backend services

From the project root (where docker-compose.yml lives):

docker compose up -d --build

This builds the api image and starts all four services: api, controller, database, and searcher.

Check that everything is running:

docker compose ps

All four containers should show as Up.


4. Run database migrations

docker compose exec api php artisan migrate

This creates the customers table in PostgreSQL.

(Optional) Seed some sample data for manual testing:

docker compose exec api php artisan tinker
App\Models\Customer::factory()->count(10)->create();

5. Verify the backend is working

  • Visit http://localhost:8080 in your browser β€” you should see Laravel's default response, confirming Nginx, PHP-FPM, and Laravel are wired up correctly.
  • Test the API directly:
    curl http://localhost:8080/api/customers
  • Verify Elasticsearch is reachable:
    curl http://localhost:9200

6. Run the backend test suite

docker compose exec api php artisan test

This runs the full PHPUnit feature test suite against an isolated in-memory SQLite database, covering all CRUD endpoints and validation rules.


7. Run the frontend

The frontend is not containerized and runs directly on your machine, separately from Docker.

cd frontend
npm install
npm run dev

By default, the frontend expects the API to be reachable at http://localhost:8080/api (the address exposed by the controller service above). If your setup uses a different port, update the API base URL in the frontend's API client configuration accordingly.

Once running, open the local dev server URL shown in your terminal (typically http://localhost:5173) to use the app.


Shutting everything down

docker compose down

Add -v if you also want to remove the Postgres and Elasticsearch data volumes and start completely fresh next time:

docker compose down -v

Project Structure

.
β”œβ”€β”€ api/                  # Laravel backend
β”œβ”€β”€ frontend/             # React frontend (run separately, not containerized)
β”œβ”€β”€ docker/
β”‚   └── nginx/
β”‚       └── default.conf  # Nginx config for the controller service
β”œβ”€β”€ docker-compose.yml
└── README.md

About

πŸ“¦ Containerized CRUD app

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages