Skip to content

Commit 7c904f6

Browse files
authored
Merge pull request #56 from Jalen-Stephens/49-implement-demoable-client-in-same-repository
49 implement demoable client in same repository
2 parents 407c3a0 + 180ff8f commit 7c904f6

19 files changed

Lines changed: 1764 additions & 81 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ build/
3636
.env
3737
env.local.sh
3838
env.pooler.sh
39+
.env.prod.sh
40+
41+
.DS_Store
42+
43+
### Client build artifacts ###
44+
client/node_modules/
45+
client/dist/
46+
client/.cache/
3947

4048
### Output.json ###
4149
output.json

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,36 @@ From the terminal, run the following CLI commands:
6565

6666
---
6767

68+
## Client Demo (Pulse)
69+
---------------------------------------------------------------------
70+
`client/` contains a lightweight social-style demo called **Pulse** that exercises the `/auth/signup` and `/auth/login` endpoints.
71+
72+
1. Start the MetaDetect backend (see steps above) so `http://localhost:8080` is available.
73+
2. Run a tiny static server from the project root:
74+
```bash
75+
python3 -m http.server 4173 --directory client
76+
```
77+
3. Visit http://localhost:4173 in your browser. Submit either form to see the live API response in the right panel. After a successful login the client automatically routes you to the Pulse Studio page.
78+
79+
### Targeting another deployment
80+
- Edit `client/config.js` and change `apiBaseUrl` to the host of any MetaDetect instance (e.g., a staging URL or a tunnel).
81+
- The badge in the form header reflects the active base URL so you always know which backend you are exercising.
82+
83+
### What the demo covers
84+
- **Sign up**: posts `{ email, password }` to `/auth/signup` and surfaces the raw Supabase JSON for convenient debugging.
85+
- **Log in**: posts the same shape to `/auth/login`, displaying access/refresh tokens if enabled in your Supabase project.
86+
- Responses can be copied to the clipboard for quickly pasting into tools like Swagger or HTTP clients.
87+
88+
### Pulse Studio — create/delete posts
89+
- Open http://localhost:4173/compose.html in the same static server session.
90+
- After logging in, the access token is automatically saved to your browser and reused by the Studio page.
91+
- Use the composer to upload images via `/api/images/upload`, add captions/hashtags (mapped to the `note` + `labels` fields), and delete posts inline via `/api/images/{id}`.
92+
- The feed retrieves your existing uploads with `/api/images` and pulls signed URLs per asset so you can actually preview the media.
93+
- Each card automatically runs `/api/analyze/{imageId}` and labels posts with an **AI generated** banner whenever the backend reports `status=DONE`.
94+
- Tokens stay hidden in the UI for safety; log in again from Pulse if you need to refresh credentials.
95+
96+
---
97+
6898
## Running the Application with Docker
6999
---------------------------------------------------------------------
70100
STILL UNDER DEVELOPMENT - PUSH TO ITERATION 2 - Sulay has been working very hard on this and it's good for next iteration
@@ -532,4 +562,4 @@ This section includes notes on tools and technologies used in building this proj
532562
* We use Supabase as our main Database
533563
* It has built in Authentication
534564
* We use tables to track metadata of images
535-
* Then we use S3 Buckets to store the physical Images within Supabase
565+
* Then we use S3 Buckets to store the physical Images within Supabase

citations.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,73 @@
11
### **Commit / Ticket Reference**
22

