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
|
||||
*.test
|
||||
*.out
|
||||
go.work
|
||||
# go.work
|
||||
|
||||
# Dependency directories
|
||||
vendor/
|
||||
|
|
|
|||
24
Makefile
24
Makefile
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
# Variables
|
||||
APP_NAME=jobs-scraper
|
||||
API_DIR=./api
|
||||
SCRAPER_DIR=./services/scraper
|
||||
API_DIR=./packages/api
|
||||
SCRAPER_DIR=./packages/linked-scraper
|
||||
GLASSDOOR_DIR=./packages/glassdoor-scraper
|
||||
DOCS_DIR=./docs
|
||||
BIN_DIR=./bin
|
||||
MAIN_FILE=$(API_DIR)/main.go
|
||||
|
|
@ -32,10 +33,25 @@ scraper: ## Run the scraper service
|
|||
@cd $(SCRAPER_DIR) && go run main.go
|
||||
|
||||
.PHONY: build-scraper
|
||||
build-scraper: ## Build the scraper service
|
||||
@echo "Building scraper service..."
|
||||
build-scraper: ## Build the linked scraper service
|
||||
@echo "Building linked scraper service..."
|
||||
@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
|
||||
cron: ## Run the 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 (
|
||||
.
|
||||
./services/linked-scraper
|
||||
./packages/linked-scraper
|
||||
./shared/domain
|
||||
./shared/infrastructure
|
||||
./shared/ports
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"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/ports"
|
||||
"github.com/jobs-scraper/shared/repo"
|
||||
|
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/jobs-scraper/api/app"
|
||||
"github.com/jobs-scraper/packages/api/app"
|
||||
"github.com/jobs-scraper/shared/infrastructure"
|
||||
httpHandler "github.com/jobs-scraper/shared/infrastructure/http"
|
||||
"github.com/jobs-scraper/shared/infrastructure/rabbitmq"
|
||||
Loading…
Reference in a new issue