Fix Web-App Connection Issue: Clojure-Datomic-PostgreSQL

Job ID: 39262943

Budget: $15 – $25 USD

**Summary of Issue**

We are facing a deployment and runtime failure in our **Clojure-based web application** primarily due to **misconfiguration and integration issues between Datomic On-Prem, PostgreSQL, and the Clojure app itself.**

---

**Core Problem**
The main issue is a **database connection failure** during the application startup.
The app is unable to acquire database connections and throws errors like:

```
java.sql.SQLException: Connections could not be acquired from the underlying database
java.net.UnknownHostException
```

This is because of a **misconfiguration between:**
- **Datomic On-Prem Transactor**
- **Clojure Application (Portal App)**
- **PostgreSQL Database**

The Datomic Transactor is expected to connect to PostgreSQL as its storage backend and the Clojure app interacts with Datomic.
**However, currently:**
- PostgreSQL is not correctly installed/configured.
- Database users and databases required by Datomic are missing.
- Datomic Transactor config is not properly pointing to the database.
- The app fails to boot due to inability to connect to Datomic & PostgreSQL.

---

**Technology Stack Involved**
- **Amazon EC2 (Amazon Linux 2023)**
- **Clojure Application (Portal)**
- **Datomic On-Prem**
- **PostgreSQL (backend for Datomic)**
- **AWS CodeDeploy (for deployments)**
- **Nginx** (reverse proxy)

---

**Scope of Work Required**
1. **Verify and fix PostgreSQL installation & configuration**
- Install correct PostgreSQL version
- Create required databases & users
- Enable external connections (if needed)

2. **Fix Datomic Transactor configuration**
- Update `dev-transactor.properties` with correct PostgreSQL DB connection
- Test Datomic transactor startup

3. **Verify and fix Clojure app configuration**
- Ensure app points to correct Datomic Peer URIs
- Environment variables / config cleanup

4. **Test full connection flow**
- PostgreSQL ⟶ Datomic Transactor ⟶ Clojure App

5. **Ensure systemd services for app & transactor**
- Configure as background services
- Enable logging & auto-restart

6. **Optional: Streamline CodeDeploy configuration**
- Fix deployment scripts (appspec.yml & lifecycle hooks)

---

**Desired Outcome**
A fully functional, production-ready EC2 instance where:
- PostgreSQL is installed and properly configured.
- Datomic transactor connects to PostgreSQL without errors.
- Clojure app is able to load and connect to Datomic.
- End-to-end deployment and app startup happens without any manual intervention.