PromptPulse is a backend-centric system designed to securely store, manage, and analyze user-generated content, with AI integration built through a controlled, backend-driven architecture.
This project emphasizes backend engineering, system design, security, and scalable API architecture, rather than frontend complexity.
- β¨ Design secure and production-ready REST APIs
- π Implement full authentication lifecycle (access + refresh tokens)
- π₯ Enforce real-world data ownership rules
- π Support scalable data access with indexing & pagination
- π€ Integrate AI safely through backend-controlled workflows
- π Build an interview-ready backend system with explainable design decisions
- User signup and login
- Password hashing using bcrypt
- JWT-based stateless authentication
- Short-lived Access Tokens (15m)
- Long-lived Refresh Tokens (7d)
- Refresh token stored in database for revocation
- Secure token renewal endpoint
- Logout with refresh token invalidation
- Protected routes via authentication middleware
- Limited exposure if access token is compromised
- Controlled session renewal
- Proper logout and session revocation
- Create, read, update content with structured endpoints
- Ownership enforced using
userIdextracted from JWT - Soft delete using lifecycle-aware design
- Structured and consistent API responses
- Clean RESTful routing
- Keyword-based search across user content
- Type-based filtering for granular queries
- Limitβoffset pagination for large datasets
- Compound indexing for optimized queries:
{ userId, isDeleted }{ createdAt }
- Designed to avoid full collection scans
- Ensures efficient performance as data grows
- β Centralized error handling middleware
- β Structured JSON response format
- β Rate limiting (auth and sensitive endpoints)
- β Request logging for debugging and observability
- π§ Service-layer abstraction for AI calls
- π‘οΈ Backend-controlled prompt construction
- π Ownership validation before AI execution
- π Designed for Retrieval-Augmented Generation (RAG)
- πΎ Embeddings treated as derived, rebuildable data
- π« AI never bypasses backend authorization rules
- Node.js β JavaScript runtime
- Express.js β Minimalist web framework
- MongoDB β NoSQL database (Mongoose ODM)
- JWT β Stateless authentication
- bcrypt β Password hashing
- Docker β Containerization
- OpenAI / Gemini API β LLM provider
- Embeddings API β Vector generation
- Vector Store β FAISS or similar
- React β API consumption only
| Feature | Status |
|---|---|
| Authentication (Access + Refresh) | β Completed |
| Refresh Token DB Validation | β Completed |
| Logout & Token Revocation | β Completed |
| Content CRUD | β Completed |
| Ownership Enforcement | β Completed |
| Soft Delete Lifecycle | β Completed |
| Search & Filtering | β Completed |
| Pagination | β Completed |
| Compound Indexing | β Completed |
| Rate Limiting | β Completed |
| Centralized Error Handling | β Completed |
| AI Summarization | β³ In Progress |
| AI Q&A (RAG) | β³ In Progress |
PromptPulse demonstrates:
- π Secure authentication design β Token lifecycle management
- π Data ownership enforcement β Query-level security
- β‘ Query optimization β Compound indexing strategies
- π Scalable REST API design β Pagination & search patterns
- π€ Controlled AI integration β Backend-first architecture
This project is built as an interview anchor to showcase backend and system design thinking.
- Node.js 16+
- MongoDB instance
- npm or yarn
# Clone the repository
git clone <repo-url>
# Navigate to project directory
cd PromptPulse
# Install dependencies
npm install
# Start development server
npm run devThe server will start at http://localhost:5000
Create a .env file in the root directory:
| Variable | Description | Required | Default |
|---|---|---|---|
PORT |
Port number for the server | β Yes | 5000 |
| Variable | Description | Required | Example |
|---|---|---|---|
MONGO_URI |
MongoDB connection string | β Yes | mongodb+srv://user:pass@cluster.mongodb.net/dbname |
| Variable | Description | Required | Notes |
|---|---|---|---|
ACCESS_TOKEN_SECRET |
Secret key for signing access tokens | β Yes | Use a strong random string (min 32 chars) |
REFRESH_TOKEN_SECRET |
Secret key for signing refresh tokens | β Yes | Use a different strong random string |
| Variable | Description | Required | Example |
|---|---|---|---|
LLM_API_KEY |
API key for OpenAI or Gemini | β³ No* | sk-... or AIza... |
Note: LLM_API_KEY is optional until AI features are enabled.
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# π₯οΈ SERVER CONFIGURATION
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PORT=5000
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# ποΈ DATABASE CONFIGURATION
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/promptpulse?retryWrites=true&w=majority
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# π JWT SECRETS
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Generate strong random strings using:
# Linux/Mac: openssl rand -base64 32
# Windows: Use online generator
ACCESS_TOKEN_SECRET=your_super_secret_access_token_key_min_32_chars
REFRESH_TOKEN_SECRET=your_super_secret_refresh_token_key_min_32_chars
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# π€ AI INTEGRATION
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Optional: Enable when integrating AI features
LLM_API_KEY=your_openai_or_gemini_api_key_here- π― Backend is the single source of truth
- π Authentication is stateless but revocable
- π€ AI is treated as a controlled service layer
- π Data lifecycle is intentional and recoverable
- π‘ Design decisions prioritize explainability over overengineering
src/
βββ controllers/ # Route handlers and business logic
β βββ aiController.js
β βββ authController.js
β βββ contentController.js
βββ middleware/ # Express middleware
β βββ authMiddleware.js
β βββ errorMiddleware.js
β βββ rateLimiter.js
βββ models/ # Mongoose schemas
β βββ User.js
β βββ Content.js
β βββ Embedding.js
βββ routes/ # API route definitions
β βββ authRoute.js
β βββ contentRoutes.js
β βββ airRoutes.js
β βββ testRoutes.js
βββ services/ # Business logic and integrations
β βββ aiService.js
βββ app.js # Express app configuration
βββ server.js # Server entry point
POST /auth/signupβ Register new userPOST /auth/loginβ User loginPOST /auth/refreshβ Refresh access tokenPOST /auth/logoutβ Logout and revoke token
POST /contentβ Create new contentGET /contentβ Retrieve user's content (paginated)GET /content/:idβ Get specific contentPUT /content/:idβ Update contentDELETE /content/:idβ Soft delete content
POST /ai/summarizeβ Generate content summaryPOST /ai/qaβ Q&A over content
# Run tests
npm test
# Check linting
npm run lint
# Format code
npm run format
# Build for production
npm run build- Token-Based Auth β Stateless, scalable authentication with revocable refresh tokens
- Ownership at Query Level β Every database query filters by
userId - Soft Deletes β Data recovery and auditability through
deletedAttimestamps - Compound Indexes β Performance optimization for common query patterns
- Service Layer β Abstraction between controllers and external APIs
- Centralized Error Handling β Consistent error responses across all endpoints
Built as a production-ready backend system for learning and interview preparation.
Happy coding! π