Coder Social home page Coder Social logo

job-fetcher's Introduction

Job Fetcher

Prerequisites

  • JDK: version 20 (distribution temurin)

Main commands

Run the application

# replace the <change-me> with your own access token
POLE_EMPLOI_API_TOKEN=<change-me> ./gradlew bootTestRun

# to get your own access token execute the following curl command (replace <change-me> with your own data)
curl --location --request POST 'https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=<change-me>' \
--data-urlencode 'client_secret=<change-me>' \
--data-urlencode 'scope=api_offresdemploiv2 o2dsoffre'

It will create a postgresql database in a docker container behind the hood. Thanks to Spring Boot 3.1 and Testcontainers (article)

Once the app is started, you can do the synchronization by calling an endpoint. It is described here . If you are using IntelliJ IDE you can run it directly from the file. Check out this documentation for more details

Database access

The JDBC url is jdbc:postgresql://localhost:<port>/job. The credentials are:

  • the port is dynamic by nature (it's how Testcontainers works). It can be found on the logs of the app after the app has been launched. The pattern is Container is started (JDBC URL: jdbc:postgresql://localhost:<port>/job?loggerLevel=OFF)
  • the username is admin
  • the password is change-me.
    Credentials are defined here

Run the test suite

./gradlew test The coverage is 87%

img.png

Information

Git commits

I write commits as an history so it can help people to understand what the application does.

Architecture

I'm using hexagonal architecture (with port & adapter pattern). It eases the testing of the app by implementing the ports.

Testing

I'm using use case driven development. Check out this great presentation about this topic. I'm using approach 2 (slide 46).
I prefer stubs rather than mocks. It eases the refactoring of the code.

Development methodology

I used real TDD during the development of this project.

Lombok

Here I'm using lombok but in the real life I'm not a big fan of this library. Some upgrades of lombok can be challenging and sometimes there is conflicts with other libs (for example with Mapstruct). I prefer writing the good old POJOs by myself (with an IDE it's super fast).

Java records are a good candidate to replace lombok but the fields are immutable by nature and it makes it incompatible with some libraries. That's why I'm using them only in the domain.

Equals and hashcode on jpa entity

They have been generated using JpaBuddy utility

Improvements

  • Feature: I'm only fetching the first 100 job ads from the Pole Emploi API. I would have to iterate over all the pages.
  • Feature: I did not implement the top 10 entreprises
  • Security: OAuth2 flow has not been implemented
  • Incremental mode is working but it delete all the job ads and then it save them all from the Pole Emploi API. Checking ids can be smarter and more efficient.

job-fetcher's People

Contributors

fleboulch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.