Skip to content

Latest commit

 

History

History
261 lines (182 loc) · 4.73 KB

File metadata and controls

261 lines (182 loc) · 4.73 KB

🚀 STEP 1 — Backend Scaffold

Paste this now:

Build the backend scaffold for the project based on the given context.

Requirements:

  • Use NestJS with TypeScript (preferred)
  • Use PostgreSQL with Prisma ORM
  • Setup Redis (for future queue usage, no need to fully integrate yet)

Create a clean modular structure with the following modules:

  • auth
  • users
  • assets
  • posts
  • sentiment
  • alerts
  • strategies
  • whale

Implement:

  • Basic NestJS app setup
  • Prisma setup with connection to PostgreSQL
  • Environment configuration (.env)
  • Basic logging and error handling

Database models (initial version):

  • User (id, email, password, createdAt)
  • Asset (id, name, symbol, type)
  • UserPreferences (id, userId, assetId, alertEnabled, createdAt)

Do NOT implement business logic yet. Focus only on clean architecture and working setup.

Make sure:

  • project runs locally
  • Prisma migrations work

👉 After it completes:

Say this: Refactor and clean the code. Ensure proper folder structure and remove duplication.

🚀 STEP 2 — Auth System

Then paste:

Now implement authentication.

Requirements:

  • JWT-based authentication
  • Password hashing (bcrypt)

Endpoints:

  • POST /auth/signup
  • POST /auth/login

Features:

  • Validate input
  • Store hashed password
  • Return JWT token on login

Add:

  • Auth guards
  • Middleware for protected routes

Keep implementation clean and modular.

👉 Then refactor again:

Refactor auth module for clarity and maintainability.

🚀 STEP 3 — Asset + Preferences System

Implement asset management and user preferences.

Endpoints:

Assets:

  • GET /assets (list available assets)
  • POST /assets/add (user selects asset)
  • DELETE /assets/remove

Preferences:

  • POST /preferences (update user settings)
  • GET /preferences (fetch user settings)

Features:

  • User can select stocks/crypto
  • Store mapping between user and assets
  • Add alertEnabled toggle

Keep relations clean in Prisma schema.

👉 Then:

Refactor assets and preferences modules. Ensure DB relations are correct and optimized.

🚀 STEP 4 — Post Model + Basic Feed

Implement post ingestion structure.

Create Post model:

  • id
  • source (X, Reddit)
  • content
  • author
  • createdAt
  • rawData (JSON)

Create endpoint:

  • GET /posts (filter by asset and source)

Do NOT implement fetcher yet. Allow manual insertion of posts for testing.

👉 Then:

Clean up post module and ensure scalable structure.

🚀 STEP 5 — Redis + Queue Setup

Integrate Redis and BullMQ.

Implement:

  • Queue configuration
  • Connection setup

Create queues:

  • postQueue
  • sentimentQueue

Do NOT add workers yet. Just setup infrastructure.

Ensure:

  • queues connect correctly
  • no runtime errors

👉 Then:

Refactor queue setup and isolate configuration properly.

🚀 STEP 6 — Worker System

Implement worker system.

Create two workers:

  1. Fetcher Worker:
  • Runs every 30–60 seconds
  • Generates mock posts (if API unavailable)
  • Pushes posts to postQueue
  1. Sentiment Worker:
  • Consumes posts from queue
  • Stores posts in DB

Workers should run separately from main server.

Keep logic simple for now.

👉 Then:

Refactor worker logic and ensure clean separation from main app.

🚀 STEP 7 — Sentiment Engine

Implement sentiment engine.

Output:

  • sentiment_score (-1 to 1)
  • impact_score (0–100)
  • confidence
  • category
  • reason

Logic:

  • keyword-based scoring
  • positive/negative keywords
  • simple engagement factor

Store results in SentimentResult table.

Integrate this inside sentiment worker.

👉 Then:

Refactor sentiment logic and make it modular.

🚀 STEP 8 — Strategy Config

Implement strategy configuration.

Each user has JSON config:

{ keywords_positive: [], keywords_negative: [], impact_threshold: 70, confidence_threshold: 60 }

Endpoints:

  • GET /strategy
  • POST /strategy/update

Sentiment engine should use this config.

Do NOT allow raw code execution.

🚀 STEP 9 — Alerts

Implement alert system.

Trigger: IF impact_score > threshold AND confidence > threshold

Actions:

  • Store alert in DB
  • Send email (use nodemailer)

Make email optional.

Create:

  • GET /alerts

🚀 STEP 10 — LLM Deep Analysis

Implement LLM service.

Endpoint: POST /analysis/deep

Input:

  • post_id

Behavior:

  • fetch post
  • return detailed explanation

IMPORTANT:

  • Do NOT run automatically
  • Only run on API call

Keep provider abstract.

🚀 STEP 11 — WebSockets

Add WebSocket support.

Emit:

  • new post
  • new sentiment
  • new alert

Frontend should subscribe. 🔥 CRITICAL RULE

After EVERY step, if things look messy, say:

Fix all inconsistencies. Ensure modular clean architecture aligned with original context. 🚀 After Backend Done

Then tell me:

👉 “frontend time”

and I’ll guide you similarly for frontend.

You’re basically building this like a real startup backend now 😄