Commit graph

430 commits

Author SHA1 Message Date
Ashwin Kumar Sivakumar
67d372c160 ci: remove GitHub Actions workflow - using Forgejo CI exclusively
- Remove build-and-deploy-forgejo.yml from GitHub Actions
- Forgejo CI at ci.nxtgauge.com now handles all builds and deployments
- All images pushed to Forgejo registry (ci.nxtgauge.com/ashwin/*)
- GitOps updates handled by Forgejo workflows
2026-07-06 04:19:40 +05:30
Ashwin Kumar Sivakumar
b8939e6384 fix(k8s): switch db-migrate image from GHCR to Forgejo registry 2026-07-06 03:52:54 +05:30
Ashwin Kumar Sivakumar
6b1b38e04a fix(docker-compose): switch from GHCR to Forgejo registry 2026-07-06 03:52:35 +05:30
Ashwin Kumar Sivakumar
76e8646c7c fix(ci): switch from GHCR to Forgejo registry
- Update workflow to push to ci.nxtgauge.com/ashwin/*
- Use FORGEJO_USERNAME and FORGEJO_TOKEN secrets
- Fix gitops repo cloning to use x-access-token
- Add ai-assistant to deployment scripts
2026-07-06 03:49:11 +05:30
Ashwin Kumar Sivakumar
cba7f607cd fix: resolve all warnings and errors
- Add #![allow(dead_code)] pragma to all main.rs files
- Remove unused imports from users handlers (ai_cache, AiCreditPackageRepository, AiCreditTransactionRepository)
- Make LiteLLMChatMessage and LiteLLMChoice public with public fields
- Fix remaining unused variables with cargo fix
- Add missing pub visibility modifiers to litellm structs

All packages now compile with ZERO warnings and errors!
2026-07-06 03:00:37 +05:30
Ashwin Kumar Sivakumar
b99651f330 fix: resolve warnings (partial)
- Fix unused variable entry_type -> _entry_type
- Remove unused imports BufMut and cache_jobs from companies handlers
- Fix doc comment on lazy_static
- Add #[allow(dead_code)] to reset_daily_actions and reset_monthly_credits
- Fix unused imports in job_seekers handlers
2026-07-06 02:55:42 +05:30
Ashwin Kumar Sivakumar
e83271c300 fix: resolve payments package compilation errors
- Remove duplicate 'name' field from PricingPackageRow struct
- Add tracecoins_credited variable from package.tracecoins_amount
- Change rust_decimal to use i32 instead of Decimal for SQL compatibility
- Simplify discount calculation to work with paise (integer) values
- Fix payu config field names (merchant_key, merchant_salt)

payments package now compiles successfully.
2026-07-06 02:32:14 +05:30
Ashwin Kumar Sivakumar
0ac0527232 fix: resolve match arm type mismatches and add Deserialize trait
- Fix match arm type errors in ai.rs: wrap bare String returns in (String, bool)
  tuples to match expected return type (response_text, _ollama_used)
- Add Deserialize trait to LiteLLMChatMessage for deserialization
- Add missing fields to GenerateFieldResponse constructors
- Remove body.user_id reference from form extraction (field doesn't exist)
- Add get_llm_base_url() and get_llm_model() helper functions

users package now compiles successfully (only warnings remain).
2026-07-06 02:27:09 +05:30
Ashwin Kumar Sivakumar
339325091c fix: resolve cherry-pick breakage and add missing modules
- Restore deleted module declarations (tutor, ugc_content_creator, user,
  user_role_profile, verification, video_editor) in db/models/mod.rs
- Add mod ai; to users/src/main.rs (fixes crate::ai import)
- Add pub mod ai_auto; to handlers/mod.rs
- Add rust_decimal dependency to payments/Cargo.toml
- Fix missing PgPool import in payments/src/ai_credits.rs
- Make LiteLLMUsage fields public in users/src/litellm.rs
- Add get_llm_base_url() and get_llm_model() helper functions
- Remove leading underscore from variables that are used

Partial fix for high-performance branch build issues.
2026-07-06 02:23:29 +05:30
Ashwin Kumar Sivakumar
4f2683d085 chore: remove legacy AI quota system
Delete legacy code that used old company_ai_usage/job_seeker_ai_usage tables:
- Remove has_active_ai_pack() - old AI_PACK pricing package check
- Remove check_and_increment_usage() - legacy daily quota tracking
- Remove BASE_AI_LIMIT, get_ai_limit_for_package constants/functions
- Remove legacy queries from ai_auto_apply() and ai_usage_status()
- Update auto_apply.rs to use user_ai_subscriptions.daily_actions_used
  instead of job_seeker_ai_usage table
- Inline apply_scheduled_downgrades() and expire_trials() in cron tasks
  to remove dependency on users crate internal modules

The new system uses user_ai_subscriptions with:
- daily_actions_used / daily_credits_used counters
- monthly_credits_total / monthly_credits_used
- purchased_credits_total / purchased_credits_used

All AI billing now flows through the wallet/ledger system with
LiteLLM integration (Tasks 1-10).
2026-07-06 02:14:23 +05:30
Ashwin Kumar Sivakumar
c795242040 chore: remove broken company_ai_credits stub
- Delete apps/companies/src/handlers/ai.rs (broken placeholder code)
- Remove ai module export from handlers/mod.rs
- Remove /api/companies/ai route from main.rs

The broken stub had:
- Uuid::parse_str("placeholder") that always errored
- Uuid::new_v4() generating random IDs instead of using auth
- Queries to non-existent company_ai_credits/ai_usage_log tables

AI credits are now properly handled by the users service with
the new ai_credits module (wallet, ledger, LiteLLM integration).
2026-07-06 02:08:07 +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
Ashwin Kumar Sivakumar
f5831da1f5 ci(forgejo): update backend build pipeline 2026-07-03 19:51:37 +05:30
Ashwin Kumar Sivakumar
fcb40c3590 ci: sync GitHub pushes to Forgejo 2026-07-03 18:59:02 +05:30
Ashwin Kumar Sivakumar
fda72c8698 fix(auth): add logging for role assignment debugging
- Enhanced logging for role assignment to track intent/profession
- Better error handling for role insertion
2026-07-03 17:40:19 +05:30
Ashwin Kumar Sivakumar
eaae3d470f Fix /api/ai/* returning 500 on every request, close credit-minting bugs, add grounding guardrail
Critical: ai_access_middleware was wired via from_fn_with_state((), ...)
- passing the unit type as state - and pulled AppState from request
extensions, which nothing ever populated. Every request through
/api/ai/* and /api/ai/auto/* returned 500 INCOMPLETE_CONTEXT. Fixed by
extracting State<AppState> properly and passing the real state at both
call sites; removed the redundant, identically-broken inner middleware
layer inside ai_router().

Security: ai_addon_purchase (/api/ai/addons/purchase, /api/ai/credits/buy)
and ai_plan_upgrade (/api/ai/plans/upgrade) granted AI credits / plan
upgrades (including enterprise) with zero payment verification - any
authenticated user could mint unlimited free credits, and the frontend
already called this directly. Disabled both until wired to a real
payment flow.

Quality: added a grounding/anti-hallucination system prompt applied to
every AI feature call (orchestrator::call_feature /
call_feature_with_plan, plus the handful of call sites that bypass the
orchestrator). Verified against the live model that it reduces but does
not eliminate fabrication on harder reasoning tasks - even the larger
model invents facts not present in the input on some prompts. This is a
real limitation of the two locally-hosted models, not something a
system prompt alone fully solves; flagged for follow-up (e.g. a
verification pass or deterministic checks for high-stakes decisions
like auto-apply).

Also fixed Persona/Pillar keyword detection using naive substring
matching (e.g. "team" matching inside "esteemed", "lead" matching
inside "leadership") - added a word-boundary-aware contains_word()
helper and applied it to all keyword classifiers in this file.
2026-07-03 04:05:14 +05:30
Ashwin Kumar Sivakumar
64089e4da3 Replace Razorpay payment integration with PayU hosted checkout
The frontend (lib/payu.ts, payu-return.tsx) and admin config UI had
already switched to PayU, but the payments service was still calling
Razorpay's order API and verifying Razorpay HMAC signatures -
payments were broken end to end. Rewrites apps/payments to PayU's
hash-based hosted-checkout flow (SHA-512 request/response hash,
key+salt from admin config or PAYU_MERCHANT_KEY/PAYU_SALT), for both
the tracecoin wallet purchase flow and the AI credits flow. The AI
credits frontend checkout was also fabricating a fake payment_id and
signature client-side instead of ever opening a real PayU checkout -
fixed to use the same real flow as tracecoin purchases.

Also fixes the ai_create_ticket endpoint on the users service, which
never validated the X-AI-Service-Key header despite the client
sending one - anyone could create tickets under an arbitrary user_id.
2026-07-02 18:31:07 +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
c9d0e283ac Merge branch 'high-performance' of https://github.com/Traceworks2023/nxtgauge-backend-rust into high-performance 2026-07-02 06:51:14 +05:30
Ashwin Kumar Sivakumar
0b88294486 Update Dockerfile.simple 2026-07-02 06:51:03 +05:30
Tracewebstudio Dev
5082427279 Wire admin Razorpay gateway config 2026-06-26 21:07:36 +02:00
Tracewebstudio Dev
cd3fbfe7ca Integrate Razorpay checkout payments 2026-06-26 20:48:41 +02:00
Ashwin Kumar Sivakumar
4bfb5b4418 Update Forgejo backend publish workflow 2026-06-17 03:28:46 +05:30
Ashwin Kumar Sivakumar
a38a2fd185 fix(ci): isolate gitops checkout dir 2026-06-16 03:29:01 +05:30
Ashwin Kumar Sivakumar
d2e7aee81b fix(ci): retry gitops sync pushes 2026-06-16 01:26:33 +05:30
Ashwin Kumar Sivakumar
46a0758335 fix(ci): run backend deploys on self-hosted runners 2026-06-16 00:50:01 +05:30
Ashwin Kumar Sivakumar
c1c9d246eb feat(ai): improve ask ash direct responses 2026-06-15 16:59:56 +05:30
Ashwin Kumar Sivakumar
06e73eebb5 fix(ai): align backend plans and clean warnings 2026-06-15 09:23:44 +05:30
Ashwin Kumar Sivakumar
09465824ad fix(ai): improve ask ash chat responses 2026-06-15 06:50:08 +05:30
Ashwin Kumar Sivakumar
0c2ce413f9 Merge remote high-performance: keep new AI plans implementation and resolve conflicts 2026-06-15 06:18:52 +05:30
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
ba63736e46 feat: add AI management endpoints and LiteLLM support
User-facing AI endpoints:
- GET /api/ai/usage/v2 - extended with addon_balance, renewal_date
- POST /api/ai/addons/purchase - purchase addon packs
- POST /api/ai/plans/upgrade - upgrade AI plans

Admin AI endpoints:
- GET /api/admin/ai/stats - AI usage statistics
- GET /api/admin/ai/users - paginated user AI usage list
- GET /api/admin/ai/plans - list AI plans

Files:
- apps/users/src/handlers/admin_ai.rs (new)
2026-06-14 20:28:26 +02:00
Ashwin Kumar Sivakumar
74dad77614 fix(ci): deploy via gitops from github actions 2026-06-14 23:06:24 +05:30
Ashwin Kumar Sivakumar
ccf57df0c7 fix(ci): deploy via gitops from github actions 2026-06-14 23:05:23 +05:30
Ashwin Kumar Sivakumar
22ee7f8544 fix(ci): simplify backend github deployment workflow 2026-06-14 23:00:37 +05:30
Ashwin Kumar Sivakumar
06789f2b61 fix(ci): simplify backend github deployment workflow 2026-06-14 22:59:51 +05:30
Ashwin Kumar Sivakumar
be6c238691 fix(ci): use lowercase ghcr image names 2026-06-14 22:58:26 +05:30
Ashwin Kumar Sivakumar
8153105c77 fix(ci): use lowercase ghcr image names 2026-06-14 22:57:54 +05:30
Ashwin Kumar Sivakumar
8188072b08 ci: deploy backend via github actions and ghcr 2026-06-14 22:52:53 +05:30
Ashwin Kumar Sivakumar
9b03bec22f ci: deploy backend via github actions and ghcr 2026-06-14 22:49:06 +05:30
Tracewebstudio Dev
a4af5c2c06 feat: add LiteLLM support and auto-apply cron job
- Add get_llm_base_url() and get_llm_model() helper functions
- Update call_ollama_inline to route to LiteLLM when LLM_PROVIDER=litellm
- Add auto-apply cron task for background job matching
- Auto-apply matches job seekers to new jobs based on skills
- Generate cover letters via LiteLLM for each application
2026-06-14 18:00:38 +02:00
Ashwin Kumar Sivakumar
ac3fef72a1 fix(users): allow demo login without redis 2026-06-14 15:56:51 +05:30
Ashwin Kumar Sivakumar
9b3bc98b38 fix(companies): restore backend build 2026-06-14 06:08:00 +05:30
Ashwin Kumar Sivakumar
349673b7f8 fix(ci): unify backend build flow through forgejo 2026-06-14 01:20:24 +05:30
Ashwin Kumar Sivakumar
de1b6fe828 chore: trigger build
Some checks failed
build-all / build-users (push) Failing after 2s
build-all / build-cron (push) Failing after 2s
build-services / build-gateway (push) Failing after 4s
build-services / build-users (push) Failing after 3s
build-services / build-jobs (push) Failing after 2s
build-services / build-leads (push) Failing after 3s
build-services / build-cron (push) Failing after 3s
build-all-services / build (push) Failing after 2s
build-and-push / detect-changes (push) Successful in 32s
build-and-push / build (developers) (push) Failing after 2s
build-gateway / build (push) Failing after 30s
build-and-push / build (catering-services) (push) Failing after 2s
build-and-push / build (companies) (push) Failing after 3s
build-and-push / build (employees) (push) Failing after 3s
build-and-push / build (fitness-trainers) (push) Failing after 2s
build-and-push / build (gateway) (push) Failing after 2s
build-and-push / build (graphic-designers) (push) Failing after 3s
build-and-push / build (job-seekers) (push) Failing after 2s
build-and-push / build (jobs) (push) Failing after 2s
build-and-push / build (leads) (push) Failing after 2s
build-and-push / build (makeup-artists) (push) Failing after 2s
build-and-push / build (payments) (push) Failing after 2s
build-and-push / build (photographers) (push) Failing after 3s
build-and-push / build (social-media-managers) (push) Failing after 3s
build-and-push / build (tutors) (push) Failing after 3s
build-and-push / build (ugc-content-creators) (push) Failing after 3s
build-and-push / build (users) (push) Failing after 3s
build-and-push / build (video-editors) (push) Failing after 3s
build-and-push / build (cron) (push) Successful in 6m15s
build-and-push / build (customers) (push) Successful in 9m40s
2026-06-13 23:29:43 +05:30
Ashwin Kumar Sivakumar
6dfb7a1a2e chore: rebuild all services 2026-06-13 21:33:02 +05:30
Ashwin Kumar Sivakumar
a7501eafc8 chore: rebuild all - clean build 2026-06-13 20:41:38 +05:30
Ashwin Kumar Sivakumar
1c9b4848a9 feat: Add Dockerfiles for jobs/leads services and build scripts
Some checks failed
build-all / build-users (push) Failing after 1s
build-all / build-cron (push) Failing after 2s
build-gateway / build (push) Failing after 4s
build-services / build-gateway (push) Failing after 3s
build-services / build-users (push) Failing after 5s
build-services / build-jobs (push) Failing after 3s
build-and-push / detect-changes (push) Successful in 8s
build-services / build-cron (push) Failing after 2s
build-services / build-leads (push) Failing after 4s
build-all-services / build (push) Failing after 3s
build-and-push / build (cron) (push) Failing after 5s
build-and-push / build (customers) (push) Failing after 3s
build-and-push / build (employees) (push) Failing after 3s
build-and-push / build (developers) (push) Failing after 3s
build-and-push / build (fitness-trainers) (push) Failing after 4s
build-and-push / build (gateway) (push) Failing after 3s
build-and-push / build (graphic-designers) (push) Failing after 3s
build-and-push / build (job-seekers) (push) Failing after 3s
build-and-push / build (jobs) (push) Failing after 2s
build-and-push / build (leads) (push) Failing after 2s
build-and-push / build (makeup-artists) (push) Failing after 2s
build-and-push / build (payments) (push) Failing after 2s
build-and-push / build (photographers) (push) Failing after 3s
build-and-push / build (social-media-managers) (push) Failing after 3s
build-and-push / build (tutors) (push) Failing after 3s
build-and-push / build (ugc-content-creators) (push) Failing after 2s
build-and-push / build (users) (push) Failing after 2s
build-and-push / build (video-editors) (push) Failing after 2s
build-and-push / build (companies) (push) Failing after 10m52s
build-and-push / build (catering-services) (push) Successful in 11m29s
Add build-images.yaml for Forgejo CI
tmp build.yaml
Add Dockerfiles for jobs and leads services
Add build-all.sh script for batch building
2026-06-13 18:31:34 +05:30
Ashwin Kumar Sivakumar
189f4bca60 ci: test single job with ubuntu-latest
Some checks failed
build-all / build-cron (push) Failing after 1s
build-and-push / detect-changes (push) Successful in 4s
build-all / build-users (push) Failing after 1s
build-gateway / build (push) Failing after 1s
build-services / build-gateway (push) Failing after 2s
build-services / build-users (push) Failing after 3s
build-services / build-jobs (push) Failing after 3s
build-services / build-cron (push) Failing after 2s
build-services / build-leads (push) Failing after 4s
build-all-services / build (push) Failing after 2s
build-and-push / build (catering-services) (push) Failing after 2s
build-and-push / build (companies) (push) Failing after 4s
build-and-push / build (cron) (push) Failing after 3s
build-and-push / build (customers) (push) Failing after 4s
build-and-push / build (developers) (push) Failing after 3s
build-and-push / build (fitness-trainers) (push) Failing after 3s
build-and-push / build (employees) (push) Failing after 4s
build-and-push / build (gateway) (push) Failing after 3s
build-and-push / build (graphic-designers) (push) Failing after 3s
build-and-push / build (job-seekers) (push) Failing after 3s
build-and-push / build (jobs) (push) Failing after 3s
build-and-push / build (leads) (push) Failing after 3s
build-and-push / build (payments) (push) Failing after 3s
build-and-push / build (makeup-artists) (push) Failing after 4s
build-and-push / build (photographers) (push) Failing after 2s
build-and-push / build (social-media-managers) (push) Failing after 3s
build-and-push / build (tutors) (push) Failing after 2s
build-and-push / build (ugc-content-creators) (push) Failing after 3s
build-and-push / build (users) (push) Failing after 2s
build-and-push / build (video-editors) (push) Failing after 3s
2026-06-13 01:44:07 +05:30
Ashwin Kumar Sivakumar
1956acdcf3 ci: minimal workflow without external actions
Some checks failed
build-all / build-users (push) Failing after 1s
build-services / build-gateway (push) Failing after 2s
build-services / build-users (push) Failing after 4s
build-services / build-jobs (push) Failing after 2s
build-services / build-leads (push) Failing after 4s
build-all / build-gateway (push) Failing after 2s
build-all / build-cron (push) Failing after 2s
build-services / build-cron (push) Failing after 2s
build-all-services / build (push) Failing after 2s
build-and-push / detect-changes (push) Successful in 4s
build-and-push / build (catering-services) (push) Failing after 2s
build-and-push / build (companies) (push) Failing after 2s
build-and-push / build (cron) (push) Failing after 2s
build-and-push / build (customers) (push) Failing after 2s
build-and-push / build (developers) (push) Failing after 2s
build-and-push / build (employees) (push) Failing after 2s
build-and-push / build (fitness-trainers) (push) Failing after 3s
build-and-push / build (gateway) (push) Failing after 3s
build-and-push / build (graphic-designers) (push) Failing after 3s
build-and-push / build (job-seekers) (push) Failing after 3s
build-and-push / build (jobs) (push) Failing after 2s
build-and-push / build (leads) (push) Failing after 2s
build-and-push / build (makeup-artists) (push) Failing after 3s
build-and-push / build (payments) (push) Failing after 3s
build-and-push / build (photographers) (push) Failing after 3s
build-and-push / build (social-media-managers) (push) Failing after 3s
build-and-push / build (tutors) (push) Failing after 2s
build-and-push / build (ugc-content-creators) (push) Failing after 2s
build-and-push / build (users) (push) Failing after 2s
build-and-push / build (video-editors) (push) Failing after 2s
2026-06-13 01:41:32 +05:30