How du380202/restaurant-api works
This Go service exposes a restaurant API: users register or log in, authenticate requests, then browse and manage restaurants or like and unlike them. Admin and moderator users also have a profile route. The tree shows separate transport, business, and storage layers for users, restaurants, and likes, but their internal calls were not sampled, so those links are omitted. The sampled runtime confirms router dispatch, authentication’s token and user lookup, and PostgreSQL startup; no README was provided.
Main entry points: main.go HTTP server · user_router.go User routes · authenticate.go Authentication · admin_router.go Admin routes
Components 19
API runtime
- HTTP server
cmd/main.go - User routes
cmd/user_router.go - Admin routes
cmd/admin_router.go - App context
component/appctx/app_context.go - Postgres setup
config/db.go
Accounts and security
- Authentication
middleware/authenticate.go - Role checks
middleware/role_require.go - JWT provider
component/tokenprovider/jwt/jwt.go - User storage
internal/user/storage/find.go - User endpoints
internal/user/transport/login.go - User logic
internal/user/biz/login.go
Restaurant management
- Restaurant endpoints
internal/restaurant/transport/ginrestaurant/list_restaurant.go - Restaurant logic
internal/restaurant/biz/list_restaurant.go - Restaurant storage
internal/restaurant/storage/list.go
Restaurant likes
- Like endpoints
internal/restaurantlike/transport/user_like_restaurant.go - Like logic
internal/restaurantlike/biz/user_like_restaurant.go - Like storage
internal/restaurantlike/storage/list.go
Other components
- API client
- PostgreSQL
Connections 17
- API client → HTTP server: sends requests
- HTTP server → Postgres setup: connects
- Postgres setup → PostgreSQL: opens database
- HTTP server → User routes: registers routes
- HTTP server → Admin routes: registers routes
- HTTP server → App context: creates context
- User routes → User endpoints: dispatches
- User routes → Restaurant endpoints: dispatches
- User routes → Like endpoints: dispatches
- User routes → Authentication: protects routes
- Admin routes → User endpoints: dispatches profile
- Admin routes → Authentication: requires authentication
- Admin routes → Role checks: checks roles
- Authentication → App context: gets database and secret
- Authentication → JWT provider: validates token
- Authentication → User storage: finds user
- Like storage → PostgreSQL: queries