# kunal-deve1oper/interview_app_backend architecture

> Architecture diagram of the GitHub repository kunal-deve1oper/interview_app_backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kunal-deve1oper/interview_app_backend
- Repository: https://github.com/kunal-deve1oper/interview_app_backend

## Overview

##### Main Components

a) External Layer:
- Client Applications (showing incoming HTTP requests)
- Email Service Integration
- Nginx Reverse Proxy (evident from nginx/default.conf)

b) Application Layer:
- HTTP Server (using Go's HTTP server)
- Middleware Layer (JWT Authentication)
- Route Handler Layer
- Service Layer
- Data Access Layer

c) Data Storage:
- PostgreSQL Database
- Redis Cache

##### Component Organization

**[Client Applications] → [Nginx Reverse Proxy] → [Go HTTP Server]**

**Middleware → Routes → Handlers → Services → Data Access → Databases**

##### Detailed Component Breakdown

- Admin Management
- Candidate Management
- Job Role Management
- Organization Management
- Form Management

##### Key Relationships to Highlight

- HTTP Request/Response flows
- Database queries
- Email notifications
- Cache interactions
- Authentication flows

##### Specific Implementation Details

Following key architectural patterns:
- JWT-based authentication flow
- Email service integration
- Database query layer separation
- Input validation mechanisms
- Error handling patterns

##### Component Details

a) Handler Layer:
- Admin handlers
- Candidate handlers
- Job Role handlers
- Organization handlers
- Form handlers

b) Service Layer:
- Admin queries
- Candidate queries
- Job Role queries
- Organization queries
- Form queries

c) Model Layer:
- Admin model
- Candidate model
- JWT model
- Organization model
- Role model

##### Additional Elements

Annotations for:
- Configuration management
- Environment variables
- Database connection details
- Mail service configuration
- Validation rules

##### Infrastructure Components

Containerization aspects:
- Docker container boundaries
- Docker Compose services
- Network isolation

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        Client[Client Applications]:::external
        Email[Email Service]:::external
    end

    subgraph Infrastructure
        Nginx["Nginx Reverse Proxy"]:::infra
        click Nginx "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/nginx/default.conf"
        Docker["Docker Container"]:::infra
        click Docker "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/Dockerfile"
        DockerCompose["Docker Compose"]:::infra
        click DockerCompose "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/docker-compose.yml"
    end

    subgraph "HTTP Server"
        Server["HTTP Server"]:::server
        click Server "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/server/server.go"
        
        subgraph Middleware
            JWT["JWT Authentication"]:::security
            click JWT "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/middleware/jwt.go"
        end

        subgraph Routes
            MainRoutes["Route Handler"]:::route
            click MainRoutes "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/routes/routes.go"
        end

        subgraph Handlers
            AdminH["Admin Handlers"]:::handler
            click AdminH "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/handlers/admin/"
            CandidateH["Candidate Handlers"]:::handler
            click CandidateH "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/handlers/candidates/"
            JobRoleH["Job Role Handlers"]:::handler
            click JobRoleH "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/handlers/jobrole/"
            OrgH["Organization Handlers"]:::handler
            click OrgH "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/handlers/organization/"
            FormH["Form Handlers"]:::handler
            click FormH "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/handlers/form/"
        end

        subgraph Services
            AdminS["Admin Services"]:::service
            click AdminS "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/services/adminQuery/"
            CandidateS["Candidate Services"]:::service
            click CandidateS "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/services/candidatesQuery/"
            JobRoleS["Job Role Services"]:::service
            click JobRoleS "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/services/jobroleQuery/"
            OrgS["Organization Services"]:::service
            click OrgS "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/services/organizationQuery/"
            FormS["Form Services"]:::service
            click FormS "https://github.com/Kunal-deve1oper/interview_app_backend/tree/main/internal/services/formQuery/"
        end

        subgraph Models
            AdminM["Admin Model"]:::model
            click AdminM "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/models/admin_modal.go"
            CandidateM["Candidate Model"]:::model
            click CandidateM "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/models/candidate_modal.go"
            OrgM["Organization Model"]:::model
            click OrgM "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/models/organization_modal.go"
            RoleM["Role Model"]:::model
            click RoleM "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/models/role_modal.go"
            JWTM["JWT Model"]:::model
            click JWTM "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/models/jwt_modal.go"
        end

        subgraph Utils
            EmailSvc["Email Service"]:::util
            click EmailSvc "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/utils/mailService.go"
            EmailTemp["Email Templates"]:::util
            click EmailTemp "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/utils/mail_templates.go"
            Validation["Validation"]:::util
            click Validation "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/utils/validate_candidate.go"
            ErrorHandler["Error Handler"]:::util
            click ErrorHandler "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/utils/send_error_response.go"
        end
    end

    subgraph Storage
        Postgres[(PostgreSQL)]:::db
        click Postgres "https://github.com/Kunal-deve1oper/interview_app_backend/blob/main/internal/utils/init_db.sql"
        Redis[(Redis Cache)]:::cache
    end

    %% Connections
    Client --> Nginx
    Nginx --> Server
    Server --> JWT
    JWT --> MainRoutes
    MainRoutes --> AdminH & CandidateH & JobRoleH & OrgH & FormH
    AdminH --> AdminS
    CandidateH --> CandidateS
    JobRoleH --> JobRoleS
    OrgH --> OrgS
    FormH --> FormS
    AdminS & CandidateS & JobRoleS & OrgS & FormS --> Postgres
    AdminS & CandidateS & JobRoleS & OrgS & FormS --> Redis
    AdminS & CandidateS --> EmailSvc
    EmailSvc --> Email
    
    %% Styles
    classDef external fill:#68B7FF,stroke:#333,stroke-width:2px
    classDef infra fill:#FFB366,stroke:#333,stroke-width:2px
    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef route fill:#98FB98,stroke:#333,stroke-width:2px
    classDef handler fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef service fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef model fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef util fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef db fill:#FFD700,stroke:#333,stroke-width:2px
    classDef cache fill:#FF69B4,stroke:#333,stroke-width:2px
```
