{"id":25105101,"url":"https://github.com/gbrayhan/hexagonal-architecture-clojure","last_synced_at":"2026-02-16T17:02:04.298Z","repository":{"id":276042944,"uuid":"928025302","full_name":"gbrayhan/hexagonal-architecture-clojure","owner":"gbrayhan","description":"DDD Hexagonal Architecture using Clojure ","archived":false,"fork":false,"pushed_at":"2025-03-10T02:03:20.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-01T01:58:25.126Z","etag":null,"topics":["clean-architecture","clojure","clojure-ddd","clojure-postgresql","docker-compose","hexagonal","hexagonal-architecture","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gbrayhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-05T23:47:18.000Z","updated_at":"2025-10-24T17:38:08.000Z","dependencies_parsed_at":"2025-09-15T18:43:42.474Z","dependency_job_id":"359c7220-375e-4c1b-b761-38562ad34c09","html_url":"https://github.com/gbrayhan/hexagonal-architecture-clojure","commit_stats":null,"previous_names":["gbrayhan/hexagonal-architecture-clojure"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gbrayhan/hexagonal-architecture-clojure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrayhan%2Fhexagonal-architecture-clojure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrayhan%2Fhexagonal-architecture-clojure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrayhan%2Fhexagonal-architecture-clojure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrayhan%2Fhexagonal-architecture-clojure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gbrayhan","download_url":"https://codeload.github.com/gbrayhan/hexagonal-architecture-clojure/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrayhan%2Fhexagonal-architecture-clojure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29513430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","clojure","clojure-ddd","clojure-postgresql","docker-compose","hexagonal","hexagonal-architecture","rest-api"],"created_at":"2025-02-07T22:33:35.607Z","updated_at":"2026-02-16T17:02:04.270Z","avatar_url":"https://github.com/gbrayhan.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clojure DDD Hexagonal Architecture REST API\nAuthor: Alejandro Guerrero - [LinkedIn](https://www.linkedin.com/in/gbrayhan/)\nEmail: gbrayhan@gmail.com \n\nThis is a Clojure-based REST API following Hexagonal Architecture principles. The project provides an implementation for managing users and their data in a PostgreSQL database using Clojure and Docker.\n\n## Project Overview\n\nThis project is built with a focus on:\n\n- **Hexagonal Architecture**: Ensures that the application core is independent of external technologies like databases, frameworks, or UI.\n- **Clojure**: The language used to implement the application.\n- **PostgreSQL**: The relational database used for data persistence.\n- **Docker**: The application is containerized for easy deployment.\n\nThe API allows for the management of user data, including the ability to create, retrieve, update, and delete users.\n\n## Project Structure\n\n- **`src/clojure_ddd_hexagonal`**: The main application code.\n    - **`application/usecase`**: Contains use cases (business logic) for user operations.\n    - **`domain`**: Contains the domain model, including the user entity and service interfaces.\n    - **`infrastructure`**: Includes the repository and REST controllers for handling HTTP requests.\n- **`resources`**: Configuration files like `migratus.edn` and `application.properties`.\n- **`migrations`**: SQL scripts for database migrations.\n- **`Dockerfile`**: The Docker configuration for building and running the application.\n- **`docker-compose.yml`**: Configuration to run the app and database in Docker containers.\n- **`project.clj`**: The project configuration file for Leiningen (Clojure build tool).\n- **`entrypoint.sh`**: Shell script to handle startup tasks like waiting for the database and running migrations.\n\n## Hexagonal Architecture\n\nIn Hexagonal Architecture, the core of the application (business logic) is decoupled from external frameworks, databases, and other infrastructure. This design allows for flexibility and testability by separating concerns into different layers.\n\n- **Core**: Contains the core business logic and application use cases (e.g., create, update, delete, and fetch users).\n- **Adapters**: Exposes the application to external systems like databases, HTTP requests, and other services. This includes the repository layer (PostgreSQL) and the REST API controllers.\n\n## How to Run the Project\n\n### Prerequisites\n\nEnsure that you have Docker and Docker Compose installed on your machine.\n\n### Steps\n\n1. Clone the repository.\n2. Build the Docker containers using Docker Compose:\n   ```bash\n   docker-compose up --build\n   ```\n\n3. This will:\n    - Build the application image.\n    - Start the PostgreSQL database and the application.\n    - Run any required migrations.\n\n4. Once the application is running, you can access it via `http://localhost:3000`.\n\n### Docker Compose\n\nThe `docker-compose.yml` file defines the following services:\n\n- **db**: The PostgreSQL database.\n- **app**: The REST API application that communicates with the database.\n\n```yaml\nservices:\n  db:\n    image: postgres:15\n    container_name: hexagonal_clojure_db\n    environment:\n      POSTGRES_USER: usuario\n      POSTGRES_PASSWORD: password\n      POSTGRES_DB: mi_api_rest_db\n    volumes:\n      - db-data:/var/lib/postgresql/data\n    ports:\n      - \"5432:5432\"\n    networks:\n      - app-network\n\n  app:\n    build: .\n    container_name: hexagonal_clojure_rest_app\n    environment:\n      DATABASE_URL: \"jdbc:postgresql://db:5432/mi_api_rest_db\"\n    ports:\n      - \"3000:3000\"\n    depends_on:\n      - db\n    networks:\n      - app-network\n\nvolumes:\n  db-data:\n\nnetworks:\n  app-network:\n```\n\n### Migrations\n\nThe project uses the **Migratus** library for database migrations. These migrations can be applied with the following command:\n\n```bash\ndocker-compose run app lein migrate\n```\n\nYou can also roll back migrations using:\n\n```bash\ndocker-compose run app lein rollback\n```\n\n## API Endpoints\n\nThe API has the following endpoints for managing users:\n\n### Create a New User\n```bash\ncurl -X POST http://localhost:3000/user \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"John Doe\", \"email\": \"john@example.com\"}'\n```\n\n### Get All Users\n```bash\ncurl http://localhost:3000/user\n```\n\n### Get User by ID\n```bash\ncurl http://localhost:3000/user/{id}\n```\n\n### Update a User\n```bash\ncurl -X PUT http://localhost:3000/user/{id} \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"John Updated\", \"email\": \"john.updated@example.com\"}'\n```\n\n### Delete a User\n```bash\ncurl -X DELETE http://localhost:3000/user/{id}\n```\n\n## Architecture Overview\n\nThe architecture of the project is based on **Hexagonal Architecture**, where the core business logic (e.g., user management) is isolated from the external systems (database, web framework). The architecture includes:\n\n- **Core (Use Cases)**: Defines the operations that can be performed on users.\n- **Ports**: Interfaces that define how the core interacts with the outside world (e.g., HTTP API, repositories).\n- **Adapters**: Implement the interfaces defined in the ports to interact with external systems (e.g., PostgreSQL database, HTTP controllers).\n\n## Additional Information\n\n- **Database**: The application uses PostgreSQL as the data store. You can configure database credentials and connection settings in `resources/migratus.edn`.\n- **Testing**: The project includes basic unit tests using Clojure's `clojure.test`. Run tests with:\n  ```bash\n  lein test\n  ```\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n\n---\n\nFeel free to modify this README file as needed based on any additional features or setup steps!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbrayhan%2Fhexagonal-architecture-clojure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgbrayhan%2Fhexagonal-architecture-clojure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbrayhan%2Fhexagonal-architecture-clojure/lists"}