Commit graph

43 commits

Author SHA1 Message Date
Ashwin Kumar Sivakumar
63fd3f5135 feat: generate a GST invoice automatically after a successful Tracecoin/PayU purchase
crates/invoice (InvoiceService, GST computation, HTML rendering) was
fully built but never wired to anything and never had its tables —
invoices/invoice_line_items/billing_profiles/invoice_number_seq never
existed in any active migration (same root cause as everything else
this session: only in scripts/init-db.sql, which the real db-migrate
job never runs). Created them, matching InvoiceService's actual
columns exactly rather than init-db.sql's older, simpler invoices
shape.

Fixed a real bug in InvoiceService::create while at it: four money
fields (total, and three line-item amounts) were bound as i64 against
columns/read-models that are i32 everywhere else — would have failed
every insert with a Postgres type mismatch the first time this code
ever actually ran against a real table.

Wired invoice generation into apps/payments' PayU verify_payment
handler (the actual success callback) — right after the wallet is
credited, a one-line-item GST invoice is generated from the purchased
package and PayU's billing fields (firstname/email/phone), using a
new INVOICE_SELLER_* env-configurable seller identity. Generation
failures are logged, not surfaced to the buyer, since the payment and
wallet credit have already succeeded by that point.

Also added the missing user-facing endpoints to fetch what got
generated: GET /api/payments/invoices (list) and
GET /api/payments/invoices/{id} (detail + line items) — previously
only admin-side invoice viewing existed.

NOTE: the frontend (nxtgauge-frontend-solid, a separate repo) has an
existing invoice-viewing page at src/routes/dashboard/wallet/invoices/
but it calls /wallet/me/invoices (no /api/ prefix) via a different,
apparently-dead API helper (api.get, not apiFetch) that every other
live page avoids — same dead-code pattern as the earlier apps/leads
discovery. The live purchase flow (CreditsPage.tsx) has no invoice UI
at all yet. Not fixed here since it's out of this repo's scope this
session — flagging for a frontend pass.
2026-07-21 03:02:47 +05:30
Ashwin Kumar Sivakumar
119c39e184 fix: payments/pricing_packages tables never existed either
Same root cause, found via a systematic diff of every table in
scripts/init-db.sql against what active migrations actually create:
payments and pricing_packages (the Tracecoin/job-slot purchase flow,
apps/payments) were never created by any active migration.
20260317202300_coupons_discounts.up.sql (already deployed) references
payments(id) via FK a few hours later the same day — the earliest
still-live failure point for this table.

Schema uses the final PayU column names (payu_txnid/payu_mihpayid)
directly, matching what apps/payments/src/main.rs actually reads/writes
today, rather than init-db.sql's stale pre-rename Razorpay names —
20260626000000_payu_rename_columns (already deployed) only renames
columns that exist, so starting with the final names outright is
correct and makes that migration a safe no-op.
2026-07-21 02:28:57 +05:30
Ashwin Kumar Sivakumar
36c555dc55 fix: verifications/approval_requests tables never existed — the single biggest gap
The most severe finding in this audit: `verifications` backs the entire
admin approval system this whole session's work depends on (every
role's profile submission, job posting, and requirement approval flow
goes through VerificationRepository). No active migration ever created
it, verification_logs, or approval_requests/approval_logs.

The correct schema for all of these already existed in
scripts/init-db.sql — a "complete schema" reference doc — but that file
is never actually executed by the real migration runner: Dockerfile.migrate
only COPYs crates/db/migrations into the image, and crates/db-migrate's
main.rs only ever reads that directory. init-db.sql has been dead
documentation this whole time, describing the schema this codebase
*should* have without any path to actually get there.

Cross-referencing init-db.sql against the Rust code that reads/writes
these tables found two bugs in init-db.sql itself:
  - verification_logs.verification_request_id pointed at a separate,
    unrelated `verification_requests` table instead of `verifications`
    (already independently discovered and patched by an existing
    migration, 20260718210823_fix_verification_logs_fk — this new
    migration just creates it correctly from the start).
  - approval_requests was missing UNIQUE(entity_type, entity_id), which
    apps/users/src/handlers/verifications.rs's
    `INSERT ... ON CONFLICT (entity_type, entity_id) DO UPDATE` requires.

Positioned before the earliest active migration that already assumed
these tables existed (20260718210823). The custom db-migrate runner
(crates/db-migrate) has no applied-migration tracking — it just re-runs
every *.up.sql file in filename order on every invocation — so there's
no "already applied, don't touch" risk from adding an earlier-dated
migration; idempotent IF NOT EXISTS guards make it safe regardless.
2026-07-21 02:26:15 +05:30
Ashwin Kumar Sivakumar
442dac8c04 fix: portfolio_items/services tables never existed; wallet ledger read used stale column names
Continuing the migration-chain audit: professional portfolio/services
management (PortfolioPage.tsx -> /api/{profession}/portfolio/me,
/api/{profession}/services) was broken the same way as lead_requests —
portfolio_items and services were only ever defined in a disabled .skip
migration (keyed differently: user_id + profession_key, vs. the
user_role_profile_id every live query in
crates/db/src/models/professional.rs actually uses). Self-created both
tables with the schema the live code needs, in the same already-pushed
migration (20260317195000_profession_specific_profiles.up.sql) that was
unconditionally ALTERing them.

