How aamir-sufiyan-n/hoodhire works
1. What this repo is
HoodHire is a Go backend for a job marketplace with separate user flows for seekers, hirers, and admins. The architecture is organized as a Clean Architecture / layered system, with HTTP handling, business logic, persistence, and shared utilities kept apart.
2. Application entry and bootstrap
cmd/main.go is the executable entrypoint. It likely wires together configuration, database connections, Redis, the Fiber HTTP app, routes, and middleware via internal/app/app.go. The boot layer is split from the domain logic so the rest of the code stays framework-agnostic where possible.
3. Main request flow
Requests enter Fiber, pass through middleware, then hit controllers, which delegate to services, which call repositories for persistence. The repositories talk to PostgreSQL through GORM. Redis is a secondary store for short-lived or fast-changing data like OTPs and feature/config state.
4. Domain-driven module split
The backend is organized by business capability rather than by technical concern:
- authentication
- seekers
- hirers/business profiles
- jobs
- bonds/applications
- follows/reviews
- subscriptions
- tickets/support
- roles/permissions
- web configuration
Each of these has its own controller, service, and repository files, which makes the architecture easy to map into bounded subsystems.
5. Identity and auth subsystem
Authentication is built around user plus role-specific profiles. The utils/jwt.go, utils/bcrypt.go, utils/cookie.go, and internal/Controllers/authController.go / internal/Services/authServices.go files show the main auth flow:
- registration and login
- OTP verification via Redis TTL
- password hashing with bcrypt
- JWT access/refresh tokens stored in cookies
Middleware (authMiddleware.go, roleMiddleware.go, blockedMiddleware.go) enforces identity and account state before controllers run.
6. Profile separation: seeker vs hirer
The models under structures/models/seeker.go, hirer.go, and user.go indicate a base identity model with extended profile records. This supports different registration and profile-update flows for seekers and hirers, while keeping shared identity fields centralized in users.
7. Marketplace core: jobs, applications, and bonds
The most important business flow is job discovery and application. jobControllers.go, jobServices.go, and jobRepoes.go manage job CRUD and search/filtering. The bond subsystem (bondController.go, bondServices.go, bondRepo.go) appears to represent a confirmed hire or trusted relationship. That bond is the privacy boundary: contact details are only revealed once a bond exists.
8. Admin, RBAC, and feature gating
Admin functionality is separated into its own routes and controllers (adminRoutes.go, roleControllers.go, webConfig.go, etc.). Permissions are not hardcoded; they are data-driven through roles and permission tables, with permissionMiddleware.go checking access per request. A separate web-config subsystem lets admins toggle platform features such as registration, job posting, applying, and chat without redeploying.
9. Payments and subscriptions
Subscription logic lives in the subscription controller/service/repository trio and integrates with Razorpay. That subsystem handles plan purchase, payment verification, and activation of hirer benefits like verification and higher job limits. The utils/crone.go file and README indicate scheduled expiry/reminder handling, so subscription state is time-driven as well as event-driven.
10. Secondary engagement features
Follow/favorite/review behavior is handled as its own capability (follow.go, followReviewRepo.go). Support tickets are another independent workflow (ticketContoller.go, ticketServices.go, ticketRepo.go) for user-to-admin issue escalation. These are separate from hiring flow, but they reuse the same account and permission infrastructure.
11. External integrations
The backend depends on a few infrastructure services that materially shape the architecture:
- PostgreSQL for durable relational data
- Redis for OTP/session-like short-lived state
- Cloudinary for media and resume storage
- SMTP mail delivery through utils/mail.go
- Razorpay for subscription payments
- cron scheduling for expiry/reminder jobs
- PDF generation/export utilities in utils/pdf.go
12. Data modeling boundary
The structures/Dto folder defines transport objects for request/response shaping, while structures/models holds persistence models. That separation suggests the API does not expose database entities directly; controllers likely bind DTOs, services transform them, and repositories persist model objects.
13. Infrastructure and runtime shape
The repo is a single Go backend service, container-friendly and likely configured via environment files. The README mentions a separate chat/WebSocket service, but in this repository the visible code is the main API and its supporting domain modules. From an architecture diagram perspective, this repo should be drawn as one primary HTTP API service with PostgreSQL and Redis dependencies, plus external integrations for email, storage, and payments.
Main entry points: userRoutes.go User Routes · app.go App Wire-up · authServices.go Auth Service · user.go Models
Components 34
Bootstrap
Process entrypoint and application wiring.
- Main · Executable entrypoint for the backend service.
cmd/main.go - App Wire-up · Assembles config, database, redis, routes, and middleware.
internal/app/app.go
API Layer
HTTP handling, middleware, and routing.
- User Routes · Public and authenticated user-facing route registration.
internal/routes/userRoutes.go - Admin Routes · Admin route registration and protected admin surfaces.
internal/routes/adminRoutes.go - Auth Guard · Validates identity before protected handlers run.
internal/middlewares/authMiddleware.go - Role Guard · Checks user role constraints for requests.
internal/middlewares/roleMiddleware.go - Permission Guard · Enforces permission-based access control.
internal/middlewares/permissionMiddleware.go - Block Guard · Stops blocked or inactive accounts from proceeding.
internal/middlewares/blockedMiddleware.go
Domain Modules
Business capabilities organized by bounded context.
- Auth · Login, registration, OTP, and token handling.
internal/Controllers/authController.go - Jobs · Job CRUD, discovery, and filtering endpoints.
internal/Controllers/jobControllers.go - Bonds · Hire-confirmation and trusted relationship endpoints.
internal/Controllers/bondController.go - Seekers · Seeker profile and account flows.
internal/Controllers/seekerController.go - Hirers · Hirer profile and business account flows.
internal/Controllers/hirerController.go - Subscriptions · Plan purchase, verification, and activation endpoints.
internal/Controllers/subscription.go - Tickets · Support ticket and escalation endpoints.
internal/Controllers/ticketContoller.go - RBAC · Roles, permissions, and admin control endpoints.
internal/Controllers/roleControllers.go - Web Config · Feature gating and platform configuration endpoints.
internal/Controllers/webConfig.go - Auth Service · Coordinates login, OTP, token, and account flows.
internal/Services/authServices.go - Job Service · Implements job discovery and posting logic.
internal/Services/jobServices.go - Bond Service · Manages relationship state that unlocks private contact access.
internal/Services/bondServices.go - Subscription Service · Handles plans, payment confirmation, and expiry state.
internal/Services/subscription.go
Data and Integrations
Persistence models, DTOs, and external service adapters.
- Auth Repo · Persists users, credentials, and auth-related state.
internal/Repositories/authRepos.go - Job Repo · Persists job records and search data.
internal/Repositories/jobRepoes.go - Bond Repo · Persists hire bonds and relationship records.
internal/Repositories/bondRepo.go - Subscription Repo · Persists subscription plans, purchases, and status.
internal/Repositories/subscriptionRepo.go - DTOs · Request and response shaping objects.
structures/Dto/authDto.go - Models · Persistence entities for users, jobs, bonds, and related records.
structures/models/user.go - Postgres · Primary relational datastore accessed through GORM.
database/db.go - Redis · Short-lived state for OTPs and other ephemeral data.
config/redis.go - Cloudinary · Media and resume storage integration.
utils/cloudinary.go - Mail · SMTP-based notification delivery.
utils/mail.go - Razorpay · External payment provider for subscriptions.
internal/Services/subscription.go - JWT Utils · Token creation and verification helpers.
utils/jwt.go - Hashing · Password hashing helpers.
utils/bcrypt.go
Connections 41
- Main → App Wire-up: starts · Main launches application wiring.
- App Wire-up → User Routes: registers · Bootstraps user-facing routes.
- App Wire-up → Admin Routes: registers · Bootstraps admin routes.
- App Wire-up → Auth Guard: uses · Installs authentication middleware.
- App Wire-up → Role Guard: uses · Installs role middleware.
- App Wire-up → Permission Guard: uses · Installs permission middleware.
- App Wire-up → Block Guard: uses · Installs account-state middleware.
- User Routes → Auth: dispatches · Routes direct requests to auth handlers.
- User Routes → Jobs: dispatches · Routes direct requests to job handlers.
- User Routes → Bonds: dispatches · Routes direct requests to bond handlers.
- User Routes → Seekers: dispatches · Routes direct requests to seeker handlers.
- User Routes → Hirers: dispatches · Routes direct requests to hirer handlers.
- User Routes → Subscriptions: dispatches · Routes direct requests to subscription handlers.
- User Routes → Tickets: dispatches · Routes direct requests to support handlers.
- Admin Routes → RBAC: dispatches · Routes direct requests to RBAC handlers.
- Admin Routes → Web Config: dispatches · Routes direct requests to web-config handlers.
- Auth → Auth Service: delegates · Controllers defer business logic to services.
- Jobs → Job Service: delegates · Controllers defer business logic to services.
- Bonds → Bond Service: delegates · Controllers defer business logic to services.
- Subscriptions → Subscription Service: delegates · Controllers defer business logic to services.
- Auth Service → Auth Repo: persists · Service reads and writes auth-related data.
- Job Service → Job Repo: persists · Service reads and writes job data.
- Bond Service → Bond Repo: persists · Service reads and writes bond data.
- Subscription Service → Subscription Repo: persists · Service reads and writes subscription data.
- Auth → DTOs: binds · Controllers accept shaped request/response payloads.
- Jobs → DTOs: binds · Controllers accept shaped request/response payloads.
- Auth Repo → Models: stores · Repositories work with persistence entities.
- Job Repo → Models: stores · Repositories work with persistence entities.
- Bond Repo → Models: stores · Repositories work with persistence entities.
- Subscription Repo → Models: stores · Repositories work with persistence entities.
- Auth Repo → Postgres: uses · Primary relational persistence.
- Job Repo → Postgres: uses · Primary relational persistence.
- Bond Repo → Postgres: uses · Primary relational persistence.
- Subscription Repo → Postgres: uses · Primary relational persistence.
- Auth Service → Redis: uses · Stores ephemeral OTP and session-like state.
- Auth Service → JWT Utils: uses · Issues and validates tokens.
- Auth Service → Hashing: uses · Hashes passwords.
- Auth Service → Mail: uses · Sends OTP and account notifications.
- Subscription Service → Razorpay: uses · Integrates payment processing.
- Seekers → Cloudinary: uses · Handles profile media and document uploads.
- Hirers → Cloudinary: uses · Handles profile media and document uploads.