Contact us
Contact us
01. Our Work
01. Our Work
02. About Us
02. About Us
03. Solutions
03. Solutions
04. Our Process
04. Our Process
05. Blog
05. Blog
06. Calculator
06. Calculator

Our offices

  • Tallinn
    Harju maakond, Kesklinna linnaosa, Narva mnt 5
    10117, Tallinn, Estonia
    • +372-623-7083
  • Email
    office@make-it.run

Follow us

  • Work
    • View Our Work
    • Case Studies
    • See all →
  • Company
    • About
    • Solutions
    • Process
    • Blog
    • Calculator
    • Contact us
  • Legal
    • Privacy Policy
    • Terms of Service
  • Connect
    • LinkedIn
    • Facebook
    • Youtube
    • X

Stay updated with make-it.run

Subscribe to get the latest tech insights, startup resources, and development tips from our team.

© make-it.run 2025

Case Study
LegalSharp

The legal industry is undergoing a massive transformation, driven by the power of artificial intelligence. Our client, a forward-thinking legal tech startup, envisioned a platform that could democratize access to legal information and provide initial guidance for common legal issues. The challenge was to create LegalSharp, an AI-powered assistant that could understand complex legal queries and provide accurate, structured, and actionable information in a conversational format.

About

AI-powered legal assistant platform providing conversational support for legal questions and guidance. Users interact with an intelligent chatbot trained on legal knowledge to get instant answers to legal queries, understand legal concepts, and receive preliminary legal guidance without the cost of traditional legal consultation.

Features

  1. AI Legal Chat Interface

Conversational AI assistant answers legal questions in real-time. Provides accessible legal guidance 24/7 without appointment scheduling or hourly billing.

  1. Conversation History

Persistent chat history allows users to reference previous legal discussions. Enables building context over multiple sessions for complex legal matters.

  1. User Authentication and Accounts

Secure login system protects sensitive legal conversations. Ensures privacy and allows personalized experience with saved preferences.

  1. Real-Time Responses

Instant AI-generated responses to legal queries. Eliminates waiting time compared to traditional legal consultation scheduling.

  1. Session Management

Maintains active user sessions across multiple devices. Users can start conversation on desktop and continue on mobile seamlessly.

Technical Development

Stack: React (Frontend), NestJS (Backend Framework), MySQL (Database), Redis (Caching/Session Management)

Authentication System

Frontend Implementation: React authentication pages with toggle between sign-in and sign-up modes. Single component handles both login and registration by switching form fields and button text. Email and password inputs with client-side validation checking email format and password strength (minimum 8 characters). Form submission prevents default behavior and sends credentials to backend API.

Backend Implementation: NestJS authentication module uses Passport.js for strategy-based authentication. Password hashing implemented with bcrypt before storing in MySQL database. JWT tokens generated upon successful login containing user ID and expiration timestamp. Tokens sent to frontend in HTTP-only cookies for security against XSS attacks.

Database Design: MySQL users table stores user credentials with columns for id (primary key), email (unique index), password hash, created_at timestamp, and last_login timestamp. Email uniqueness enforced at database level preventing duplicate accounts.

Session Management: Redis stores active user sessions with JWT token as key and user data as value. Session expiration set to 7 days with automatic cleanup of expired sessions. Redis provides fast session lookup without querying MySQL on every request.

Chat Interface

Frontend Implementation: React chat component displays conversation in scrollable message list with user messages aligned right and AI responses aligned left. Message input field at bottom with send button and Enter key support. Auto-scroll to newest message when response arrives. Typing indicator shows when AI is generating response.

Backend Implementation: NestJS WebSocket gateway handles real-time bidirectional communication between client and server. When user sends message, WebSocket event triggers AI processing. Response streamed back to client in real-time as AI generates text. Message history saved to MySQL after each exchange.

AI Integration: Backend integrates with OpenAI GPT-4 API or similar large language model fine-tuned for legal domain. System prompt instructs AI to provide legal information while disclaiming it’s not substitute for licensed attorney. AI responses include relevant legal concepts, statutes, and case law references where applicable.

Conversation History

Frontend Implementation: React sidebar component lists previous conversations with titles auto-generated from first user message. Clicking conversation loads full message history into main chat interface. Search functionality filters conversations by keywords. Delete button allows removing old conversations.

Backend Implementation: MySQL conversations table stores conversation metadata with columns for id, user_id (foreign key), title, created_at, and updated_at. Messages table stores individual messages with conversation_id (foreign key), role (user or assistant), content (text), and timestamp. Pagination loads conversations in batches of 20 to handle users with extensive history.

Data Retrieval: API endpoint fetches conversation list with most recent first. Separate endpoint retrieves full message history for specific conversation. Redis caches recent conversations for faster loading. Cache invalidated when new message added to conversation.

Real-Time Communication