Also fixed TracecoinLedgerEntry (professional.rs) — its `type`/`reason`
fields didn't match the `transaction_type`/`reference_type` columns
TracecoinWalletRepository actually writes (see previous commit), so
GET /api/{profession}/wallet/ledger would have failed to deserialize
every row. professional.rs has its own duplicate, unreachable
try_reserve/debit/release_tracecoins using the old type/reason names —
left alone since nothing calls them (send_lead_request and friends all
go through TracecoinWalletRepository).
2026-07-21 02:21:52 +05:30
Ashwin Kumar Sivakumar
94a8a1096a fix: three more already-deployed migrations unconditionally ALTERed tables that were never created
Following the reference_numbers fix, audited every active (non .skip)
migration for the same failure shape — ALTER/CREATE TRIGGER against
lead_requests, tracecoin_wallets, tracecoin_ledger, or job_applications
without ever creating them — since this codebase has a repeated pattern
of table-creation migrations getting silently disabled (renamed .skip)
after the code that depends on them was already written. Found three
more, ALL already pushed to origin, meaning they've likely been
breaking the migration chain since the date each was deployed:

- 20260317195000_profession_specific_profiles.up.sql (Mar 17) — ALTERs
  lead_requests twice. Earliest failure point found for the lead_requests
  chain. Now self-creates a minimal lead_requests table first (no FK to
  `leads`, which isn't created until June 10 — well after this migration).
- 20260318233000_tracecoin_ledger_immutable.up.sql (Mar 18) — creates
  immutability triggers ON tracecoin_ledger, assuming it exists. Now
  self-creates tracecoin_wallets/tracecoin_ledger first, matching the
  column names (transaction_type/reference_type) the Rust code actually
  uses — the only schema that ever existed for these tables (in a
  disabled .skip migration) used stale names (type/reason).
- 20260425000000_ai_usage.up.sql (Apr 25) — ALTERs job_applications
  inside a BEGIN/COMMIT block, so this failure was also rolling back
  company_ai_usage/job_seeker_ai_usage creation in the same file. Now
  self-creates job_applications first.

Each later migration that also touches these tables (this session's
customer/job-seeker/lead_requests fixes) now uses ADD COLUMN IF NOT
EXISTS instead of assuming its own CREATE TABLE ran, so the schema
converges to the same end state regardless of which migration actually
created the table first.

Every touched migration uses IF NOT EXISTS / idempotent guards
throughout, so this is safe to apply whether or not any of these tables
already exist in the real database.
2026-07-21 02:18:23 +05:30
Ashwin Kumar Sivakumar
70e63c6aff fix: lead_requests table never existed, and reference_numbers migration was unconditionally broken
Tracing "can a professional send a request to contact a customer"
surfaced two more breaks in the same family as everything else fixed
this session:

1. crates/db/migrations/20260719120000_reference_numbers.up.sql (not
   yet pushed) unconditionally ran `ALTER TABLE job_applications ...`
   and `ALTER TABLE lead_requests ...`. Neither table was ever created
   by any active (non .skip) migration, so this migration would fail
   outright on a clean apply and block every migration after it in the
   chain — including all of this session's other fixes. Moved the
   reference_number column/trigger/backfill logic for job_applications
   and lead_requests into their own table-creation migrations instead,
   where the tables are guaranteed to exist.

2. lead_requests (LeadRequestRepository, send_lead_request in
   profession_shared.rs, list_requests/approve_request/reject_request
   in apps/customers/src/handlers.rs) was only ever defined in disabled
   .skip migrations, and even those didn't match the columns the
   current Rust code reads/writes (missing professional_user_id and
   reference_number; `message`/`customer_user_id`-only shape instead of
   `remarks`/`requested_at`/`resolved_at`). Added a migration with the
   schema the live code actually needs.

3. Same root cause found for tracecoin_wallets/tracecoin_ledger — only
   ever defined in .skip migrations, and with stale column names
   (`type`/`reason` vs. the `transaction_type`/`reference_type` the
   Tracecoin reservation code in TracecoinWalletRepository actually
   uses. These back the credit reservation that happens when a lead
   request is sent. Created them with CREATE TABLE IF NOT EXISTS (safe
   no-op if they already exist under any name/history) plus a
   best-effort ADD COLUMN IF NOT EXISTS fallback for the stale-name
   scenario.

NOTE: an already-deployed migration (20260318233000_tracecoin_ledger_immutable,
already on origin) creates triggers directly on tracecoin_ledger,
assuming it already exists. That migration was NOT touched here since
editing already-pushed migration history is out of scope for a blind
fix — if tracecoin_ledger doesn't already exist in the real database,
that migration has been failing since it was deployed and needs a
human to check `_sqlx_migrations` / actual schema state directly.
2026-07-21 02:00:23 +05:30
Ashwin Kumar Sivakumar
b5dea58ed4 fix: customer document submission and profile verification
customer_profiles already had custom_data but never got a `status`
column, so — same root cause already fixed for job_seeker_profiles —
the generic profile save/get/submit handlers failed outright for the
CUSTOMER role, and the admin final-approval path couldn't write a
verified status either.

- Migration: add customer_profiles.status (default 'DRAFT').
- Special-case CUSTOMER in the generic profile.rs handlers (get_profile,
  save_profile, fetch_saved_profile, set_profile_status), mirroring the
  existing JOB_SEEKER special-case, storing basic-tab fields under
  custom_data.basic_info.
- Re-enable the CUSTOMER branch in activate_profile_after_final_approval
  now that the status column exists.
- Add the missing POST /api/customers/profile/documents upload endpoint
  — the frontend's document upload (required: Aadhar/Government ID)
  targets this exact path for CUSTOMER and previously 404'd since no
  such route was ever registered. Mirrors the B2-upload-only pattern
  used by the profession apps' shared upload_document handler.

Verified separately: requirement posting (POST /api/customers/requirements)
and requirement submission-for-verification (POST
/api/customers/requirements/:id/submit) already work correctly — both
use the `leads` table (an active migration, despite the model's
"Requirement" naming) and properly create a verification record
(case_type REQUIREMENT_APPROVAL) that lands in admin Verification
Management via the existing approve_requirement/reject_requirement
handlers. No changes needed there.
2026-07-21 01:39:25 +05:30
Ashwin Kumar Sivakumar
28b09aa019 fix: professionals (photographer, tutor, developer, etc.) couldn't submit profiles/documents
The generic profile save/get/submit handlers (apps/users/src/handlers/profile.rs)
have always read and written every non-COMPANY/JOB_SEEKER role's table via
`... WHERE user_role_profile_id = $1`, but that linking column was never
migrated onto any of the 10 profession tables (photographer_profiles,
tutor_profiles, makeup_artist_profiles, developer_profiles,
video_editor_profiles, graphic_designer_profiles,
social_media_manager_profiles, fitness_trainer_profiles,
catering_service_profiles, ugc_content_creator_profiles) — it only existed
in a migration that was disabled (20260415010003, .skip). Every basic-info
save, document upload persistence, and verification submission for these
professions has therefore always failed with "column
user_role_profile_id does not exist".

Adds the column (+ backfill from existing user_role_profiles rows, +
index) to all 10 tables. No application code changes needed — the Rust
handlers were already written correctly for this schema.
2026-07-21 01:19:49 +05:30
Ashwin Kumar Sivakumar
2e95c4750b fix: company job posting, job seeker profile submission, and job applications
- Company approval wrote profile status to 'ACTIVE' (company_profiles'
  own pre-verification default) using an id column that never matched
  any row, so create_job's APPROVED check always rejected newly
  approved companies. Match on user_id for user_id-keyed tables and
  write the canonical 'APPROVED' status.
- job_seeker_profiles was missing columns the job-seeker app has
  always queried (full_name, location, summary, skills,
  active_application_count, status), and the job_applications /
  job_seeker_documents tables it depends on were never migrated in —
  job seeker profile save/submit and job applications failed outright
  with "column/relation does not exist".
- Renamed the job_seeker first_name/last_name split to full_name to
  match what the frontend has always sent.
- Special-cased JOB_SEEKER in the generic profile.rs handlers (mirrors
  the existing COMPANY special-case) so the shared ProfilePage save/
  submit flow, which was routed through a user_role_profile_id-based
  path job_seeker_profiles never had, now persists correctly.
- Fixed apply_to_job's company notification query joining a
  nonexistent "companies" table instead of company_profiles.
- Fixed auto-apply cron's company status filter to match the
  corrected 'APPROVED' status.
2026-07-21 01:00:47 +05:30
Ashwin Kumar Sivakumar
e4c9fc31ee feat: human-readable reference numbers + fix verification document visibility
All checks were successful
build-and-release / build (developers) (push) Successful in 1m42s
build-and-release / build (companies) (push) Successful in 1m48s
build-and-release / build (catering-services) (push) Successful in 1m55s
build-and-release / build (cron) (push) Successful in 2m4s
build-and-release / build (customers) (push) Successful in 2m26s
build-and-release / build (employees) (push) Successful in 1m24s
build-and-release / build (fitness-trainers) (push) Successful in 1m37s
build-and-release / build (gateway) (push) Successful in 1m38s
build-and-release / build (graphic-designers) (push) Successful in 1m54s
build-and-release / build (jobs) (push) Successful in 1m48s
build-and-release / build (leads) (push) Successful in 1m40s
build-and-release / build (job-seekers) (push) Successful in 2m52s
build-and-release / build (photographers) (push) Successful in 1m50s
build-and-release / build (payments) (push) Successful in 2m16s
build-and-release / build (makeup-artists) (push) Successful in 2m48s
build-and-release / build (tutors) (push) Successful in 2m16s
build-and-release / build (social-media-managers) (push) Successful in 2m42s
build-and-release / build (ugc-content-creators) (push) Successful in 2m36s
build-and-release / build (video-editors) (push) Successful in 2m19s
build-and-release / build (users) (push) Successful in 5m10s
Adds a DB-trigger-generated reference_number (NXT-{TYPE}-{YY}-{000001}) to
verifications, support_tickets, payments, job_applications, lead_requests,
and users, replacing raw UUIDs shown to customers/admins. Also fixes
verification-status endpoint to return uploaded documents (previously
omitted, so documents never appeared after submission), and adds a
reference-number lookup endpoint for the AI support assistant.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-19 16:34:00 +05:30
Ashwin Kumar Sivakumar
dbb02e54cc fix(db): stop wiping employees table on every migration run, restore phone column
All checks were successful
build-and-release / build (catering-services) (push) Successful in 1m43s
build-and-release / build (companies) (push) Successful in 1m56s
build-and-release / build (cron) (push) Successful in 2m10s
build-and-release / build (customers) (push) Successful in 2m29s
build-and-release / build (gateway) (push) Successful in 51s
build-and-release / build (fitness-trainers) (push) Successful in 1m22s
build-and-release / build (developers) (push) Successful in 1m50s
build-and-release / build (employees) (push) Successful in 2m42s
build-and-release / build (job-seekers) (push) Successful in 2m1s
build-and-release / build (jobs) (push) Successful in 2m10s
build-and-release / build (graphic-designers) (push) Successful in 2m51s
build-and-release / build (leads) (push) Successful in 2m22s
build-and-release / build (photographers) (push) Successful in 1m42s
build-and-release / build (makeup-artists) (push) Successful in 2m49s
build-and-release / build (payments) (push) Successful in 2m11s
build-and-release / build (social-media-managers) (push) Successful in 2m33s
build-and-release / build (tutors) (push) Successful in 2m36s
build-and-release / build (ugc-content-creators) (push) Successful in 2m12s
build-and-release / build (video-editors) (push) Successful in 2m38s
build-and-release / build (users) (push) Successful in 4m29s
CRITICAL: 20260402030000_strict_employee_separation.up.sql contained an
unconditional DROP TABLE IF EXISTS employees CASCADE followed by a bare
CREATE TABLE, written as a one-time schema transformation back when it was
authored. The db-migrate tool has no applied-migrations tracking table - it
replays every .sql file on every run - which turned that one-time DROP into
a destructive operation that wipes every employee account (including admin
accounts) on every single migration job run. This is what caused today's
"db error while logging in": the phone column (never present in any tracked
migration, added out-of-band in production at some point) was gone after the
recreate, and every employee row - including the account in use this session
- was deleted.

Fix: make the table creation a plain idempotent CREATE TABLE IF NOT EXISTS
(the standalone-schema transition it performed already happened in
production long ago, so the drop was never needed for correctness going
forward). Add a proper migration for the phone column so it's tracked
instead of relying on an undocumented manual ALTER.

Confirmed via kubectl-verified row count (0) and a pre-incident backup
(2026-07-18T21:00:03Z, predates the destructive run) that the deleted row
is recoverable; restoring it separately as a one-time data fix, not part of
this schema migration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-19 05:40:48 +05:30
Ashwin Kumar Sivakumar
bb616c6db1 fix(db): make three more migrations idempotent; log swallowed login DB error
All checks were successful
build-and-release / build (customers) (push) Successful in 1m23s
build-and-release / build (employees) (push) Successful in 1m48s
build-and-release / build (catering-services) (push) Successful in 1m57s
build-and-release / build (companies) (push) Successful in 2m6s
build-and-release / build (cron) (push) Successful in 2m23s
build-and-release / build (gateway) (push) Successful in 51s
build-and-release / build (developers) (push) Successful in 2m44s
build-and-release / build (fitness-trainers) (push) Successful in 1m39s
build-and-release / build (jobs) (push) Successful in 45s
build-and-release / build (graphic-designers) (push) Successful in 2m16s
build-and-release / build (job-seekers) (push) Successful in 2m16s
build-and-release / build (leads) (push) Successful in 1m46s
build-and-release / build (payments) (push) Successful in 2m19s
build-and-release / build (makeup-artists) (push) Successful in 3m0s
build-and-release / build (photographers) (push) Successful in 2m42s
build-and-release / build (social-media-managers) (push) Successful in 2m19s
build-and-release / build (ugc-content-creators) (push) Successful in 2m33s
build-and-release / build (tutors) (push) Successful in 2m42s
build-and-release / build (video-editors) (push) Successful in 2m44s
build-and-release / build (users) (push) Successful in 6m38s
Same class of bug as the ai_plans_and_limits fix: ai_credit_packages and
users_litellm_key used plain CREATE TABLE/ADD COLUMN with no re-run guard,
and payu_rename_columns did a bare RENAME COLUMN that fails outright on any
second run ("column razorpay_order_id does not exist"). All three were
discovered by actually running the db-migrate job end to end for the first
time and fixed in the same pass as the verification_logs FK fix - already
baked into the db-migrate image that was built and run manually, this
commit just brings the source in the repo in sync with what's deployed.

Also: apps/employees login handler's DB error was being discarded via
.map_err(|_| ...) with zero logging, making the reported "db error while
logging in" impossible to diagnose from pod logs. Log the real error.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-19 04:40:31 +05:30
Ashwin Kumar Sivakumar
e80ce2901c fix(db): make ai_plans_and_limits migration idempotent
All checks were successful
build-and-release / build (cron) (push) Successful in 48s
build-and-release / build (catering-services) (push) Successful in 1m31s
build-and-release / build (companies) (push) Successful in 1m34s
build-and-release / build (developers) (push) Successful in 1m59s
build-and-release / build (customers) (push) Successful in 2m10s
build-and-release / build (employees) (push) Successful in 2m15s
build-and-release / build (gateway) (push) Successful in 59s
build-and-release / build (jobs) (push) Successful in 46s
build-and-release / build (graphic-designers) (push) Successful in 1m33s
build-and-release / build (fitness-trainers) (push) Successful in 2m44s
build-and-release / build (makeup-artists) (push) Successful in 1m53s
build-and-release / build (job-seekers) (push) Successful in 2m30s
build-and-release / build (leads) (push) Successful in 2m32s
build-and-release / build (photographers) (push) Successful in 2m33s
build-and-release / build (payments) (push) Successful in 2m53s
build-and-release / build (social-media-managers) (push) Successful in 2m38s
build-and-release / build (ugc-content-creators) (push) Successful in 2m19s
build-and-release / build (tutors) (push) Successful in 2m53s
build-and-release / build (video-editors) (push) Successful in 2m14s
build-and-release / build (users) (push) Successful in 4m35s
The db-migrate job (crates/db-migrate) has no applied-migrations tracking
table - it replays every .sql file on every run, relying on each file being
idempotent (IF NOT EXISTS / ON CONFLICT), which is the pattern virtually
every other migration in this directory follows. This one wasn't: plain
CREATE TABLE/CREATE INDEX and two INSERTs with no ON CONFLICT guard.

Since the tables/data already exist from this file's one successful run,
every subsequent migration job run failed immediately on
"relation ai_plans already exists" - before ever reaching any migration
after it, including ones genuinely needed (see the verification_logs FK fix
two commits back). Confirmed via a live job run: this was the actual reason
db-migrate had never completed successfully before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-19 03:14:02 +05:30
Ashwin Kumar Sivakumar
466e7abf03 fix(db): point verification_logs FK at verifications, not legacy verification_requests
Some checks failed
build-and-release / build (gateway) (push) Successful in 55s
build-and-release / build (graphic-designers) (push) Successful in 2m13s
build-and-release / build (social-media-managers) (push) Has been cancelled
build-and-release / build (video-editors) (push) Has been cancelled
build-and-release / build (employees) (push) Successful in 2m0s
build-and-release / build (developers) (push) Successful in 2m43s
build-and-release / build (leads) (push) Successful in 1m49s
build-and-release / build (photographers) (push) Successful in 2m17s
build-and-release / build (tutors) (push) Has been cancelled
build-and-release / build (cron) (push) Successful in 47s
build-and-release / build (companies) (push) Successful in 2m6s
build-and-release / build (jobs) (push) Successful in 44s
build-and-release / build (customers) (push) Successful in 2m12s
build-and-release / build (fitness-trainers) (push) Successful in 2m20s
build-and-release / build (payments) (push) Successful in 2m45s
build-and-release / build (makeup-artists) (push) Successful in 3m10s
build-and-release / build (users) (push) Has been cancelled
build-and-release / build (ugc-content-creators) (push) Has been cancelled
build-and-release / build (catering-services) (push) Successful in 1m36s
build-and-release / build (job-seekers) (push) Successful in 2m22s
scripts/init-db.sql created verification_logs.verification_request_id with a
foreign key against verification_requests(id) - an unrelated legacy table.
VerificationRepository::update_status inserts the verifications.id (the row
actually being approved/rejected) into that column on every status change,
which has been violating the FK on every single call:

  "insert or update on table verification_logs violates foreign key
   constraint verification_logs_verification_request_id_fkey"

This made every Approve/Reject click in Verification Management 500,
confirmed via the browser's actual response body. Drop and recreate the
constraint to point at verifications(id), which is what the code has always
actually been logging against.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-19 03:01:25 +05:30
Tracewebstudio Dev
0163349988 fix: skip broken migrations that reference dropped professionals table
All checks were successful
build-and-release / build (companies) (push) Successful in 1m39s
build-and-release / build (cron) (push) Successful in 52s
build-and-release / build (catering-services) (push) Successful in 2m9s
build-and-release / build (developers) (push) Successful in 1m32s
build-and-release / build (customers) (push) Successful in 1m51s
build-and-release / build (employees) (push) Successful in 1m52s
build-and-release / build (gateway) (push) Successful in 2m1s
build-and-release / build (fitness-trainers) (push) Successful in 2m11s
build-and-release / build (job-seekers) (push) Successful in 1m54s
build-and-release / build (graphic-designers) (push) Successful in 2m15s
build-and-release / build (leads) (push) Successful in 1m39s
build-and-release / build (jobs) (push) Successful in 2m9s
build-and-release / build (makeup-artists) (push) Successful in 2m39s
build-and-release / build (photographers) (push) Successful in 1m52s
build-and-release / build (tutors) (push) Successful in 2m31s
build-and-release / build (ugc-content-creators) (push) Successful in 2m43s
build-and-release / build (payments) (push) Successful in 4m9s
build-and-release / build (social-media-managers) (push) Successful in 4m8s
build-and-release / build (video-editors) (push) Successful in 2m39s
build-and-release / build (users) (push) Successful in 7m7s
Several migrations reference a professionals table that was replaced by
per-profession profile tables in 20260317195000. Rename to .skip so
sqlx migrate run succeeds on a fresh local dev database. Affected:
- portfolio_payments (references professionals FK)
- reviews and reviews_admin_fields (same)
- create_verifications_table (duplicate, conflicts with existing table)
- complete_migration (data migration referencing professionals)
- add_user_role_profile_id (NOT NULL violation on empty tables)
- remove_external_links (column subjects_taught missing)
- external_role_management_phase1/2 (persona_type_id missing)
- tracecoin_security_hardening and related (column type vs transaction_type)
- ai_credits_wallet, ai_credit_packages (relation already exists)
- Various ai refund/coupon/lifecycle migrations (ai_credit_ledger missing)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 00:48:50 +02:00
Ashwin Kumar Sivakumar
f5201965d8 Issue each account its own LiteLLM virtual key instead of the shared master key
All checks were successful
build-and-release / build (cron) (push) Successful in 5m1s
build-and-release / build (catering-services) (push) Successful in 9m1s
build-and-release / build (customers) (push) Successful in 9m3s
build-and-release / build (developers) (push) Successful in 9m23s
build-and-release / build (employees) (push) Successful in 10m36s
build-and-release / build (companies) (push) Successful in 10m59s
build-and-release / build (gateway) (push) Successful in 3m26s
build-and-release / build (fitness-trainers) (push) Successful in 8m52s
build-and-release / build (jobs) (push) Successful in 4m46s
build-and-release / build (graphic-designers) (push) Successful in 8m44s
build-and-release / build (job-seekers) (push) Successful in 9m22s
build-and-release / build (makeup-artists) (push) Successful in 8m33s
build-and-release / build (leads) (push) Successful in 10m17s
build-and-release / build (payments) (push) Successful in 8m40s
build-and-release / build (photographers) (push) Successful in 9m36s
build-and-release / build (social-media-managers) (push) Successful in 8m38s
build-and-release / build (tutors) (push) Successful in 8m42s
build-and-release / build (ugc-content-creators) (push) Successful in 7m27s
build-and-release / build (video-editors) (push) Successful in 7m46s
build-and-release / build (users) (push) Successful in 10m0s
register() now generates a per-account LiteLLM key (best-effort, non-blocking)
and stores it on the user. New internal endpoint GET /internal/users/{id}/llm-key
lets other services fetch (or lazily backfill) an account's key, authenticated
via the existing X-AI-Service-Key shared secret.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-16 20:29:00 +05:30
Ashwin Kumar Sivakumar
0dd5045676 feat: Complete Ask Ash AI Credits implementation on high-performance branch (Tasks 1-10)
- Task 1: Admin endpoints for wallet management
- Task 2: AI Credits admin UI (pricing.tsx, credit.tsx)
- Task 3: Ollama security (NetworkPolicy, prompt validation, audit)
- Task 4: LiteLLM integration (litellm.rs, migrated AI feature handlers)
- Task 5: Refund architecture (ai_refunds table, endpoints)
- Task 6: Coupons, promotions, referrals (order creation with coupon)
- Task 7: Subscription lifecycle (plan upgrades/downgrades, cron jobs)
- Task 8: Credit expiration enforcement (daily cron task)
- Task 9: Token cost engine (ai_model_cost_config, margin view)
- Task 10: Observability (metrics tables, aggregation function)

Cherry-picked from main branch commit 3c0f45f
2026-07-06 01:49:16 +05:30
Tracewebstudio Dev
eb009ac3d0 feat: profile photo upload, PDF resume generation, AI auto-apply, schema fixes
- Profile photo upload: POST /api/profile/photo for all roles, stores via B2 storage
- PDF resume: auto-generated from job seeker portfolio on every profile save (printpdf)
- Company applications: enriched with applicant name, avatar, headline, skills, education
- AI auto-apply cron: rewrote run_auto_apply with correct schema (job_seeker_profiles,
  cover_note, ai_auto_apply_settings, ai_auto_apply_logs, credit deduction)
- Schema fix: job_seeker_profiles table name (was incorrectly 'job_seekers' in two places)
- Migration: add resume_url column to job_seeker_profiles
- Migrations: PayU rename, tracecoin hardening, lead reserve linkage, invoice/wallet crates
- PayU integration: ai_credits, packages, admin payment handlers
- Wallet and invoice crates added

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-02 13:31:06 +02:00
Ashwin Kumar Sivakumar
c85e6af22e feat(ai): complete AI plans/credits implementation and build tooling
- Add AI plans, credits, model routing, LiteLLM client, and orchestrator services
- Add AI management endpoints, auto-apply/auto-request handlers, and log endpoints
- Add cron jobs for daily action reset and monthly credit reset
- Add AI credit purchase flow in payments service
- Add ai_credit_packages migration with seed data
- Update Dockerfile build tooling across services
2026-06-15 06:15:49 +05:30
Tracewebstudio Dev
2c6d102205 fix(e2e): 14 bug fixes across users, leads, gateway, KB, and reviews
DB:
- Add niche_tags column to ugc_content_creator_profiles (was blocking UGC service)
- Add turnaround_days and fix user_role_profile_id NOT NULL for UGC
- leads/lead_requests tables (already created in session 1)

Code:
- Add UGC_CONTENT_CREATOR to is_professional_role() to auto-create user_role_profiles
- Fix onboarding INSERT to include user_id for photographer_profiles
- Fix send_lead_request_ai to use correct customer_user_id (was self-notifying)
- Add PATCH /api/leads/:id support + mount leads at /api/* for gateway compatibility
- Fix admin_list_cases query (WHERE was using wrong params)
- Fix admin_get_case query (was using list query instead of fetch-by-id)
- Add GET /api/me in profile.rs (moved from onboarding)
- Add KB articles by ID route /api/kb/articles/id/{id}
- Rewrite reviews handlers to match actual reviews table schema
- Add public reviews router GET /api/reviews

Gateway:
- Add /api/reviews route to users service
2026-06-10 16:17:10 +02:00
Ashwin Kumar Sivakumar
d48983ee21 feat(ai): Phase 4 - multilingual, voice, A/B testing, analytics (with stubs)
Some checks failed
build-and-push / detect-changes (push) Failing after 0s
build-and-push / build (catering-services) (push) Failing after 0s
build-and-push / build (companies) (push) Has been skipped
build-and-push / build (cron) (push) Has been skipped
build-and-push / build (customers) (push) Has been skipped
build-and-push / build (developers) (push) Has been skipped
build-and-push / build (fitness-trainers) (push) Has been skipped
build-and-push / build (employees) (push) Failing after 0s
build-and-push / build (gateway) (push) Has been skipped
build-and-push / build (graphic-designers) (push) Has been skipped
build-and-push / build (job-seekers) (push) Failing after 0s
build-and-push / build (jobs) (push) Has been skipped
build-and-push / build (leads) (push) Has been skipped
build-and-push / build (tutors) (push) Has been skipped
build-and-push / build (makeup-artists) (push) Failing after 0s
build-and-push / build (payments) (push) Has been skipped
build-and-push / build (photographers) (push) Has been skipped
build-and-push / build (social-media-managers) (push) Failing after 0s
build-and-push / build (users) (push) Has been skipped
build-and-push / build (ugc-content-creators) (push) Has been skipped
build-and-push / build (video-editors) (push) Has been skipped
2026-06-08 06:41:10 +05:30
Ashwin Kumar Sivakumar
088e467e58 feat(ai): Phase 3 - RAG, streaming, rate limiting, feedback 2026-06-08 06:15:58 +05:30
Ashwin Kumar Sivakumar
cc11657236 feat(ai): Phase 2 - functional endpoints with personas and pillars 2026-06-08 05:50:17 +05:30
Tracewebstudio Dev
aa71ccdf36 Add AI endpoints and gateway route fix
- Fix gateway: add /api/ai route to users_url
- Add AI job field generation endpoints (generate-job-field, generate-cover-letter, tailor-resume, auto-apply)
- Add AI usage tracking and rate limiting
- Add professional auto-respond-to-lead endpoint (30 tracecoins)
- Add DB migrations for AI usage tracking tables
- Update leads service with AI auto-respond functionality
2026-05-01 02:54:42 +02:00
Tracewebstudio Dev
5946bfe3a8 chore: checkpoint workspace updates 2026-04-26 23:58:43 +02:00
Tracewebstudio Dev
f7e18cd4d6 feat: pricing packages with multi-select roles, lead requests, mock checkout 2026-04-13 01:36:13 +02:00
Tracewebstudio Dev
2e283e5d67 feat(db): add complete migration and update extension models to use user_role_profile_id
- Add comprehensive migration script for database schema redesign
- Update all extension profile models to reference user_role_profile_id
- Create user_role_profiles as root table for all role profiles
- Remove external portfolio links (github_url, portfolio_url, reel_url)
- Rename applications→job_applications, requirements→leads
- Drop deprecated tables (professionals, onboarding_submissions, etc.)
2026-04-12 23:55:08 +02:00
Tracewebstudio Dev
03376b9567 feat: Add database redesign documentation and Phase 1-2 migrations
- Add schema_audit.md documenting current schema issues
- Add target_schema.md with complete target schema design
- Add old_to_new_mapping.md with table mapping
- Add migration_plan.md with phased migration strategy
- Add Phase 1 migrations (core infrastructure):
  - user_sessions table
  - users missing columns
  - departments updates
  - designations updates
  - employees updates
- Add Phase 2 migrations (profile domain - CRITICAL):
  - create user_role_profiles root table
  - backfill user_role_profiles from existing profiles
  - add user_role_profile_id to extension tables
  - remove forbidden external portfolio links
- Add user_role_profile Rust model
- Update photographer model to use user_role_profile_id
2026-04-12 23:21:11 +02:00
Ashwin Kumar
2ded64e71b feat: extend admin/user flows with settings, verification, and approval updates 2026-04-08 22:40:54 +02:00
Ashwin Kumar
5cd00b74bc feat: implement user verification system and database migrations 2026-04-06 03:39:41 +02:00
Ashwin Kumar
89b055b329 Add UGC Content Creator microservice (10th professional role)
- New service at apps/ugc_content_creators (port 8095)
- DB model + repository in crates/db/src/models/ugc_content_creator.rs
- Migration: ugc_content_creator_profiles table with platforms, content_niches,
  content_formats, follower_count, handles, and standard status/timestamps
- Contracts: is_professional_profile_approved() handles UGC_CONTENT_CREATOR case
- Gateway: routes /api/ugc-content-creators to new service
- Workspace Cargo.toml updated with new member

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 21:14:02 +02:00
Ashwin Kumar
3935277fb7 Fix backend compile errors after schema migrations
- employees.rs: rewrite for new standalone schema (email/password_hash,
  no user_id/role_id FK — matches 20260402030000 migration)
- migration: DROP old employees table before CREATE (old schema incompatible)
- pricing.rs: merge if-else sqlx::query! branches into single nullable param query
- kb.rs: fix target_roles Option<Vec<String>> unwrap, category_id Some() wrapping
- support.rs: fix .or() call with non-optional user_email (use Some())
- roles.rs: fix employees JOIN from role_id (deleted) to role_code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 02:25:47 +02:00
Ashwin Kumar
d900c361d8 Add reviews, coupons, discounts, pricing packages, and reports handlers
- handlers/reviews.rs: admin CRUD for /api/admin/reviews (list, create, patch status, delete)
- handlers/coupons.rs: admin CRUD for /api/admin/coupons and /api/admin/discounts
- handlers/pricing.rs: admin CRUD for /api/admin/tracecoin-packages + /api/admin/reports/{users,revenue}
- handlers/dashboard.rs: replace all hardcoded fake data with real DB queries (registrations per day, revenue per week, live KPIs including pending approvals and total revenue)
- Migrations: extend reviews table (nullable FKs + admin fields), add coupons.title/role_keys, create discounts table
- gateway: route new admin paths to users service

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 18:09:50 +02:00
Ashwin Kumar
96f9da2cdb feat: add KB and support ticket system
- 2 new migrations: summary/tags columns on kb_articles, description/requester fields on support_tickets
- handlers/kb.rs: public routes (GET /api/kb/categories|articles|articles/:slug) + admin CRUD (/api/admin/kb/*)
- handlers/support.rs: user ticket routes + admin support-cases CRUD with internal notes
- Registered all new routes in users service main.rs
- Gateway resolve_upstream: /api/kb/*, /api/support/*, /api/admin/kb/*, /api/admin/support-cases/* → users service
- scripts/seed_kb.sql: 8 categories, 28 full-length published articles covering all user roles

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 13:36:12 +02:00
Ashwin Kumar
446b6322de feat(admin): wire management modules to live backend and add UGC role 2026-04-02 13:09:43 +02:00
Ashwin Kumar
3b28d9fd36 feat: add designation management CRUD backend
Full CRUD handler for designations with department JOIN, employee count,
level/can_manage_team/can_approve fields, and migration to extend the
minimal designations table with all management columns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 19:20:55 +01:00
Ashwin Kumar
89d9e3b861 chore: sync local changes 2026-03-26 20:58:43 +01:00
Ashwin Kumar
b82f294331 chore: checkpoint current workspace changes 2026-03-25 22:15:07 +01:00
Ashwin Kumar
91534d74c0 chore: checkpoint current workspace changes 2026-03-22 15:55:29 +01:00
Ashwin Kumar
3b6d0f4951 feat(backend): enforce profile approvals and complete migration approval flows 2026-03-19 00:30:23 +01:00
Ashwin Kumar
9764a7acdd feat: commit remaining service files, migrations, and model updates
- gateway, companies, customers, job_seekers apps updated
- users config/mod/mail handlers
- auth middleware and jwt crate updates
- db models: user, config, mod updates
- all remaining migrations: portfolio, notifications, reviews, kb, support, coupons, onboarding states

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 22:59:47 +01:00
Ashwin Kumar
bb8155dd27 feat: add Redis for OTP, auth tokens, rate limiting, lead dedup and marketplace cache
- Add crates/cache with client, otp, rate_limit, token, lead, jobs modules
- OTP tokens stored in Redis (15-min TTL, single-use GETDEL on verify)
- Refresh tokens stored in Redis (30-day TTL) — removed DB storage
- Password reset tokens stored in Redis (1-hour TTL, single-use)
- Rate limiting: register (10/hr), login (10/15min), OTP resend (3/hr), lead (5/hr), job post (20/hr)
- Lead request deduplication: 24-hour Redis lock per professional+requirement pair
- Marketplace listings cached in Redis (5-min TTL per profession+page+limit)
- Add ProfessionState{pool, redis} to contracts crate, replacing bare PgPool in all 9 profession apps
- All profession handlers and main.rs updated to use ProfessionState
- REDIS_URL env var (default: redis://127.0.0.1:6379) used across all services
- Fix profession model struct name mangling in 6 handlers (MakeupArtistRepository etc.)
- Add custom_data JSONB migration for all 9 profession profile tables
- Add onboarding_state model and repository (save_progress, complete, is_complete)
- Add onboarding handler accepting roleKey:String (not role_id:UUID) for frontend compat

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 22:58:42 +01:00
Ashwin Kumar
5640cd4ee5 feat: complete rust microservices migration with real db logic 2026-03-17 20:42:51 +01:00