Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TS_backend

TruEstate Retail Sales Management System - Backend API

Overview

High-performance Node.js/Express backend with PostgreSQL, Prisma ORM, and schema-based sharding. Handles 500,000+ transaction records with chunk-based caching and parallel shard queries.

Tech Stack

  • Node.js, Express.js
  • PostgreSQL with Prisma ORM
  • Schema-based Range Sharding (shard_2021, shard_2022, shard_2023)
  • Chunk-based caching (1500 records per chunk)

API Endpoints

  • GET /api/health - Health check
  • GET /api/sales - Get paginated sales data
  • GET /api/sales/filters - Get filter options
  • GET /api/sales/stats - Get summary statistics

Environment Variables

DATABASE_URL=your_postgresql_connection_string
PORT=3001
NODE_ENV=production

Setup

  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your DATABASE_URL
  1. Generate Prisma client:
npm run prisma:generate
  1. Push database schema:
npx prisma db push
  1. Start server:
npm start
# or for development
npm run dev

Deployment on Render

Steps:

  1. Connect Repository: Connect your GitHub repository DevXSoni021/TS_backend to Render

  2. Create Web Service:

    • Service Type: Web Service
    • Build Command: npm install && npm run prisma:generate
    • Start Command: npm start
  3. Environment Variables:

    • DATABASE_URL: Your PostgreSQL connection string
    • PORT: 3001 (or let Render assign)
    • NODE_ENV: production
  4. Database Setup:

    • Run npm run db:clear to create schemas
    • Run npx prisma db push to create tables
    • Run npm run import:sharded to import data

Scripts

  • npm start - Start production server
  • npm run dev - Start development server with nodemon
  • npm run prisma:generate - Generate Prisma client
  • npm run prisma:migrate - Run database migrations
  • npm run db:clear - Clear database and create sharded schemas
  • npm run import:sharded - Import CSV data with sharding

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages