How anton-kulchytskyi/car-service-book works
Purpose and Runtime
This is a Next.js App Router application for personal/shared vehicle management: cars, service/expense records, maintenance schedules, ownership transfer, dashboard reporting, profile management, and PDF export. It runs as a TypeScript React server/client application with route handlers under app/api, deployable to Vercel per the base README.
Route and Layout Composition
Locale-prefixed UI routes partition authenticated application screens from authentication screens. Root and locale layouts establish global and localized shells; (app) provides the signed-in area, while (auth) isolates login/register. Primary user entry points include:
• app/[locale]/page.tsx
• app/[locale]/(app)/dashboard/page.tsx
• app/[locale]/(app)/layout.tsx
• app/[locale]/(auth)/login/page.tsx
• app/[locale]/layout.tsx
Internationalization routing/request behavior is centralized in i18n/routing.ts, i18n/request.ts, and locale dictionaries in messages/en.json and messages/uk.json.
Authentication and Session Boundary
Custom API authentication exposes register, login, logout, and current-user endpoints. JWT/password/session utilities provide the security boundary consumed by protected UI and server logic:
• app/api/auth/login/route.ts
• app/api/auth/register/route.ts
• app/api/auth/me/route.ts
• lib/auth/jwt.ts
• lib/auth/session.ts
• proxy.ts
The expected control flow is browser auth form → API route → password/JWT/session handling → protected localized app routes.
Vehicle and Service Domain
Cars are the primary aggregate. Users create, view, edit, delete, transfer, and share/inspect ownership; each car contains maintenance/service records and schedules. UI detail routes model this hierarchy, while REST-style handlers form the mutation/query boundary:
• app/[locale]/(app)/cars/[id]/page.tsx
• app/[locale]/(app)/cars/[id]/records/new/page.tsx
• app/api/cars/[id]/route.ts
• app/api/cars/[id]/transfer/route.ts
• app/api/records/[id]/route.ts
• app/api/cars/[id]/schedules/route.ts
Forms and cards are the main client interaction layer: components/forms/car-form.tsx, components/forms/record-form.tsx, and components/cards/car-card.tsx.
Persistence and Domain Automation
Drizzle ORM defines the relational data model and migration history; database access should flow through the DB module rather than route/UI code owning SQL:
• lib/db/schema.ts
• lib/db/index.ts
• drizzle.config.ts
• drizzle/0005_normal_pixie.sql
Maintenance synchronization is a distinct domain process, likely reconciling schedule state against car records/mileage:
• lib/maintenance-sync.ts
• app/api/schedules/[scheduleId]/route.ts
• components/maintenance-schedules.tsx
Reporting and Document Output
The dashboard aggregates vehicle/service cost information and mileage into visual summaries. PDF export turns car service data into a downloadable report:
• components/charts/cost-by-type-chart-wrapper.tsx
• components/current-mileage.tsx
• components/export-pdf-button.tsx
• components/pdf/car-service-pdf.tsx
• app/[locale]/(app)/dashboard/page.tsx
External Storage and Uploads
Photo/file uploads are mediated by an API route and upload utilities, with Cloudinary as the explicit external media-service integration:
• app/api/upload/route.ts
• lib/cloudinary.ts
• lib/upload-files.ts
• components/photo-upload.tsx
This separates browser file selection from cloud-storage credentials and persistent vehicle/record metadata updates.
Main entry points: [locale]/layout.tsx Locale layout and routes · (app)/layout.tsx Signed-in app shell · route.ts Vehicle and record API · index.ts Drizzle data access
Components 19
Localized UI
Locale-prefixed App Router screens and client components.
- Locale layout and routes · Establishes localized application composition.
app/[locale]/layout.tsx - i18n routing · Resolves locale routing and request translations.
i18n/routing.ts - Login and register
app/[locale]/(auth)/login/page.tsx - Signed-in app shell · Contains authenticated localized screens.
app/[locale]/(app)/layout.tsx - Dashboard reporting · Summarizes vehicle costs and mileage.
app/[locale]/(app)/dashboard/page.tsx - Car and record screens · Vehicle detail and service-record entry hierarchy.
app/[locale]/(app)/cars/[id]/page.tsx - Vehicle interaction components · Car and record forms drive mutations.
components/forms/car-form.tsx - PDF export · Builds downloadable car service reports.
components/pdf/car-service-pdf.tsx - Photo upload component · Selects files in the browser.
components/photo-upload.tsx
Server APIs
Route handlers provide domain and integration boundaries.
- Authentication API · Register, login, logout, and current-user endpoints.
app/api/auth/login/route.ts - Vehicle and record API · Manages cars, transfers, records, and schedules.
app/api/cars/[id]/route.ts - Upload API · Mediates browser file uploads.
app/api/upload/route.ts
Domain Services
Authentication, persistence, and maintenance logic.
- Session protection · Protects localized application routes.
proxy.ts - JWT and session service · Handles passwords, JWTs, and sessions.
lib/auth/session.ts - Drizzle data access · Central relational persistence access.
lib/db/index.ts - Relational schema · Defines vehicle, ownership, record, and schedule data.
lib/db/schema.ts - Maintenance synchronization · Reconciles schedule state with records and mileage.
lib/maintenance-sync.ts
External Services
- Cloudinary · External media storage integration.
Other components
- Next.js App Router · TypeScript React server/client application.
Connections 21
- Next.js App Router → Locale layout and routes: serves
- Locale layout and routes → i18n routing: uses
- Locale layout and routes → Login and register: renders
- Locale layout and routes → Signed-in app shell: renders
- Session protection → Signed-in app shell: protects
- Login and register → Authentication API: auth requests
- Authentication API → JWT and session service: authenticates via
- JWT and session service → Session protection: establishes session
- Signed-in app shell → Dashboard reporting: contains
- Signed-in app shell → Car and record screens: contains
- Dashboard reporting → Vehicle and record API: loads aggregates
- Car and record screens → Vehicle interaction components: uses
- Vehicle interaction components → Vehicle and record API: queries and mutates
- Vehicle and record API → Maintenance synchronization: syncs schedules
- Vehicle and record API → Drizzle data access: persists
- Maintenance synchronization → Drizzle data access: reads and updates
- Drizzle data access → Relational schema: maps data model
- Dashboard reporting → PDF export: exports report
- Photo upload component → Upload API: uploads files
- Upload API → Cloudinary: stores media
- Upload API → Drizzle data access: updates metadata