-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added attendance service documentation (#25)
* chore : added attendance service doc * chore : added sequence to services * feat : added attendance apis * feat : added about and feature page
- Loading branch information
Showing
21 changed files
with
870 additions
and
5 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,7 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# About | ||
|
||
The attendance service is used to mark attendance for different context - events and cohorts, with its contextId. It supports latitude and longitude for location based attendance. Scope of the attendance can be self or student. It can be used to mark present, absent or on-leave records. |
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,13 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Features | ||
|
||
Following are the key features | ||
|
||
#### 1. Mark Bulk attendance #### | ||
Mark attendance of multiple users with bulk attendance marking API. | ||
|
||
#### 2. Search Attendance with filters and facets #### | ||
Search with limit and offsets along with various filters and facets. Facets are all column names of the table. Sort on facets or filters as per requirements. |
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,28 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Getting Started | ||
|
||
Before setting up the Attendance service, ensure you have the following prerequisites | ||
|
||
### Prerequisites | ||
|
||
- [Node.js] - Version 20 or later | ||
- [NestJS] - Familiarity with NestJS framework | ||
- [PostgreSQL] - Database for storing Attendance data | ||
|
||
[//]: # | ||
[Node.js]: http://nodejs.org | ||
[NestJS]: https://docs.nestjs.com | ||
[PostgreSQL]: https://www.postgresql.org/ | ||
|
||
### Setting Up Locally | ||
|
||
Follow these steps to set up the Attendance service on your local machine: | ||
|
||
1. **Install Node.js** | ||
If you haven’t already installed Node.js, download it from the [Node.js official website](http://nodejs.org). Follow the installation instructions for your operating system. | ||
|
||
2. **Install PostgreSQL** | ||
Download and install PostgreSQL from the [PostgreSQL official website](https://www.postgresql.org/download/). Follow the instructions based on your operating system to complete the installation. During installation, take note of the username and password you create for the 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,17 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Tech Stack | ||
|
||
#### Framework : | ||
- **nest.js** (for Node.js) | ||
|
||
#### Language : | ||
- **typescript** | ||
|
||
#### APIs : | ||
- **REST** | ||
|
||
#### Database : | ||
- **PostgreSQL** |
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,7 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
|
||
# Architecture | ||
|
||
![Attendance Service Architecture](assets/attendance_architecture.png) |
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,47 @@ | ||
--- | ||
sidebar_position: 6 | ||
--- | ||
|
||
# Database Schema | ||
|
||
## Entities -Attendance Management | ||
|
||
### Table: Attendance | ||
|
||
| **Column Name** | **Data Type** | **Details** | | ||
|---------------------|--------------------------|-------------------------------------------------------------------------------------------------| | ||
| `attendance` | `varchar` | **NOT NULL**, must be one of (`present`, `absent`, `on-leave`) | | ||
| `remark` | `varchar(255)` | Optional | | ||
| `image` | `varchar(500)` | Optional | | ||
| `metaData` | `varchar` | Optional | | ||
| `syncTime` | `varchar` | Optional | | ||
| `session` | `varchar` | Optional | | ||
| `contextId` | `uuid` | **NOT NULL** | | ||
| `context` | `varchar(255)` | **NOT NULL** | | ||
| `createdAt` | `timestamptz` | Defaults to current timestamp | | ||
| `updatedAt` | `timestamptz` | Defaults to current timestamp | | ||
| `attendanceId` | `uuid` | **NOT NULL**, Primary Key, defaults to `gen_random_uuid()` | | ||
| `tenantId` | `uuid` | **NOT NULL** | | ||
| `userId` | `uuid` | **NOT NULL** | | ||
| `attendanceDate` | `date` | **NOT NULL**, defaults to current date | | ||
| `latitude` | `float8` | Optional | | ||
| `longitude` | `float8` | Optional | | ||
| `createdBy` | `uuid` | Optional | | ||
| `updatedBy` | `uuid` | Optional | | ||
| `scope` | `public.attendance_scope` | Optional | | ||
|
||
## Indexes | ||
|
||
- **`Attendance_tenant`**: Hash index on `tenantId`. | ||
- **`Attendance_userId`**: Hash index on `userId`. | ||
|
||
## Constraints | ||
|
||
1. **Primary Key**: `PK_Attendance_attendanceId` on `attendanceId`. | ||
2. **Check Constraint**: `attendance` must be one of `present`, `absent`, or `on-leave`. | ||
|
||
## Triggers | ||
|
||
- **`set_public_Attendance_updatedAt`**: Trigger to update `updatedAt` timestamp before any update operation. | ||
|
||
![NotificationLogs](assets/attendance.png) |
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,42 @@ | ||
--- | ||
sidebar_position: 8 | ||
--- | ||
|
||
# Installation | ||
|
||
## Steps to Install Locally for Development | ||
|
||
### 1. Clone Git Repository | ||
|
||
```sh | ||
git clone https://github.com/tekdi/attendance-microservice | ||
cd attendance-microservice | ||
npm install | ||
``` | ||
|
||
### 2. Setup DB | ||
|
||
Make sure you have PostgreSQL installed and running. Create a database for the attendance service | ||
|
||
### 3. Environment Variables | ||
|
||
Create a .env file in the root directory of your project and add the necessary environment variables. | ||
|
||
```dotenv | ||
#server | ||
POSTGRES_HOST="add-here" | ||
POSTGRES_PORT="add-here" | ||
POSTGRES_USERNAME="add-here" | ||
POSTGRES_PASSWORD="add-here" | ||
POSTGRES_DATABASE="add-here" | ||
``` | ||
|
||
### 4. Run the Application | ||
|
||
```sh | ||
npm run start:dev | ||
``` | ||
|
||
## Steps for Server Side Setup | ||
@TODO |
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,8 @@ | ||
{ | ||
"label": "Attendance Service", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Learn about Attendance service" | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
docs/attendance-service/apis/attendance-api-collection.info.mdx
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,76 @@ | ||
--- | ||
id: attendance-api-collection | ||
title: "Attendance API Collection" | ||
description: "APIs of Attendance Service" | ||
sidebar_label: Introduction | ||
sidebar_position: 0 | ||
hide_title: true | ||
custom_edit_url: null | ||
--- | ||
|
||
import ApiLogo from "@theme/ApiLogo"; | ||
import Heading from "@theme/Heading"; | ||
import SchemaTabs from "@theme/SchemaTabs"; | ||
import TabItem from "@theme/TabItem"; | ||
import Export from "@theme/ApiExplorer/Export"; | ||
|
||
<span | ||
className={"theme-doc-version-badge badge badge--secondary"} | ||
children={"Version: 1.0"} | ||
> | ||
</span> | ||
|
||
<Heading | ||
as={"h1"} | ||
className={"openapi__heading"} | ||
children={"Attendance API Collection"} | ||
> | ||
</Heading> | ||
|
||
|
||
|
||
APIs of Attendance Service | ||
|
||
<div | ||
style={{"marginBottom":"2rem"}} | ||
> | ||
<Heading | ||
id={"authentication"} | ||
as={"h2"} | ||
className={"openapi-tabs__heading"} | ||
children={"Authentication"} | ||
> | ||
</Heading><SchemaTabs | ||
className={"openapi-tabs__security-schemes"} | ||
> | ||
<TabItem | ||
label={"API Key: access-token"} | ||
value={"access-token"} | ||
> | ||
|
||
|
||
|
||
|
||
<div> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<th> | ||
Security Scheme Type: | ||
</th><td> | ||
apiKey | ||
</td> | ||
</tr><tr> | ||
<th> | ||
Header parameter name: | ||
</th><td> | ||
Authorization | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</TabItem> | ||
</SchemaTabs> | ||
</div> | ||
|
71 changes: 71 additions & 0 deletions
71
docs/attendance-service/apis/attendance-controller-create-attendance.api.mdx
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,71 @@ | ||
--- | ||
id: attendance-controller-create-attendance | ||
title: "Create Attendance" | ||
description: "Create Attendance" | ||
sidebar_label: "Create Attendance" | ||
hide_title: true | ||
hide_table_of_contents: true | ||
api: eJyVlktv4zYQgP8KMacuIMWS7diJbmmyh6AoGmzcS4OgGEtjmxuJ1JKUd1XD/70YSdHL3tT1JRE5nOc3Qx5A52TQSa0eE4jgzjlSCaqY7rVyRqcpmb9jQ+io2wIPcjSYkSNjIXo5gMKMIILCknlMwAND3wppKIHImYI8kAoi+FaQKcGDhGxsZM422zOiPeGBjXeUIUQHoB+Y5SlrDqczml8vlj7d3K79cJrMfJxfL/z5dLEI5+FyHgQBeODKnKWtM1Jt4Xj0WtccKVROsv7KmR1hQmZgbXz4tY6DrPtVJyVLjMOKtXKkHG9hnqcyrhI5+Wo5ssOpar3+SrHj9BlOu5NkebdJ24kL41StdiRYViZCb4TbkcB+TRLaYJE6iACOHnRbD+joMuUJOjpVLaQSG20ydKIsy9LPMj9JBvamwXTuh1M/uF2FQTRdRrPF1Xwx+2vox2U+9Oz+d5CGMjRvZ4rnQYpOuiLpW1VFtiZTbWq1/fmuzHB7xtujBxk5fEB3DhcPbKnilczOn7RkrayxONmrMPrhLstPI3xBchrJS8lqxS9QbWOdn4vz2G/9l24ejGAcUNF39NUDJ13V8d24eXCabTbDoOqY+/FE4m4rsgxNCRF8riUZWnEiOQ79gRzKlBJBH5/aY1pUdsaN1aN/GFgEuSFLyomJwHXzj1Z+Srgn6OAF6NMaDOgMWhpZqsOPvzreqq93wOB3bVRd5BYsoH1tPtY7bdwg5xEk8fomWN7M/GAR3vrzm+uNv57i0qd4nmymIS1xEUBbdLCUbsREWPZQOThWPw7H5lrZukDTIOQ/w1R3+RQ7tGJNpER9tyTCFnFM1m6KNC2vKpAcbvly6Z1iPIYa6zqJQaEycjvNYeXaVrMW3Q4imGAuJ/twMiDPktnXd9grf8SFka585rFdh4GVU77Tb9RvXczlb1SeXCXNVXNXuJ028p/qMqhC4QvhS3eVfH6/1rrR3zXmB3iNhusItlZDy1W7cgFdrWyPsXatR1q31vLWLnW4jZeGIbYgtRNQqo2u8nvS/OLu6VHc8zskrtI5JuDu6dHywOqdeCazl3XPkml8DK+CxhuMedByVZiPDKu6NpU7h9PAXEsABzXJU5SK3S9Myns1aS+MBxsPhxV69WDHREYvcDis0dKfJj0eebl+GPE7KpEW1ykPzw2mlk6stw8O+OVLM2c/idMX1Fkn36jsP9GaeQbA75w9GsmGuRGO3jvR/8+jj+323l+dZe/Q7N7XWvwVK+gkTh5V7Gvb309/PK/Ag3XzOMs0Iw0Gv3MP4PfaJV15WjVztXaAFNW2qKGvdfLvX1AGt5A= | ||
sidebar_class_name: "post api-method" | ||
info_path: docs/attendance-service/apis/attendance-api-collection | ||
custom_edit_url: null | ||
--- | ||
|
||
import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint"; | ||
import ParamsDetails from "@theme/ParamsDetails"; | ||
import RequestSchema from "@theme/RequestSchema"; | ||
import StatusCodes from "@theme/StatusCodes"; | ||
import OperationTabs from "@theme/OperationTabs"; | ||
import TabItem from "@theme/TabItem"; | ||
import Heading from "@theme/Heading"; | ||
|
||
<Heading | ||
as={"h1"} | ||
className={"openapi__heading"} | ||
children={"Create Attendance"} | ||
> | ||
</Heading> | ||
|
||
<MethodEndpoint | ||
method={"post"} | ||
path={"/api/v1/attendance"} | ||
context={"endpoint"} | ||
> | ||
|
||
</MethodEndpoint> | ||
|
||
|
||
|
||
Create Attendance | ||
|
||
<Heading | ||
id={"request"} | ||
as={"h2"} | ||
className={"openapi-tabs__heading"} | ||
children={"Request"} | ||
> | ||
</Heading> | ||
|
||
<ParamsDetails | ||
parameters={[{"name":"userId","required":true,"in":"query","description":"userId required","schema":{"example":"123e4567-e89b-12d3-a456-426614174000","type":"string"}},{"name":"tenantid","in":"header","schema":{"type":"string"}}]} | ||
> | ||
|
||
</ParamsDetails> | ||
|
||
<RequestSchema | ||
title={"Body"} | ||
body={{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string","description":"The userid of the attendance","default":""},"attendanceDate":{"type":"string","description":"The date of the attendance in format yyyy-mm-dd","default":"2024-12-09T10:27:36.463Z"},"attendance":{"type":"string","description":"The attendance of the attendance","default":""},"remark":{"type":"string"},"latitude":{"type":"number"},"longitude":{"type":"number"},"image":{"type":"string"},"metaData":{"type":"string"},"syncTime":{"type":"string"},"session":{"type":"string"},"context":{"type":"string","description":"The context of the attendance","default":""},"contextId":{"type":"string","description":"The contextId of the attendance","default":""},"scope":{"type":"string"}},"required":["userId","attendanceDate","attendance","contextId"],"title":"AttendanceDto"},"examples":{"CreateAttendance":{"summary":"Example for CreateAttendance","description":"Detailed example for CreateAttendance","value":{"attendanceDate":"2024-12-09","attendance":"present / absent / on-leave","remark":"","latitude":0,"longitude":0,"image":"","metaData":"","syncTime":"","session":"Morning","context":"event / cohort","contextId":"dcb80783-0619-485f-b2a7-ec4df21e7a60","scope":"self / student"}}}}}}} | ||
> | ||
|
||
</RequestSchema> | ||
|
||
<StatusCodes | ||
id={undefined} | ||
label={undefined} | ||
responses={{"201":{"description":"Attendance has been created successfully."}}} | ||
> | ||
|
||
</StatusCodes> | ||
|
||
|
||
|
Oops, something went wrong.