Skip to content

Commit

Permalink
feat: updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LishuGupta652 committed Sep 2, 2023
1 parent 5f3721c commit 7ab4590
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
ignorePatterns: ['dist', '.eslintrc.cjs'],
ignorePatterns: ['dist', '.eslintrc.cjs', 'node_modules', 'webpack.config.js', 'webpack.config.prod.js', 'server'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
Expand Down
156 changes: 101 additions & 55 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,107 @@
# Problem why this project is not possible
![logo](https://i.imgur.com/lU5LxHe.png)

- Web app can't access location in background
- Web app can't access location when screen is off
- Web app can't access location when app is closed
- Web app can't access location when app is not in use
- Web app can't access location when app is not in foreground
- Web app can't access location when app is not in focus
# GeoAttend: Revolutionizing Attendance with Geofencing

Introducing **GeoAttend**, a cutting-edge Geospatial Attendance System designed to streamline attendance tracking for organizations and events of all sizes. With a robust set of features and a
user-friendly interface, GeoAttend ensures accurate and efficient attendance management through advanced geofencing technology.

## Screenshots

![Screenshot 2023-09-02 221546](https://i.imgur.com/nZRuZ2A.png)

![Screenshot 2023-09-02 221434](https://i.imgur.com/DJ9VjxK.png)

![Screenshot 2023-09-02 221514](https://i.imgur.com/rlq9m1C.png)

## Technologies Used:

- **Frontend:** React, Redux, Material UI, React Router, React Hooks, React Context API, React Leaflet, React Geolocation, React Google Maps, React Google Charts, React Google Login, React Google

- **Backend:** Node.js, Express.js, MongoDB, Mongoose, JWT, Bcrypt, Nodemailer, Nodemailer Sendgrid Transport, Nodemon, Concurrently, Axios, Dotenv, Cors, Body Parser, Cookie Parser, Multer, Multer

- **API Testing:** Postman

- **Development Environment:** VS Code, Git, GitHub, Heroku, Netlify, MongoDB Atlas

- **Project Management:** Figma, Lucidchart, Google Docs

- **Version Control:** Git, GitHub

- **Deployment:** Heroku, Netlify, MongoDB Atlas

## Installation

#### Install Client

```bash
npm install
```

#### Install Server

```bash
cd server
npm install
```

## Run Locally

Open frontend and backend in different terminals. Go to the project directory

#### Start server

Install dependencies

```bash
cd server
npm install
```

```bash
npm run start:backend
```

#### Start Client

Install dependencies

```bash
npm install
```

```bash
npm run start:frontend
```

## Deployment

# Project Summary (NEVER OVER-ENGINEER)
To deploy this project run

```bash
npm run prod
```

## Environment Variables

To run this project, you will need to add the following environment variables to your .env file

#### Server Env

> put the env inside ./server/.env
`MONGODB_URI`

`TOKEN_SECRET`

`PORT`

# Project Summary

- Automation
- Production Ready
- Scalable
- Maintainable

# GeoAttend: Revolutionizing Attendance with Geofencing

Introducing **GeoAttend**, a cutting-edge Geospatial Attendance System designed to streamline attendance tracking for organizations and events of all sizes. With a robust set of features and a
user-friendly interface, GeoAttend ensures accurate and efficient attendance management through advanced geofencing technology.

## Key Features:

- **Diverse Organizational Support:** GeoAttend caters to a wide range of organizations, including universities, event halls, classrooms, and more, offering seamless attendance management for
Expand Down Expand Up @@ -66,48 +149,7 @@ reducing the administrative burden on organizations.
GeoAttend also offers a diverse set of features, including event creation, location setting, event scheduling, and user management, empowering administrators to manage events with ease. The platform
also caters to a wide range of organizations, including universities, event halls, classrooms, and more, offering seamless attendance management for hundreds of events across different locations.

## Technical Details:

### Technologies Used:

- **Frontend:** React, Redux, Material UI, React Router, React Hooks, React Context API, React Leaflet, React Geolocation, React Google Maps, React Google Charts, React Google Login, React Google
Places Autocomplete, React Google Recaptcha, React Google Maps Loader, React Google Maps API, React Google Maps Directions, React Google Maps Loader

- **Backend:** Node.js, Express.js, MongoDB, Mongoose, JWT, Bcrypt, Nodemailer, Nodemailer Sendgrid Transport, Nodemon, Concurrently, Axios, Dotenv, Cors, Body Parser, Cookie Parser, Multer, Multer
S3, AWS SDK, AWS S3, GeoLib, GeoLib Clean Coordinates, GeoLib Get Center, GeoLib Get Bounding Box, GeoLib Get Distance, GeoLib Get Rhumb Line, GeoLib Get Rhumb Line Between, GeoLib Get Rhumb Line
Point, GeoLib Get Rhumb Line Point Between, GeoLib Get Great Circle, GeoLib Get Great Circle Between, GeoLib Get Great Circle Point, GeoLib Get Great Circle Point Between, GeoLib Get Nearest,
GeoLib Get Nearest Point, GeoLib Get Nearest Point Of Line, GeoLib Get Nearest Point Of Line Segment, GeoLib Get Nearest Point Of Polygon, GeoLib Get Nearest Point Of Polygon Edge, GeoLib Get
Nearest Point Of Polygon Vertex, GeoLib Get Nearest Point Of Polygon

- **API Testing:** Postman, Jest, Supertest

- **Development Environment:** VS Code, Git, GitHub, Heroku, Netlify, MongoDB Atlas, AWS S3

- **Project Management:** Trello, Figma, Lucidchart, Google Docs, Google Slides, Google Sheets, Google Forms, Google Meet, Google Drive, Google Calendar, Google Maps, Google Places, Google
Recaptcha, Google Analytics, Google Search Console, Google Cloud Platform, Google Cloud Storage, Google Cloud Functions, Google Cloud Run, Google Cloud Build, Google Cloud SQL, Google Cloud
Firestore, Google Cloud Pub/Sub, Google Cloud CDN, Google Cloud IAM, Google Cloud Billing, Google Cloud Logging, Google Cloud Monitoring, Google Cloud Error Reporting, Google Cloud Debugger,
Google Cloud Profiler, Google Cloud Trace, Google Cloud Security Scanner, Google Cloud Web Security Scanner, Google Cloud API Gateway, Google Cloud Endpoints, Google Cloud Memorystore, Google
Cloud Scheduler, Google Cloud Tasks, Google Cloud Secret Manager, Google Cloud Key Management Service, Google Cloud Storage Transfer Service, Google Cloud Data Transfer Service, Google Cloud
BigQuery, Google Cloud Dataflow, Google Cloud Dataproc, Google Cloud Datalab, Google Cloud Data Studio, Google Cloud Data Catalog, Google Cloud Data Fusion, Google Cloud Data Loss Prevention,
Google Cloud Data Labeling Service, Google Cloud Data Migration Service, Google Cloud Data Catalog, Google Cloud Data

- **Version Control:** Git, GitHub

- **Deployment:** Heroku, Netlify, MongoDB Atlas, AWS S3

### System Architecture:

![System Architecture](./images/system-architecture.png)

### Database Schema:

![Database Schema](./images/database-schema.png)

### API Routes:

![API Routes](./images/api-routes.png)

## Drawbacks to Consider and Handle (CHAT GPT)
## Drawbacks to Consider and Handle

1. **Battery Drain:** Continuous use of geolocation services can lead to increased battery consumption on users' devices. This can be a concern, especially for longer events or when users forget to
turn off location services.
Expand Down Expand Up @@ -182,6 +224,10 @@ GeoAttend is a powerful attendance management system that can be further enhance

- **One User Per Device:** Restricting users to one device per account can help prevent unauthorized access and improve attendance accuracy.

# Problem why this project is not possible on Web App (PWA) ?

- Web app can't access location in background / when screen is off / when app is closed / when app is not in use / when app is not in foreground / when app is not in focus.

# Report a Bug

- lishugupta652@gmail.com To report a bug, please [open an issue](https://github.com/LishuGupta652/GeoAttend/issues/new) on GitHub and provide detailed information about the bug, including steps to
Expand Down
4 changes: 4 additions & 0 deletions Server/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# MONGODB_URI = mongodb+srv://lishugupta652:mongodc652@firstcluster.76qkd.mongodb.net/geoattend_dev
MONGODB_URI=mongodb://localhost:27017/geoattend_dev
TOKEN_SECRET='thattypescriptguy'
PORT=3001
6 changes: 0 additions & 6 deletions Server/README.MD

This file was deleted.

164 changes: 81 additions & 83 deletions Server/controllers/User.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,98 @@
const User = require("../models/User");
const bcrypt = require("bcrypt");
const jwt = require("jsonwebtoken");
const { loginValidation, registerValidation } = require("../validation");
const User = require('../models/User');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const { loginValidation, registerValidation } = require('../validation');

exports.homepage = (req, res) => {
return res.status(200).json({
error: "You are not authorized to access this page.",
message: "Welcome to Gea Attend API v1.0.0",
});
return res.status(200).json({
error: 'You are not authorized to access this page.',
message: 'Welcome to Gea Attend API v1.0.0'
});
};

exports.signup = async (req, res) => {
const { warning, value, error } = registerValidation(req.body);
if (error) {
return res.status(400).json({
error: error.details[0].message,
message: "",
});
}
const { warning, value, error } = registerValidation(req.body);
if (error) {
return res.status(400).json({
error: error.details[0].message,
message: ''
});
}

// Check if the user already exists
const emailExists = await User.findOne({ email: req.body.email });
if (emailExists) {
return res.status(400).send({
error: "Email already exists",
message: "",
});
}
// Check if the user already exists
const emailExists = await User.findOne({ email: req.body.email });
if (emailExists) {
return res.status(400).send({
error: 'Email already exists',
message: ''
});
}

// Hash the password
// Salt must be integer and bcrypt is responding with a string
const salt = bcrypt.genSalt(10);
const hashedPassword = await bcrypt.hash(req.body.password, parseInt(salt));
// Hash the password
// Salt must be integer and bcrypt is responding with a string
const salt = bcrypt.genSalt(10);
const hashedPassword = await bcrypt.hash(req.body.password, parseInt(salt));

// Create New User
const user = new User({
name: req.body.name,
email: req.body.email,
password: hashedPassword,
});
try {
const savedUser = await user.save();
res.send({ user: { id: savedUser._id } });
} catch (err) {
console.log(err);
res.status(404).json({
error: "Something went wrong. Please try again later.",
message: err.message,
// Create New User
const user = new User({
name: req.body.name,
email: req.body.email,
password: hashedPassword
});
}
try {
const savedUser = await user.save();
res.send({ user: { id: savedUser._id } });
} catch (err) {
console.log(err);
res.status(404).json({
error: 'Something went wrong. Please try again later.',
message: err.message
});
}
};

exports.login = async (req, res) => {
// Validate the data
try {
const { error } = loginValidation(req.body);
if (error) return res.status(400).send(error.details[0].message);
const { email, password } = req.body;
// Validate the data
try {
const { error } = loginValidation(req.body);
if (error) return res.status(400).send(error.details[0].message);
const { email, password } = req.body;

// Validating the email
const user = await User.findOne({ email: email });
if (!user) {
return res.status(400).send({
error: "No User Found",
message: "",
});
}
// Validating the email
const user = await User.findOne({ email: email });
if (!user) {
return res.status(400).send({
error: 'No User Found',
message: ''
});
}

// Validating the password
const validPass = await bcrypt.compare(password, user.password);
if (!validPass) {
return res.status(400).send({
error: "Email or password is wrong",
message: "",
});
}
// Validating the password
const validPass = await bcrypt.compare(password, user.password);
if (!validPass) {
return res.status(400).send({
error: 'Email or password is wrong',
message: ''
});
}

const token = jwt.sign(
{
_id: user._id,
email,
name: user.name,
exp: Math.floor(Date.now() / 1000) + 60 * 60,
},
process.env.TOKEN_SECRET
);
const token = jwt.sign(
{
_id: user._id,
email,
name: user.name,
exp: Math.floor(Date.now() / 1000) + 60 * 60
},
process?.env?.TOKEN_SECRET
);

res.cookie("auth-token", token, { httpOnly: true });
return res.header("auth-token", token).json({ user: { token: token } });
} catch (err) {
console.log(
"Error while logging in: " + err.message + " " + err.details[0].message
);
res.status(404).json({
error: "Something went wrong. Please try again later.",
message: err.message,
});
}
res.cookie('auth-token', token, { httpOnly: true });
return res.header('auth-token', token).json({ user: { token: token } });
} catch (err) {
console.log('Error while logging in: ' + err.message + ' ' + err);
res.status(404).json({
error: 'Something went wrong. Please try again later.',
message: err.message
});
}
};
Loading

0 comments on commit 7ab4590

Please sign in to comment.