How habibi-source/ostore-service-api works
This is a Gin-based online-store API. Clients register or log in, then use public catalog and region endpoints or authenticated profile, store, address, and transaction endpoints; administrators can manage categories. Handlers pass work to use cases, which are wired to repositories at startup. Authentication validates JWTs and loads users, while repositories use MySQL; region repositories provide a separate external-data branch. The README is empty, and most handler, use-case, and repository implementations were not sampled, so those links reflect explicit startup wiring and the repository structure rather than unsampled internal call details.
Main entry points: main.go Gin API · user_repository.go User repository · auth_usecase.go Authentication · user_usecase.go User services
Components 25
API and access
- Gin API
cmd/api/main.go - Auth middleware
internal/middleware/auth_middleware.go
Store commerce
- Store endpoints
internal/handler/store_handler.go - Store services
internal/usecase/store_usecase.go - Address endpoints
internal/handler/address_handler.go - Address services
internal/usecase/address_usecase.go - Category endpoints
internal/handler/category_handler.go - Category services
internal/usecase/category_usecase.go - Product endpoints
internal/handler/product_handler.go - Product services
internal/usecase/product_usecase.go - Transaction endpoints
internal/handler/transaction_handler.go - Transaction services
internal/usecase/transaction_usecase.go - Region endpoints
internal/handler/region_handler.go - Region services
internal/usecase/region_usecase.go
Identity and accounts
- Auth endpoints
internal/handler/auth_handler.go - Authentication
internal/usecase/auth_usecase.go - User endpoints
internal/handler/user_handler.go - User services
internal/usecase/user_usecase.go
Data and integrations
- User repository
internal/repository/user_repository.go - Store repository
internal/repository/store_repository.go - Region API repositories
internal/repository - MySQL database
pkg/database/mysql.go - JWT utility
pkg/jwt/jwt.go
Other components
- API client
- Region data service
Connections 34
- API client → Gin API: sends requests
- Gin API → Auth endpoints: routes auth
- Gin API → User endpoints: routes user
- Gin API → Store endpoints: routes stores
- Gin API → Address endpoints: routes addresses
- Gin API → Category endpoints: routes categories
- Gin API → Product endpoints: routes products
- Gin API → Transaction endpoints: routes transactions
- Gin API → Region endpoints: routes regions
- Gin API → Auth middleware: protects routes
- Auth endpoints → Authentication: invokes
- Auth endpoints → User services: creates default store
- Authentication → User repository: checks and saves users
- Authentication → Store repository: creates default store
- Authentication → JWT utility: generates tokens
- Auth middleware → JWT utility: validates tokens
- Auth middleware → User repository: loads user
- User endpoints → User services: invokes
- User services → User repository: uses
- User services → Store repository: uses
- Store endpoints → Store services: invokes
- Store services → Store repository: uses
- Address endpoints → Address services: invokes
- Address services → User repository: uses
- Category endpoints → Category services: invokes
- Product endpoints → Product services: invokes
- Transaction endpoints → Transaction services: invokes
- Region endpoints → Region services: invokes
- Region services → Region API repositories: uses
- Region data service → Region API repositories: provides region data
- Store repository → MySQL database: reads and writes
- User repository → MySQL database: reads and writes
- Product services → MySQL database: persists products
- Transaction services → MySQL database: persists transactions