-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5d528f2
Showing
53 changed files
with
19,677 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Internal Employee CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '**' | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '**' | ||
jobs: | ||
backend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Node.js for backend | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install backend dependencies | ||
run: | | ||
cd backend | ||
npm install | ||
- name: Lint backend code | ||
run: | | ||
cd backend | ||
npm run lint | ||
- name: Run backend tests | ||
run: | | ||
cd backend | ||
npm test | ||
frontend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Node.js for frontend | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install frontend dependencies | ||
run: | | ||
cd frontend | ||
npm install | ||
- name: Lint frontend code | ||
run: | | ||
cd frontend | ||
npm run lint | ||
- name: Run frontend tests | ||
run: | | ||
cd frontend | ||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Internal Employee Directory ![ workflow](https://github.com/devzero-inc/samples/actions/workflows/main.yml/badge.svg) | ||
|
||
## Overview | ||
This Internal Employee Directory is a modern, full-stack web application designed to manage and display employee information within an organization. It leverages a MongoDB database for efficient data storage, Node.js and Express.js for a robust server-side environment, and React.js with Tailwind CSS for an interactive and responsive client-side experience. | ||
|
||
![Alt Text](https://i.imgur.com/CIW6oSl.png) | ||
|
||
## Table of contents | ||
- [Features](#features) | ||
- [Technologies Used](#technologies-used) | ||
- [High Level Design](#high-level-design) | ||
- [Tech Stack](#tech-stack) | ||
- [Installation](#installation) | ||
|
||
## Features | ||
- **Employee Data Management:** Manage employee records, view individual details, and visualize organizational hierarchy. | ||
- **Search and Filter:** Quickly find employees based on various criteria. | ||
- **Responsive Design:** Accessible on various devices and screen sizes. | ||
- **Secure Access:** Role-based access control and authentication (TBD). | ||
|
||
|
||
## Technologies Used | ||
|
||
- **Database:** [MongoDB](https://www.mongodb.com/) - A document-based, distributed database built for modern application developers and for the cloud era. | ||
- **Backend:** | ||
- [Node.js](https://nodejs.org/) | ||
- [Express.js](https://expressjs.com/) | ||
- [Mongoose ODM](https://mongoosejs.com/) | ||
|
||
- **Frontend:** | ||
- [React.js](https://reactjs.org/) | ||
- [Tailwind CSS](https://tailwindcss.com/) | ||
|
||
|
||
|
||
## High Level Design | ||
|
||
![Alt Text](https://i.imgur.com/S7Fwpg1.jpeg) | ||
|
||
Our application operates by facilitating user interaction through the frontend interface. When a user accesses the frontend, the application initiates requests to the backend API endpoints. These endpoints, in turn, interact with the database to retrieve pertinent data. Once obtained, the backend delivers the requested data back to the frontend. The frontend is responsible for presenting this data on the website, ensuring a seamless and user-friendly experience. | ||
|
||
## Tech Stack | ||
|
||
Database: Our application utilizes a MongoDB database to store and manage data efficiently. | ||
|
||
Backend: The server-side of our application is powered by Node.js and Express.js. These technologies enable us to create a robust server and design RESTful APIs. Additionally, we leverage Mongoose as an Object Data Modeling (ODM) tool to facilitate seamless interactions with the MongoDB database. | ||
|
||
Frontend: For the client-side development, we have employed React.js, a powerful JavaScript library for building user interfaces. To enhance the visual aesthetics and responsiveness of the website, we have incorporated Tailwind CSS for comprehensive styling. | ||
|
||
|
||
### Prerequisites | ||
- Docker | ||
## Installation | ||
|
||
Dependencies: | ||
``` | ||
Docker version - 24.0.7 | ||
``` | ||
|
||
|
||
Run locally: | ||
```bash | ||
git clone https://github.com/devzero-inc/samples.git | ||
docker compose up -d | ||
``` | ||
Backend will be running on ```PORT:8000``` (you can test it by going to localhost:8000/test) -> [http://localhost:8000/](http://localhost:8000/) | ||
|
||
Frontend will be running on ```PORT:5173``` -> [http://localhost:5173/](http://localhost:5173/) | ||
|
||
Now just go to [http://localhost:5173/](http://localhost:5173/) and explore the application. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
./node_modules | ||
Dockerfile | ||
.dockerignore | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
"env": { | ||
"node": true, | ||
"commonjs": true, | ||
"es2021": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"overrides": [ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"files": [ | ||
".eslintrc.{js,cjs}" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
} | ||
} | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
}, | ||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM node:20-alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json . | ||
|
||
RUN npm ci | ||
|
||
COPY . . | ||
|
||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const express = require('express'); | ||
const cors = require('cors'); | ||
const employeeRoutes = require('./routes/employeeRoutes'); | ||
|
||
const app = express(); | ||
app.use(express.json()); | ||
app.use(cors()); | ||
|
||
app.get('/test', (req, res) => { | ||
res.send('Hello from server!'); | ||
}); | ||
|
||
app.use('/api/employees', employeeRoutes); | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
class Database { | ||
constructor() { | ||
this.connection = null; | ||
} | ||
|
||
async connect(uri) { | ||
if (!this.connection) { | ||
try { | ||
this.connection = await mongoose.connect(uri); | ||
|
||
console.log('Connected to the database'); | ||
} catch (error) { | ||
console.error('Error connecting to the database:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
return this.connection; | ||
} | ||
|
||
async disconnect() { | ||
if (this.connection) { | ||
try { | ||
await mongoose.disconnect(); | ||
|
||
console.log('Disconnected from the database'); | ||
} catch (error) { | ||
console.error('Error disconnecting from the database:', error); | ||
throw error; | ||
} finally { | ||
this.connection = null; | ||
} | ||
} | ||
} | ||
} | ||
|
||
const database = new Database(); | ||
|
||
module.exports = database; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const database = require('./database'); | ||
const app = require('./app'); | ||
require('dotenv').config(); | ||
|
||
database.connect(process.env.MONGO_URI); | ||
|
||
const PORT = process.env.PORT || 8000; | ||
|
||
app.listen(PORT, () => { | ||
console.log(`Server running on port ${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const employeeSchema = new mongoose.Schema({ | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
designation: { | ||
type: String, | ||
required: true, | ||
}, | ||
employeeID: { | ||
type: String, | ||
required: true, | ||
}, | ||
bio: { | ||
type: String, | ||
}, | ||
about:{ | ||
type: String, | ||
}, | ||
workHistory: { | ||
companyName: { | ||
type: String, | ||
}, | ||
position: { | ||
type: String, | ||
}, | ||
}, | ||
contactDetails:{ | ||
email: { | ||
type: String, | ||
}, | ||
phone: { | ||
type: Number, | ||
}, | ||
}, | ||
profiles:{ | ||
linkedIn: { | ||
type: String, | ||
}, | ||
github: { | ||
type: String, | ||
}, | ||
}, | ||
profilePicture: { | ||
type: String, | ||
}, | ||
}, {timestamps: true}); | ||
|
||
const Employee = mongoose.model('employee', employeeSchema); | ||
|
||
module.exports = Employee; |
Oops, something went wrong.