Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

mateusmlo/plate_manager

Repository files navigation

Plate Manager

A parking management system built with NestJS and MongoDB that tracks vehicle parking entries, payments, and exits.

Features

  • Create parking entries with license plate validation (format: AAA-9999)
  • Track parking payment status
  • Record vehicle exit times
  • View parking history by license plate
  • Dockerized deployment with MongoDB
  • Up and running on Railway with my own custom DNS (proxied via Cloudflare)! Check out the Test the API section below.

Stack

  • Framework: NestJS (Node.js)
  • Database: MongoDB 7
  • Runtime: Node.js 20 (Alpine)
  • Containerization: Docker & Docker Compose

Quick Start (Docker Compose - Recommended)

Prerequisites

  • Docker
  • Docker Compose

Run the Application

  1. Clone the repository.

  2. Start the application with Docker Compose:

docker compose up -d

This will:

  • Build the NestJS application
  • Start MongoDB 7 with health checks
  • Create persistent storage for database
  • Expose the API on port 3000
  1. Verify the services are running:
docker compose ps
  1. Stop the application:
docker compose down
  1. Stop and remove data:
docker compose down -v

API Endpoints

Create Parking Entry

POST /parking
Content-Type: application/json

{
  "plate": "ABC-1234"
}

Response: 201 Created
{
  "parkingId": "695e9e44f6f97a164319c0f6"
}

Get Parking History

GET /parking/:plate

Response: 200 OK
[
  {
    "id": "695e9e44f6f97a164319c0f6",
    "time": "15 minutes",
    "paid": false,
    "left": false
  }
]

Mark as Paid

# use parkingId as param
PUT /parking/:id/pay

Response: 204 No Content

Mark Vehicle Exit

# use parkingId as param
PUT /parking/:id/out

Response: 204 No Content

Testing the API

Example workflow:

DISCLAIMER: since it's a free tier serverless deploy, it may take longer than expected for both the server and database to "wake up" and the first request may timeout. Simply try again if that's the case. If running locally with docker compose this should not happen!

To run on your machine with docker compose, simply change the URLs to http://[::]:3000

# 1. Create a parking entry
curl -X POST https://bocchi.codes/parking \
  -H "Content-Type: application/json" \
  -d '{"plate": "ABC-1234"}'

# 2. Get parking history
curl https://bocchi.codes/parking/ABC-1234

# 3. Mark as paid 
curl -X PUT https://bocchi.codes/parking/ABC-1234/pay

# 4. Mark vehicle exit
curl -X PUT https://bocchi.codes/parking/ABC-1234/out

Additionally, there's a health check route to see services status:

curl https://bocchi.codes/parking/health

# or locally
curl http://[::]:3000/health

Tests

# Unit tests
yarn run test

# Test coverage
yarn run test:cov

Docker Configuration

The application uses a multi-stage Docker build:

  • Builder stage: Compiles TypeScript to JavaScript
  • Production stage: Runs with minimal dependencies (production-only)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors