How necipfzlakay/location-logger-api works
Project type and purpose
• This is a backend API built with NestJS.
• It implements a “point-in-polygon” algorithm to tell you whether a given geographic coordinate falls within predefined areas.
• It exposes HTTP endpoints for “areas”, “locations” and “users”.
File structure
• Top-level files: Dockerfile, docker-compose.yml, .env, tsconfig, package.json, locust/locustfile.py, README.md.
• src/ contains a standard NestJS module layout:
• app.controller.ts, app.service.ts, app.module.ts, main.ts
• areas/, locations/, users/ each with controller.ts, service.ts, module.ts, DTOs, and entity definitions.
• common/ holds static GeoJSON files (taksim.json, umraniye.json).
• test/ folder holds end-to-end tests.
README for additional insights
• Uses Docker Compose to spin up:
• logger-api (NestJS @ port 3333)
• Postgres DB + Adminer (@ port 8080)
• Locust load-tester (@ port 8089)
• Local dev via pnpm.
Main components and interactions
a. External Client
• Makes HTTP requests (e.g., via Postman or any HTTP client) to the Logger API.
b. Logger API (NestJS container)
• Controllers (HTTP layer) receive requests.
• Services implement business logic (point-in-polygon, CRUD).
• TypeORM Entities map to DB tables (areas, users, locations).
• common/*.json provide polygon definitions.
c. Database (Postgres container)
• Stores user profiles, location logs, and area records (optional).
• Accessed by the NestJS service via TypeORM.
d. Adminer (Postgres GUI)
• Optional management console.
e. Locust (Load-testing container)
• Simulates load against the Logger API endpoints.
Relationships and data flow
• Client → HTTP → NestJS Controller → NestJS Service
→ (if checking location) load geojson → run point-in-polygon
→ persist or read from Postgres via TypeORM Repository → return HTTP Response.
• NestJS Service ↔ Postgres
• Locust → HTTP → NestJS Controller
• Adminer → DB
Architectural patterns and design principles
• Modular design (areas, locations, users are separate Nest modules).
• Layered architecture (Controller → Service → Repository/Entity).
• Dependency injection (NestJS DI container).
• Infrastructure as code (Dockerfile + docker-compose.yml).
• Test automation (e2e tests + Locust for performance).
Technologies and frameworks
• NestJS (Node.js framework)
• TypeScript
• TypeORM
• Postgres (relational DB) + Adminer
• Docker & Docker Compose
• Locust (Python load testing)
• pnpm (package manager)
• Jest (e2e tests)