This project is now OFFICIALLY accepted for:
π Project Insights
| π Stars | π΄ Forks | π Issues | π Open PRs | π Closed PRs | π οΈ Languages | π₯ Contributors |
LegalHuB is a web-based platform designed to simplify access to legal resources. Users can explore legal terms, download state-specific legal documents, understand their rights, read comprehensive legal guides, and apply for legal services through official links β all in one place.
- β Legal Dictionary β AI-powered explanations of complex legal terms.
- β Download Legal Forms β Access and download state-specific legal documents.
- β Apply for Legal Services β Redirects to official legal application portals.
- β Legal Rights Database β Browse essential civil, fundamental, and employment rights.
- β Legal Articles & Guides β Learn from structured and easy-to-read legal content.
- β Smart Search β Search across legal terms, rights, and documents efficiently.
- Backend: Node.js, Express.js
- Database: MongoDB (Free Tier or Atlas)
- AI Integration: Chatbase (for AI chatbot responses)
- Templating Engine: EJS
- Authentication: Passport.js
- Node.js
- MongoDB (local or MongoDB Atlas)
.envfile with necessary API keys
git clone https://github.com/yourusername/LegalHuB
cd LegalHuB npm install- Create a .env file in the root directory and add the following:
- Copy the example environment file:
cp .env.sample .env- Update the .env file with your configuration:
# Server Configuration
PORT=8000
SESSION_SECRET=mysecrectkey
# CORS Configuration
CORS_ORIGIN=*
# CORS_ORIGIN=http://localhost:4000
#DB_URL=
DB_URL=mongodb+srv://<username>:<password>@cluster0.weuhr.mongodb.net
# Uncomment if needed for frontend security
DB_URL=
NODE_ENV=development
MISTRAL_API_KEY=
ADMIN_SECRECT_KEY=mysupersecretkeyLegalHuB uses Google OAuth 2.0 for user authentication via Passport.js.
If not configured, the project will throw this error when you run it locally:
TypeError: OAuth2Strategy requires a clientID option
https://console.cloud.google.com/
- Navigate to APIs & Services β OAuth consent screen
- Choose External and add your Gmail as a Test User
- Go to APIs & Services β Credentials β Create Credentials β OAuth client ID
- Choose Web Application
- Add the following Authorized redirect URI: http://localhost:8000/auth/google/callback
Add them to your .env file:
GOOGLE_CLIENT_ID=your-client-id-here
GOOGLE_CLIENT_SECRET=your-client-secret-here
GOOGLE_CALLBACK_URL=http://localhost:8000/auth/google/callback
LOCAL_GOOGLE_CALLBACK=http://localhost:8000/auth/google/callback
Restart your server:
npm start
Your app will now start successfully and Google login will work at: http://localhost:8000/auth/google
If youβre just testing the app and donβt need login, you can skip OAuth setup by setting:
USE_FAKE_DATA=true
in your .env to use local mock data and disable external dependencies.
To enable Mistral AI-powered features in LegalHuB, follow the steps below:
-
Go to the Mistral AI Platform and create an account (if you haven't already).
-
Navigate to API Keys and generate a new key.
-
Add the following entry to your
.envfile:MISTRAL_API_KEY=your_mistral_api_key_here
- Start the server
npm start or npm run devThe server will run on http://localhost:8000
We welcome contributions to help improve LegalHuB! π Whether you're fixing bugs, improving documentation, or building new features β your support makes a difference.
- Navigate to the LegalHuB GitHub repository.
- Click the Fork button in the top-right corner to create a personal copy of the repository.
- Clone the repository to your local machine:
git clone https://github.com/your-username/LegalHuB.git- Navigate to the project directory:
cd LegalHuB- πΏ Create a New Branch
- Create a new branch for your changes:
git checkout -b feature/your-feature-name-
Make Your ChangesβοΈ
- Add your desired features, fix bugs, or improve documentation. π οΈ
-
π¦ Stage the Changes
- Add modified files to the staging area:
git add .- π Commit Your Changes
- Commit your changes with a clear, descriptive message:
git commit -m "Add [feature/fix]: short description of what you changed"- β¬οΈ Push to Your Fork
- Push the changes to your forked GitHub repository:
git push origin feature/your-feature-name- π¬ Create a Pull Request
-
Visit your forked repository on GitHub.
-
Click on "Compare & pull request".
-
Add a title and description of your changes.
-
Submit the pull request for review.
-
-
Follow consistent code style.
-
Write descriptive commit messages.
-
Make sure the project builds without errors.
-
Reference any related issue numbers (e.g., Fixes #123).
LegalHuB/
βββ .github/ # GitHub configuration files and workflows
β βββ ISSUE_TEMPLATE/ # Templates for issue creation
β βββ workflows/ # GitHub Actions workflows (CI/CD automation)
β βββ labeler.yml # Automatically assign labels to PRs/issues
β βββ PULL_REQUEST_TEMPLATE.md # Standard pull request template
β
βββ __tests__/ # Automated test files for all major modules
β βββ appointment.test.js # Unit tests for appointment module
β βββ article.test.js # Tests for article-related APIs
β βββ chat.test.js # Tests for chat functionality
β βββ dictionary.test.js # Tests for dictionary search endpoints
β βββ document.test.js # Tests for document handling
β βββ healthCheck.test.js # Tests for server health check route
β βββ lawyer.test.js # Tests for lawyer routes and models
β βββ review.test.js # Tests for review system
β βββ rights.test.js # Tests for legal rights endpoints
β βββ search.test.js # Tests for search module
β βββ user.test.js # Tests for user authentication and profiles
β
βββ init/ # Initialization scripts
β βββ documents.data.js # Seed data for legal documents
β βββ index.documents.js # Document initialization logic
β βββ index.rights.js # Rights initialization logic
β βββ rights.data.js # Seed data for legal rights
β
βββ src/ # Main source code directory
β βββ config/ # Environment and configuration files
β βββ controllers/ # Business logic and route handlers
β βββ db/ # Database connection and setup
β βββ middlewares/ # Express middlewares (auth, validation, logging)
β βββ models/ # Mongoose / Sequelize models for data structure
β βββ public/ # Public assets (images, static files)
β βββ routes/ # API routes definitions
β βββ services/ # Service layer for business logic and API calls
β βββ utils/ # Utility/helper functions
β βββ validators/ # Request validation schemas
β βββ views/ # View templates (if using server-side rendering)
β
βββ test/ # Global test setup and utility functions
β βββ globalSetup.js # Jest global setup
β βββ globalTeardown.js # Jest global teardown
β βββ jest.setup.js # Jest environment configuration
β βββ testHelpers.js # Common helper functions for tests
β
βββ app.js # Express app configuration and middleware setup
βββ constants.js # Global constants used throughout the project
βββ index.js # Main entry point β starts the server
βββ setUpAdmin.js # Script to initialize admin users
βββ socket.js # Socket.io configuration for real-time communication
β
βββ .env.sample # Example environment variable configuration
βββ .eslintignore # Files and folders ignored by ESLint
βββ .eslintrc.js # ESLint configuration for code linting
βββ .gitignore # Files ignored by Git
βββ .prettierignore # Files ignored by Prettier
βββ .prettierrc # Prettier configuration for code formatting
β
βββ CODE_OF_CONDUCT.md # Contributor behavior guidelines
βββ CONTRIBUTING.md # Instructions for contributing to the project
βββ LEARN.md # Learning resources or setup guide for contributors
βββ LICENSE # Open-source license for the project
βββ readme.md # Main project documentation
- GET
/api/dictionary/:term
Returns an AI-generated explanation for a legal term.
-
GET
/api/forms
Retrieve all available legal forms. -
GET
/api/forms/:id
Get a specific form by its ID. -
GET
/api/forms/download/:id
Download a specific legal form.
-
GET
/api/rights
Fetch all legal rights from the database. -
GET
/api/rights/:id
Retrieve a specific legal right by ID.
- GET
/api/search?q=your_query
Searches across legal dictionary, rights, and forms.
{
"dictionary_results": ["Tenant Rights - Explanation"],
"rights_results": ["Right to Safe Housing"],
"form_results": ["Rental Agreement Form"]
}The Smart Search feature performs a unified query across:
- Legal terms in the dictionary database
- User rights stored in MongoDB
- Legal forms and their descriptions
The results are ranked and returned in a categorized format to ensure relevance and clarity.
- Home (
/) β Introductory landing page with navigation - Legal Dictionary (
/dictionary) β Look up legal terms - Legal Forms (
/forms) β Download or view forms by category - Legal Rights (
/rights) β Explore civil and employment rights
This project is licensed under the MIT License.
Pull requests are welcome! For significant changes, please open an issue first to discuss your proposed modifications.
A heartfelt thank you to all the contributors who have dedicated their time and effort to make this project a success.
Your contributionsβwhether itβs code, design, testing, or documentationβare truly appreciated! π
See full list of contribution from contributor Contributor Graph
For support, collaboration, or legal partnerships, please contact:
π§ [email protected]
LegalHuB β Empowering users with accessible legal information.












