Skip to content

LangQuest-App/LangQuest-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LangQuest Backend

A comprehensive language learning platform backend built with Node.js, Express, TypeScript, and Prisma. This API powers interactive language learning experiences with AI-generated content, text-to-speech capabilities, and user progress tracking.

🌐 Live Deployment

Backend URL: https://langquest-backend.onrender.com

πŸš€ Features

Core Functionality

  • AI-Powered Scene Generation: Create interactive language learning scenarios using Google Gemini AI
  • Text-to-Speech Integration: Generate audio for script lines using Murf AI
  • User Response Tracking: Store and manage user interactions with learning content
  • Multi-Language Support: Support for various target languages
  • Progress Tracking: Monitor user learning progress and mistakes

API Endpoints

  • Scene Management: Create and retrieve learning scenes with script lines
  • User Responses: Track user interactions and responses
  • Lesson System: Generate and manage lessons with AI-powered content
  • Tutorial Progress: Track completion status and user progress

πŸ›  Tech Stack

  • Runtime: Node.js with TypeScript
  • Framework: Express.js
  • Database: PostgreSQL with Prisma ORM
  • AI Integration:
    • Google Gemini AI for content generation
    • Murf AI for text-to-speech
  • Database Hosting: Neon (PostgreSQL)
  • Deployment: Render

πŸ“ Project Structure

langquest-backend/
β”œβ”€β”€ controllers/           # Business logic controllers
β”‚   └── lesson-controller/ # Lesson generation and management
β”œβ”€β”€ prisma/               # Database schema and migrations
β”œβ”€β”€ routes/               # API route definitions
β”‚   β”œβ”€β”€ scene.ts         # Scene management endpoints
β”‚   β”œβ”€β”€ userResponse.ts  # User response tracking
β”‚   └── lesson.ts        # Lesson management
β”œβ”€β”€ utils/               # Utility functions
β”‚   └── prisma.ts       # Database client singleton
β”œβ”€β”€ types/               # TypeScript type definitions
β”œβ”€β”€ prompt/              # AI prompt templates
└── dist/               # Compiled JavaScript (production)

πŸ—„ Database Schema

Core Models

  • Scene: Learning scenarios with metadata
  • ScriptLine: Individual dialogue lines with TTS audio
  • UserResponse: User interactions and responses
  • User: User accounts and preferences
  • Lesson: AI-generated lesson content
  • Tutorial: Learning tutorials and progress tracking

πŸ”§ API Endpoints

Scene Management

POST /scene              # Create new learning scene
GET /scene               # Get latest scene with script lines

User Responses

POST /userResponse       # Record user response to script line
GET /userResponse        # Retrieve all user responses

Lessons

POST /lesson             # Generate new lesson content
GET /lesson/:userId      # Get user's lessons

Health Check

GET /                    # API health check
GET /health              # Detailed health status

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • PostgreSQL database
  • Google AI API key
  • Murf AI API key

Installation

  1. Clone the repository

    git clone https://github.com/Dev-Dhruba/LangQuest-backend.git
    cd LangQuest-backend
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp env.example .env

    Update .env with your configuration:

    DATABASE_URL="your_postgresql_connection_string"
    GOOGLE_API_KEY="your_google_ai_api_key"
    MURF_API_KEY="your_murf_ai_api_key"
    PORT=8000
  4. Set up the database

    npx prisma migrate dev
    npx prisma generate
  5. Start development server

    npm run dev

Production Build

npm run build
npm start

πŸ”§ Scripts

  • npm run dev - Start development server with hot reload
  • npm run build - Build for production
  • npm start - Start production server
  • npm run prisma:generate - Generate Prisma client
  • npm run compile - Compile TypeScript

🌍 Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string βœ…
GOOGLE_API_KEY Google Gemini AI API key βœ…
MURF_API_KEY Murf AI TTS API key βœ…
PORT Server port (default: 8000) ❌
NODE_ENV Environment (production/development) ❌

πŸ“Š Database Migrations

The project uses Prisma for database management:

# Create new migration
npx prisma migrate dev --name migration_name

# Apply migrations
npx prisma migrate deploy

# Reset database (development only)
npx prisma migrate reset

πŸ”’ Security Features

  • CORS enabled for cross-origin requests
  • Environment variables for sensitive data
  • Input validation for API endpoints
  • Error handling with detailed logging

πŸ§ͺ Testing API Endpoints

Create a Scene

curl -X POST https://langquest-backend.onrender.com/scene \
  -H "Content-Type: application/json" \
  -d '{"language": "Korean"}'

Get Latest Scene

curl https://langquest-backend.onrender.com/scene

Record User Response

curl -X POST https://langquest-backend.onrender.com/userResponse \
  -H "Content-Type: application/json" \
  -d '{"scriptLineId": 1, "response": "μ•ˆλ…•ν•˜μ„Έμš”"}'

πŸš€ Deployment

Render Deployment

  1. Connect GitHub repository to Render
  2. Configure build settings:
    • Build Command: npm ci && npx prisma generate && npx tsc
    • Start Command: npm start
  3. Add environment variables in Render dashboard
  4. Deploy automatically on git push

Manual Deployment

npm run build
npm start

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ API Documentation

Response Format

All API responses follow this structure:

{
  "message": "Success message",
  "data": {...},
  "count": 10 // (for list responses)
}

Error Format

{
  "error": "Error message",
  "details": "Detailed error information"
}

πŸ“„ License

This project is licensed under the ISC License.

πŸ‘¨β€πŸ’» Authors

Dev-Dhruba - GitHub Profile

Shreya Shaw - GitHub Profile

πŸ”— Related Projects

  • Frontend Repository: [Add your frontend repo link here]
  • Mobile App: [Add your mobile app repo link here]

Live API: https://langquest-backend.onrender.com

For questions or support, please open an issue in the GitHub repository.

About

Backend for the langquest applicaiton, the backend deployed URL link is given below

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors