DZ Jobs API is a backend service built with Golang using the Gin framework. It provides robust functionality for job posting and recruitment, integrating various external services and implementing modern software practices such as layered architecture, caching, and CI/CD pipelines.
- DZ Jobs API
- RESTful API built with Gin framework
- PostgreSQL database integration
- Redis for caching
- External services:
- SendGrid: Email notifications
- Google OAuth: Authentication
- Cloudinary: File uploads (profile pictures, resumes)
- Unit testing with
rapport
- CI/CD pipeline with automated testing, building, and deployment
- Programming Language: Golang
- Web Framework: Gin
- Database: PostgreSQL
- Caching: Redis
- External Services: SendGrid, Google OAuth, Cloudinary
- Containerization: Docker
- CI/CD: GitHub Actions
- Golang (1.20 or above)
- PostgreSQL
- Redis
- Docker
- Git
-
Clone the repository:
git clone https://github.com/raufzer/dz-jobs-api.git cd dz-jobs-api
-
Install dependencies:
go mod tidy
-
Create a
.env
file in the root directory with required variables
Create a .env
file with the following configuration:
# Server Configuration
BACK_END_DOMAIN=your-backend-domain.com
FRONT_END_DOMAIN=your-frontend-domain.com
SERVER_PORT=8080
# Database Configuration
DATABASE_URI=postgres://username:password@localhost:5432/dbname
# Redis Configuration
REDIS_URI=redis://localhost:6379
REDIS_PASSWORD=your-redis-password
# Security & Authentication
ACCESS_TOKEN_SECRET=your-access-token-secret
REFRESH_TOKEN_SECRET=your-refresh-token-secret
RESET_PASSWORD_TOKEN_SECRET=your-reset-password-token-secret
ACCESS_TOKEN_MAX_AGE=24h
REFRESH_TOKEN_MAX_AGE=168h
RESET_PASSWORD_TOKEN_MAX_AGE=1h
# External Services
SENDGRID_API_KEY=your-sendgrid-api-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URL=https://your-backend-domain.com/oauth/google/callback
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secret
# Defaults
DEFAULT_PROFILE_PICTURE=https://your-cloudinary-url.com/default-profile-picture.jpg
DEFAULT_RESUME=https://your-cloudinary-url.com/default-resume.pdf
# Application Metadata
BUILD_VERSION=1.0.0
COMMIT_HASH=your-commit-hash
ENVIRONMENT=production
DOC_URL=https://your-backend-domain.com/docs
LAST_MIGRATION=timestamp-of-last-migration
HEALTH_URL=https://your-backend-domain.com/health
VERSION_URL=https://your-backend-domain.com/version
METRICS_URL=https://your-backend-domain.com/metrics
# Service Email
[email protected]
Start the server:
go run cmd/server/main.go
The server will be accessible at http://localhost:9090.
- Link: Docker Hub Repo
- Docker installed
- Docker Compose (optional but recommended)
# Build the Docker image
docker build -t dz-jobs-api .
# Or using Docker Compose
docker-compose build
# Run the container
docker run -p 9090:9090 --env-file .env dz-jobs-api
# Or using Docker Compose
docker-compose up
go install github.com/swaggo/swag/cmd/swag@latest
# Generate Swagger documentation
swag init -g cmd/server/main.go
- Local URL:
http://localhost:9090/docs/index.html
- Ensure Swagger annotations are added to route handlers
Run unit tests:
go test ./...
Coverage and reporting managed with the rapport
testing tool.
GitHub Actions workflow:
- Runs tests and linter
- Builds Docker images
- Pushes to container registry
- Deploys application
- Endpoint:
/docs/index.html
- Features:
- Interactive endpoint details
- Request/response schemas
- Direct API testing
- Link: DZ Jobs API Postman Workspace
- Collections:
- Authentication endpoints
- Job posting endpoints
- User management endpoints
dz-jobs-api/
├── cmd/server
│ └── main.go # Application entry point
├── internal/
│ ├── bootstrap/ # Application bootstrapping
│ ├── controllers/ # API request handlers
│ ├── dto/ # Data transfer objects
│ ├── integrations/ # External service integrations
│ ├── middlewares/ # Middleware logic
│ ├── models/ # Domain models
│ ├── repositories/ # Data access layer
│ └── services/ # Business logic
├── docs/ # Swagger documentation
├── Dockerfile # Docker image configuration
└── docker-compose.yml # Docker Compose setup
- Verify environment variables
- Check Docker and Go versions
- Ensure network ports are available
- Review logs for specific errors
- Fork the repository
- Create a feature branch
- Commit changes
- Push branch
- Open pull request
Abd Raouf Zerkhef [email protected]