- Node.js (v14 or higher)
- MongoDB (running locally or cloud instance)
- Git
-
Clone the repository
git clone <repository-url> cd Janhit
-
Install dependencies
# Install server dependencies cd Server npm install # Install client dependencies cd ../Client npm install
-
Configure environment variables
- In the
Serverdirectory, ensure theenvfile exists with the following variables:PORT=8000 MONGODB_URI=mongodb://localhost:27017/Janhit ACCESS_TOKEN_SECRET=your_jwt_secret_key_here_change_in_production CORS=http://localhost:5173
- In the
-
Start MongoDB
- Make sure MongoDB is running on your system
- If using a different MongoDB URI, update the
MONGODB_URIin theenvfile
-
Run the application
# Start the server (from Server directory) cd Server npm start # Start the client (from Client directory, in a new terminal) cd Client npm run dev
- Open your browser and navigate to
http://localhost:5173 - Click on "Sign Up" or navigate to
/signup - Fill in the form with valid data:
- Name: Your full name
- Email: A valid email address
- Password: At least 6 characters
- Phone: Aadhar number (12 digits)
- Location: Click "Get My Location" or enter coordinates manually
- Submit the form
- You should see a success message and be redirected to the login page
- Valid coordinates for testing:
- Delhi: Longitude: 77.2090, Latitude: 28.7041
- Mumbai: Longitude: 72.8777, Latitude: 19.0760
- Bangalore: Longitude: 77.5946, Latitude: 12.9716
-
"User already exists" error
- Use a different email address for testing
-
"Network error"
- Ensure the server is running on port 8000
- Check if MongoDB is running
- Verify the API endpoint in
Client/src/ApiUri.ts
-
"Invalid coordinates" error
- Make sure longitude is between -180 and 180
- Make sure latitude is between -90 and 90
- Use the "Get My Location" button for automatic coordinates
-
CORS errors
- Ensure the CORS configuration in
Server/src/app.jsmatches your client URL - Check that the
envfile has the correct CORS origin
- Ensure the CORS configuration in
- ✅ Form validation (client-side and server-side)
- ✅ Password hashing
- ✅ Email uniqueness check
- ✅ Location coordinates validation
- ✅ Automatic location detection
- ✅ Loading states and error handling
- ✅ Success/error notifications
- ✅ JWT token authentication
- ✅ Password hashing with bcrypt
- ✅ CORS protection
- ✅ Input validation and sanitization
POST /api/v1/users/signupUser- User registrationPOST /api/v1/users/loginUser- User loginPOST /api/v1/users/logout- User logout
POST /api/v1/users/createProblem/:userId- Create problem reportGET /api/v1/users/getAllproblems- Get all problemsDELETE /api/v1/users/problem/:problemId/user/:userId- Delete problem
POST /api/v1/users/addComment/:problemId/:userId- Add commentDELETE /api/v1/users/comments/:commentId/:userId- Delete commentGET /api/v1/users/getComment/:problemId- Get comments for problem
{
name: String (required),
email: String (required, unique),
password: String (required, hashed),
phone: String,
location: {
type: String (enum: ['Point']),
coordinates: [Number, Number] // [longitude, latitude]
},
address: String,
createdAt: Date
}Janhit/
├── Client/ # React frontend
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ └── ApiUri.ts
└── Server/ # Node.js backend
├── src/
│ ├── controller/
│ ├── models/
│ ├── routes/
│ └── app.js
└── env
- Frontend: React, TypeScript, Tailwind CSS, Axios
- Backend: Node.js, Express, MongoDB, Mongoose
- Authentication: JWT, bcrypt
- Validation: Client-side and server-side validation
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.