added monorepo architecture
This commit is contained in:
parent
0e1b64b7b9
commit
e54e5fb9ea
23 changed files with 24 additions and 48 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -13,7 +13,7 @@
|
||||||
*.dylib
|
*.dylib
|
||||||
*.test
|
*.test
|
||||||
*.out
|
*.out
|
||||||
go.work
|
# go.work
|
||||||
|
|
||||||
# Dependency directories
|
# Dependency directories
|
||||||
vendor/
|
vendor/
|
||||||
|
|
|
||||||
24
Makefile
24
Makefile
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
APP_NAME=jobs-scraper
|
APP_NAME=jobs-scraper
|
||||||
API_DIR=./api
|
API_DIR=./packages/api
|
||||||
SCRAPER_DIR=./services/scraper
|
SCRAPER_DIR=./packages/linked-scraper
|
||||||
|
GLASSDOOR_DIR=./packages/glassdoor-scraper
|
||||||
DOCS_DIR=./docs
|
DOCS_DIR=./docs
|
||||||
BIN_DIR=./bin
|
BIN_DIR=./bin
|
||||||
MAIN_FILE=$(API_DIR)/main.go
|
MAIN_FILE=$(API_DIR)/main.go
|
||||||
|
|
@ -32,10 +33,25 @@ scraper: ## Run the scraper service
|
||||||
@cd $(SCRAPER_DIR) && go run main.go
|
@cd $(SCRAPER_DIR) && go run main.go
|
||||||
|
|
||||||
.PHONY: build-scraper
|
.PHONY: build-scraper
|
||||||
build-scraper: ## Build the scraper service
|
build-scraper: ## Build the linked scraper service
|
||||||
@echo "Building scraper service..."
|
@echo "Building linked scraper service..."
|
||||||
@cd $(SCRAPER_DIR) && go build -o scraper main.go
|
@cd $(SCRAPER_DIR) && go build -o scraper main.go
|
||||||
|
|
||||||
|
.PHONY: glassdoor-scraper
|
||||||
|
glassdoor-scraper: ## Run the glassdoor scraper service
|
||||||
|
@echo "Running glassdoor scraper service..."
|
||||||
|
@cd $(GLASSDOOR_DIR) && npm run dev
|
||||||
|
|
||||||
|
.PHONY: build-glassdoor
|
||||||
|
build-glassdoor: ## Build the glassdoor scraper service
|
||||||
|
@echo "Building glassdoor scraper service..."
|
||||||
|
@cd $(GLASSDOOR_DIR) && npm run build
|
||||||
|
|
||||||
|
.PHONY: build-api
|
||||||
|
build-api: ## Build the API service
|
||||||
|
@echo "Building API service..."
|
||||||
|
@cd $(API_DIR) && go build -o api main.go
|
||||||
|
|
||||||
.PHONY: cron
|
.PHONY: cron
|
||||||
cron: ## Run the job analysis cron service
|
cron: ## Run the job analysis cron service
|
||||||
@echo "Starting Job Analysis Cron Service..."
|
@echo "Starting Job Analysis Cron Service..."
|
||||||
|
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/jobs-scraper/shared/infrastructure"
|
|
||||||
"github.com/joho/godotenv"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Try to load .local.env first, then fallback to .env
|
|
||||||
if err := godotenv.Load(".local.env"); err != nil {
|
|
||||||
log.Println("No .local.env file found, trying .env")
|
|
||||||
if err := godotenv.Load(".env"); err != nil {
|
|
||||||
log.Println("No .env file found, using system environment variables")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dbConfig := infrastructure.LoadConfigFromEnv()
|
|
||||||
|
|
||||||
db, err := infrastructure.NewConnection(dbConfig)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error connecting to database: %v", err)
|
|
||||||
}
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
err = db.Ping()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error pinging database: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("Successfully connected to database")
|
|
||||||
|
|
||||||
// Run migrations
|
|
||||||
if err := infrastructure.RunMigrations(db); err != nil {
|
|
||||||
log.Fatalf("Failed to run migrations: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("Migrations completed successfully")
|
|
||||||
}
|
|
||||||
2
go.work
2
go.work
|
|
@ -2,7 +2,7 @@ go 1.24.0
|
||||||
|
|
||||||
use (
|
use (
|
||||||
.
|
.
|
||||||
./services/linked-scraper
|
./packages/linked-scraper
|
||||||
./shared/domain
|
./shared/domain
|
||||||
./shared/infrastructure
|
./shared/infrastructure
|
||||||
./shared/ports
|
./shared/ports
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/jobs-scraper/api/commands/job"
|
"github.com/jobs-scraper/packages/api/commands/job"
|
||||||
"github.com/jobs-scraper/shared/infrastructure/rabbitmq"
|
"github.com/jobs-scraper/shared/infrastructure/rabbitmq"
|
||||||
"github.com/jobs-scraper/shared/ports"
|
"github.com/jobs-scraper/shared/ports"
|
||||||
"github.com/jobs-scraper/shared/repo"
|
"github.com/jobs-scraper/shared/repo"
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/jobs-scraper/api/app"
|
"github.com/jobs-scraper/packages/api/app"
|
||||||
"github.com/jobs-scraper/shared/infrastructure"
|
"github.com/jobs-scraper/shared/infrastructure"
|
||||||
httpHandler "github.com/jobs-scraper/shared/infrastructure/http"
|
httpHandler "github.com/jobs-scraper/shared/infrastructure/http"
|
||||||
"github.com/jobs-scraper/shared/infrastructure/rabbitmq"
|
"github.com/jobs-scraper/shared/infrastructure/rabbitmq"
|
||||||
Loading…
Reference in a new issue