How nahiyanasir/spot_sync works
Spot-sync is a Go REST backend for user authentication, parking-zone availability, and parking/EV-charging reservations. The main workflow is a client request entering the Echo server, passing route middleware where protected, and reaching a domain handler, service, and PostgreSQL-backed repository. Reservation creation checks capacity under a row lock and transaction; zone listings calculate availability from active reservations. The graph follows documented layering and sampled handlers/services/repositories; server wiring and reservation-service internals were not sampled, so uncertain links are omitted.
Main entry points: server.go HTTP server · auth.go Auth middleware · registerRoutes.go User routes · service.go User service
Components 19
API platform
- Application entry
cmd/main.go - Config and DB setup
internal/config - HTTP server
internal/server.go - Auth middleware
internal/middlewares/auth.go
Identity
- JWT service
internal/auth/jwt.go - User routes
internal/user/registerRoutes.go - User handler
internal/user/handler.go - User service
internal/user/service.go - User repository
internal/user/repository.go
Parking zones
- Zone routes
internal/parkingzone/registerRoutes.go - Zone handler
internal/parkingzone/handler.go - Zone service
internal/parkingzone/service.go - Zone repository
internal/parkingzone/repository.go
Reservations
- Reservation routes
internal/reservations/registerRoutes.go - Reservation handler
internal/reservations/handler.go - Reservation service
internal/reservations/service.go - Reservation repository
internal/reservations/repository.go
Other components
- API client
- PostgreSQL
Connections 25
- API client → HTTP server: sends requests
- Application entry → Config and DB setup: loads settings
- Application entry → HTTP server: starts server
- Config and DB setup → PostgreSQL: connects
- HTTP server → User routes: registers routes
- HTTP server → Zone routes: registers routes
- HTTP server → Reservation routes: registers routes
- User routes → User handler: dispatches
- Zone routes → Zone handler: dispatches
- Reservation routes → Reservation handler: dispatches
- User routes → Auth middleware: protects routes
- Zone routes → Auth middleware: protects routes
- Reservation routes → Auth middleware: protects routes
- Auth middleware → JWT service: validates tokens
- User handler → User service: calls
- User service → User repository: queries
- User service → JWT service: generates tokens
- User repository → PostgreSQL: reads and writes
- Zone handler → Zone service: calls
- Zone service → Zone repository: queries
- Zone service → PostgreSQL: counts active bookings
- Zone repository → PostgreSQL: reads and writes
- Reservation handler → Reservation service: calls
- Reservation repository → PostgreSQL: locks and updates
- Reservation service → Reservation repository: uses repository