Welcome to LegalHuB — a web-based legal support platform designed to make legal information accessible, understandable, and actionable for everyone.
This document serves as a technical guide and developer onboarding reference. Whether you're exploring the codebase or contributing to the project, this will help you understand how everything works under the hood.
- 🎯 What Is LegalHuB?
- 🛠️ Tech Stack
- 🧠 Core Functionality Breakdown
- 🏗️ Project Structure (Monorepo)
- 🔍 API & Controllers
- ⚙️ Environment Configuration
- 🚦 GitHub Actions (CI/CD)
- 🙋 Contributing
- 🧠 Tips for New Contributors
- 📬 Contact
- 🙌 Thank You
LegalHuB empowers users to:
- Understand complex legal terms using AI
- Download state-specific legal forms
- Explore legal rights (fundamental, civil, employment)
- Read accessible legal articles and guides
- Perform smart searches across legal content
| Layer | Technology |
|---|---|
| Backend | Node.js, Express.js |
| Database | MongoDB (Free Tier/Atlas) |
| Templating | EJS (Embedded JavaScript) |
| AI Chatbot | Chatbase + OpenAI API |
| Authentication | Passport.js |
| Search | Custom Smart Search Engine |
- Users search a legal term
- The backend sends the term to the OpenAI API
- Results are rendered via EJS templates
- Forms are stored in MongoDB and categorized
- Users can browse by type or state
- Backend allows download or external redirection
- Rights include descriptions, categories, and source links
- Available at the
/rightsroute
- Markdown or HTML content rendered via EJS
- Written in simple, user-friendly language
- Unified endpoint
/api/search?q=term - Searches across:
- Dictionary entries
- Legal rights
- Document metadata
- Ranked and returned as structured JSON:
{
"dictionary_results": [...],
"rights_results": [...],
"form_results": [...]
}LegalHuB/
├── __tests__/ # Unit & integration tests
├── .github/ # GitHub workflows & templates
│ └── workflows/
├── init/ # Seed scripts (rights, documents)
├── src/ # Core backend app
│ ├── controllers/ # Route logic & APIs
│ ├── db/ # MongoDB connection
│ ├── middlewares/ # Auth, error, upload handlers
│ ├── models/ # Mongoose schemas
│ ├── routes/ # Express route definitions
│ ├── utils/ # Cloudinary, error helpers, etc.
│ ├── views/ # EJS templates
│ ├── public/, uploads/ # Static & uploaded files
│ ├── app.js # Express app config
│ ├── index.js # Entry point
│ ├── constants.js # Global constants
│ └── readme.md # Dev-only usage guide
├── .env.sample # Sample environment variables
├── package.json # NPM config
└── README.md # Project overview
📂 /src/controllers/
Handles backend logic for each feature:
dictionary.controller.js– AI-powered legal term explanationsdocument.controller.js– Upload/view/download formsrights.controller.js– Read and manage legal rightsarticle.controller.js– Legal articles & blogssearch.controller.js– Smart search queriesuser.controller.js– User auth/profile handlinghealthCheck.js– Monitoring and uptime status
Mongoose models for:
document.model.jsrights.model.jsarticle.model.jsuser.model.js
Each route maps to a controller method.
| Method | Endpoint | Action |
|---|---|---|
| GET | /api/rights |
Fetch all rights |
| POST | /api/documents |
Upload a document |
| GET | /api/search?q=... |
Smart search by query |
- Layouts:
layouts/boilerplate.ejs - Includes:
navbar.ejs,footer.ejs,flash.ejs - Pages:
documents.ejs,rights.ejs,dictionary.ejs - User auth:
login.ejs,profile.ejs,updateUser.ejs
- Copy the sample environment file:
cp .env.sample .env- Fill in required fields:
# Server
PORT=8000
SESSION_SECRET=mysecretkey
# MongoDB
DB_URL=mongodb+srv://<username>:<password>@cluster.mongodb.net
# CORS
CORS_ORIGIN=*
# AI APIs
MISTRAL_API_KEY=
ADMIN_SECRET_KEY=mysupersecretkey
NODE_ENV=developmentWorkflow file: .github/workflows/integration.yml
- Runs automated tests on PRs
- Enforces code quality
- Can be extended for deployments
We welcome your contributions! Start by reading:
Ways to contribute:
- Fix typos, links, or formatting in this guide ✅
- Suggest improvements or beginner tips
- Submit PRs for features or bugs
- Use VS Code's Markdown Preview to test changes
- Follow the repo’s Prettier config
- Reference README.md for user-facing info
- Reach out via GitHub Issues if stuck!
📧 Email: dipexplorerid23@gmail.com
🐛 Open an Issue: GitHub Issues
Thanks for contributing to LegalHuB!
Let’s build a more legally literate web — together.