Frontend Implementation: React uses Socket.IO client library to establish WebSocket connection on component mount. Event listeners handle incoming AI responses and typing indicators. Connection status indicator shows when disconnected with automatic reconnection attempts.

Backend Implementation: NestJS WebSocket gateway built on Socket.IO handles concurrent connections from multiple users. Each connection authenticated using JWT token from initial handshake. Messages routed to correct user session using socket ID mapping stored in Redis.

Message Queue: Redis pub/sub channels coordinate message delivery across multiple backend server instances in load-balanced deployment. When user sends message, server publishes to channel. AI processing server subscribes to channel, generates response, and publishes back.

Legal Knowledge Base

Frontend Implementation: Search interface allows querying legal knowledge base separate from chat. Results display relevant legal articles, statutes, and case summaries. Links to full legal documents open in new tab or modal.

Backend Implementation: MySQL legal_documents table stores curated legal content with full-text search index. Documents categorized by legal domain (contract law, criminal law, employment law, etc.). Vector embeddings of documents stored for semantic search using AI.

Search Functionality: Hybrid search combines keyword matching with semantic similarity. User query converted to vector embedding and compared against document embeddings. Results ranked by relevance score combining both methods. Redis caches popular search results.

User Dashboard

Frontend Implementation: React dashboard displays user statistics including total conversations, messages sent, and account creation date. Recent conversations shown in card grid. Quick action buttons for starting new conversation or browsing knowledge base.

Backend Implementation: API aggregates user activity data from MySQL. Queries count conversations and messages per user. Recent conversations fetched with preview of last message. Statistics cached in Redis with 1-hour TTL.

Rate Limiting and Usage Tracking

Frontend Implementation: Usage meter shows remaining AI queries for current billing period. Warning message appears when approaching limit. Upgrade prompt for premium tier with unlimited queries.

Backend Implementation: Redis counters track API usage per user with daily, weekly, and monthly keys. Rate limiting middleware checks counter before processing request. Free tier limited to 50 queries per day, premium tier unlimited. Counter resets automatically at period boundaries.

Billing Integration: MySQL subscriptions table tracks user plan (free, premium) and billing status. Stripe integration handles payment processing for premium upgrades. Webhook endpoints update subscription status when payment succeeds or fails.

Data Privacy and Security

Frontend Implementation: Privacy policy and terms of service linked in footer. Data export feature allows users to download all their conversations in JSON format. Account deletion permanently removes all user data.

Backend Implementation: All API endpoints require authentication except public pages. HTTPS enforced for all connections. Database connections encrypted with TLS. Sensitive data like passwords never logged. GDPR compliance with right to access and deletion.

Legal Disclaimers: Prominent disclaimer states AI provides information only, not legal advice. Users advised to consult licensed attorney for legal representation. Conversations not protected by attorney-client privilege.

Performance Optimization

Frontend Implementation: React code splitting loads chat interface only after authentication. Lazy loading for conversation history as user scrolls. Message virtualization renders only visible messages in long conversations. Service worker caches static assets for offline viewing of past conversations.

Backend Implementation: Redis caching reduces MySQL queries by 80%. Database connection pooling handles concurrent requests efficiently. Indexes on frequently queried columns (user_id, conversation_id, created_at) ensure fast lookups. AI responses cached for identical questions to reduce API costs.

Scalability: NestJS application runs on multiple server instances behind load balancer. Redis cluster provides distributed caching and session storage. MySQL read replicas handle query load. WebSocket connections distributed across servers using Redis adapter.

Monitoring and Analytics

Frontend Implementation: Error boundary components catch React errors and display user-friendly messages. Client-side error logging sends stack traces to monitoring service. Analytics track user engagement metrics like messages per session and conversation length.

Backend Implementation: Application logging captures all API requests, errors, and performance metrics. Prometheus metrics exported for monitoring dashboard. Alerts configured for high error rates, slow response times, and service downtime. Database query performance monitored to identify slow queries.

Deployment: React frontend deployed on Vercel or Netlify with automatic builds from Git. NestJS backend deployed on AWS ECS with Docker containers and auto-scaling. MySQL database on AWS RDS with automated backups and Multi-AZ deployment. Redis cluster on AWS ElastiCache for high availability. CloudFront CDN for static asset delivery.

Project Details

LegalSharp
Client
LegalSharp
Service
Legal Technology
Date
October 2025
Project Duration
12 weeks 6 days

Technical Stack

  • React.jsReact.js
  • Nest.jsNest.js
  • MySQLMySQL
  • RedisRedis
LegalSharp web

Tell us about your project

Tell us everything!

Our offices

  • Tallinn
    Harju maakond, Kesklinna linnaosa, Narva mnt 5
    10117, Tallinn, Estonia
    • +372-623-7083
  • Email
    office@make-it.run