3+
* **Commit:** `test(API) wrote controller test after making changes for pooler connection (#49)`
4+
* **Ticket:** `#49 — Implement Demoable Client + Pooler Stability`
5+
* **Date:** November 13, 2025
6+
* **Team Member:** Jalen Stephens
7+
8+
---
9+
10+
### **AI Tool Information**
11+
12+
* **Tool Used:** OpenAI ChatGPT (GPT-5) via Codex CLI
13+
* **Access Method:** Local Codex CLI session (sandboxed, no paid API usage)
14+
* **Configuration:** Default model parameters supplied by course tooling
15+
* **Cost:** $0 (educational access)
16+
17+
---
18+
19+
### **Purpose of AI Assistance**
20+
21+
Used AI to draft and refine the new controller-focused regression tests that restore JaCoCo coverage after the pooler/database changes. Guidance covered:
22+
23+
* Designing slice tests for `AnalyzeController` (submit, status, manifest, compare)
24+
* Adding `HealthControllerTest` to drive both branches of the DB health ping and metadata endpoint
25+
* Restructuring `SecurityConfigMvcTest` to avoid datasource/autowire failures while still verifying CORS + JWT rules
26+
* Capturing the environment tweaks (`application.properties`, Mockito plugin) needed to boot the test slices without pooler credentials
27+
28+
---
29+
30+
### **Prompts / Interaction Summary**
31+
32+
* “write AnalyzeController MockMvc tests that assert JSON payloads and verify service calls”
33+
* “add HealthController tests without talking to a real DB”
34+
* “security config test fails because of datasource—convert to WebMvcTest and stub controllers”
35+
* “how do I stop Mockito inline from requiring the byte-buddy agent in the sandbox?”
36+
* “fill out the commit citation entry using the standard template”
37+
38+
---
39+
40+
### **Resulting Artifacts**
41+
42+
* Added controller tests:
43+
* `src/test/java/dev/coms4156/project/metadetect/controller/AnalyzeControllerTest.java`
44+
* `src/test/java/dev/coms4156/project/metadetect/controller/HealthControllerTest.java`
45+
* Hardened security slice testing:
46+
* `src/test/java/dev/coms4156/project/metadetect/config/SecurityConfigMvcTest.java`
47+
* `src/test/java/dev/coms4156/project/metadetect/config/SecurityTestControllers.java`
48+
* Test-only infrastructure:
49+
* `src/test/resources/application.properties` (stable Supabase defaults for tests)
50+
* `src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker`
51+
* `pom.xml` dependency cleanup (removed `mockito-inline`)
52+
53+
---
54+
55+
### **Verification**
56+
57+
* Targeted suite:
58+
`MAVEN_USER_HOME=$PWD/.m2 ./mvnw -q -Dtest=AuthControllerTest,ImageControllerTest,AnalyzeControllerTest,HealthControllerTest,SecurityConfigMvcTest test`
59+
* All targeted tests pass. Full `./mvnw test` still blocked in `SupabaseStorageServiceTest` / `AuthProxyServiceTest` because the course sandbox forbids binding local sockets for `MockWebServer`; rerun outside the sandbox to regenerate JaCoCo.
60+
61+
---
62+
63+
### **Attribution Statement**
64+
65+
> Portions of this commit were generated with assistance from OpenAI ChatGPT (GPT-5) on November 13, 2025. All AI-generated content was reviewed, tested, and validated by the development team before committing.
66+
67+
---
68+
69+
### **Commit / Ticket Reference**
70+
371
* **Commit:** `chore(init): renamed project to MetaDetect, updated package structure, pom.xml coordinates, and Spring Boot configuration (#2)`
472
* **Ticket:** [#2 — INIT Project Skeleton Code](https://github.com/Jalen-Stephens/AdvanceJavaStudentEngineers/issues/2)
573
* **Date:** October 15 2025
@@ -43,6 +111,70 @@ Prompts and questions provided to ChatGPT included:
43111

44112
### **Resulting Artifacts**
45113

114+
---
115+
116+
### **Commit / Ticket Reference**
117+
118+
* **Commit:** `bug(DB): fixes to help pooler connection limit (#49)`
119+
* **Ticket:** `#49 — Implement Demoable Client + Pooler Stability`
120+
* **Date:** October 25, 2025
121+
* **Team Member:** Jalen Stephens
122+
123+
---
124+
125+
### **AI Tool Information**
126+
127+
* **Tool Used:** OpenAI ChatGPT (GPT-5)
128+
* **Access Method:** ChatGPT Web (.edu academic access)
129+
* **Configuration:** Default model settings
130+
* **Cost:** $0 (no paid API calls)
131+
132+
---
133+
134+
### **Purpose of AI Assistance**
135+
136+
The AI assistant helped diagnose Supabase pooler exhaustion by reviewing how Spring transactions were scoped around long-running storage calls. Guidance focused on:
137+
138+
* Shortening transaction lifetimes in `ImageService` so uploads/deletes don’t hold DB connections while streaming to Supabase Storage.
139+
* Adding orphan-cleanup logic so failed uploads best-effort delete the metadata row, preventing dangling rows that require manual cleanup.
140+
* Removing the broad `@Transactional` annotation from `AnalyzeService.submitAnalysis` so the expensive C2PA invocation runs outside the JDBC session.
141+
* Clarifying how to source `env.pooler.sh` so the smaller pool-size and timeout overrides are consistently applied during local runs.
142+
143+
---
144+
145+
### **Prompts / Interaction Summary**
146+
147+
* “Connections aren’t closing against the pooler—can you check `ImageService` for long transactions?”
148+
* “How can we make sure upload failures roll back the metadata row even after the storage call throws?”
149+
* “Should AnalyzeService keep the transaction open while running the C2PA CLI?”
150+
* “Remind me how to use `env.pooler.sh` so Hikari sees the 2-connection limit.”
151+
152+
---
153+
154+
### **Resulting Artifacts**
155+
156+
* `src/main/java/dev/coms4156/project/metadetect/service/ImageService.java`
157+
* Removed class-level `@Transactional` usage from controller entry points; now only the RLS helpers manage transactions.
158+
* Introduced `deleteOrphanedImage()` with logging to clean up rows when uploads fail midstream.
159+
* Wrapped upload flow in try/catch so DB rows are rolled back before rethrowing storage errors.
160+
* `src/main/java/dev/coms4156/project/metadetect/service/AnalyzeService.java`
161+
* `submitAnalysis` now persists the PENDING row and immediately releases the connection before downloading assets or running C2PA.
162+
* `env.pooler.sh`
163+
* Documented values reiterated so the pooler JDBC URL, credentials, and keepalive hints are sourced for local testing.
164+
165+
---
166+
167+
### **Verification**
168+
169+
* Ran `mvn -DskipTests compile` — build succeeded (only existing Guice `sun.misc.Unsafe` warnings remain).
170+
* Manual inspection confirmed all repository calls now occur within short-lived RLS-wrapped scopes, preventing Hikari from exceeding the 2-connection pooler cap.
171+
172+
---
173+
174+
### **Attribution Statement**
175+
176+
> Portions of the connection-scope refactor and pooler troubleshooting guidance for this commit were generated with assistance from **OpenAI ChatGPT (GPT-5)** on October 25, 2025. The development team reviewed, tested, and validated all AI-assisted changes prior to committing.
177+
46178
* Updated project structure → `dev/coms4156/project/metadetect`
47179
* Updated `MetaDetectApplication.java` and `application.properties`
48180
* Rewritten `pom.xml` with MetaDetect metadata, PMD, Checkstyle, and JaCoCo rules
@@ -346,6 +478,77 @@ The AI assisted in designing the revised database schema to align authentication
346478

347479
### **Commit / Ticket Reference**
348480

481+
* **Commit:** `feat(Init): Demo UI Setup Initi (#49)`
482+
* **Ticket:** [#49 — Implement demoable client in same repository](https://github.com/Jalen-Stephens/AdvanceJavaStudentEngineers/issues/49)
483+
* **Date:** November 10, 2025
484+
* **Team Member:** Jalen Stephens
485+
486+
---
487+
488+
### **AI Tool Information**
489+
490+
* **Tool Used:** OpenAI ChatGPT (GPT-5)
491+
* **Access Method:** Codex CLI (local workstation) connected to ChatGPT via academic access
492+
* **Configuration:** Default reasoning profile; no fine-tuning or paid API usage
493+
* **Cost:** $0 (covered by institutional access)
494+
495+
---
496+
497+
### **Purpose of AI Assistance**
498+
499+
The assistant helped design and implement the in-repo demo client (“Pulse”) that exercises the MetaDetect auth and media APIs. This included:
500+
501+
* Planning the folder layout under `client/` and deciding on a framework-free static build (HTML/CSS/JS).
502+
* Creating the login/sign-up experience that proxies `/auth/signup` and `/auth/login`, persists Supabase access tokens, and redirects to the media composer.
503+
* Building “Pulse Studio,” a social-style posting page that uploads images, annotates captions and hashtags, lists prior uploads, previews signed URLs, and deletes posts.
504+
* Styling both pages to resemble a polished social app experience while remaining framework-agnostic for easy demoing.
505+
* Updating `README.md` with hosting instructions, routing behavior, and token-handling notes, plus tightening `.gitignore` for future client tooling.
506+
507+
---
508+
509+
### **Prompts / Interaction Summary**
510+
511+
Representative instructions provided to the AI:
512+
513+
* “Create a social-media inspired login/sign-up UI that hits our `/auth` APIs and show responses inline.”
514+
* “Build another page where creators can upload images, add captions/hashtags, and delete posts using `/api/images`.”
515+
* “Automatically store the Supabase access token in the browser and reuse it so users don’t have to paste it.”
516+
* “Hide the bearer token in the UI but still let me override it if needed.”
517+
* “Update the README with steps for serving the client and describe Pulse Studio.”
518+
* “Add a CTA on the login page that jumps to the composer, and auto-redirect to the composer after logging in.”
519+
520+
---
521+
522+
### **Resulting Artifacts**
523+
524+
* `client/index.html`, `client/styles.css`, `client/app.js` — Pulse login/sign-up client with Supabase token persistence and auto-redirect.
525+
* `client/compose.html`, `client/compose.css`, `client/compose.js` — Pulse Studio composer supporting uploads, captions/labels, feed rendering, signed URL previews, and inline deletes.
526+
* `client/config.js` — central base-URL configuration for targeting different backend instances.
527+
* `.gitignore` — ignores future client build outputs (`client/node_modules`, `client/dist`, `.cache`).
528+
* `README.md` — new “Client Demo (Pulse)” section covering login flow, Studio usage, and hidden-token behavior.
529+
530+
---
531+
532+
### **Verification**
533+
534+
* Manually exercised the login form against a local MetaDetect backend:
535+
* Verified successful `/auth/login` response, token persistence to `localStorage`, and automatic redirect to `compose.html`.
536+
* From Pulse Studio:
537+
* Uploaded sample images through `/api/images/upload`, confirmed captions/labels persisted via `/api/images/{id}` `PUT`.
538+
* Validated feed refresh hits `/api/images` and that signed URLs render in cards via `/api/images/{id}/url`.
539+
* Deleted posts with `/api/images/{id}` `DELETE` and confirmed feed updates.
540+
* README instructions were followed start-to-finish (serve with `python3 -m http.server 4173 --directory client`) to ensure documentation accuracy.
541+
542+
---
543+
544+
### **Attribution Statement**
545+
546+
> The Pulse demo client (login UI, Pulse Studio composer, token automation, and related documentation) was developed with assistance from **OpenAI ChatGPT (GPT-5)** on November 10, 2025. All generated assets were reviewed, manually tested in the browser, and incorporated into commit `feat(Init): Demo UI Setup Initi (#49)` by the project team.
547+
548+
---
549+
550+
### **Commit / Ticket Reference**
551+
349552
* **Commit:** `feat(security): enable JWT resource server and implement identity resolution from Supabase tokens (refs #10)`
350553
* **Ticket:** `#10 — Service: Implement UserService core logic (Iteration 1)`
351554
* **Date:** February 27, 2025

0 commit comments

Comments
 (0)