This is a system (API) that manages documents with users and user roles. Each document defines access rights; the document defines which roles can access it. Also, each document specifies the date it was published. It is built with NodeJS, Express and Postgres as it's database. Source code employs ES6 syntax traspiled down to ES5 using Babel.
A created user will have a role: admin, regular.
-
Regular, rated/restricted Users can:
- Create an account
- Login
- Create a document
- Limit access to a document by specifying an access group
i.e. public, private or role
. - View public documents created by other users.
- View documents created by their access group with access level set as
role
. - Edit already created documents.
- View
public
androle
access level documents of other regular users. - Logout.
-
In addition to the general user functions, an admin user can:
- View all users.
- View all created documents.
- Delete any user.
- Update any user's records.
- Create a new role.
- View all created roles.
- Delete created roles aside the default roles
admin
andregular
Documents: Documents can be created and must have:
- title
- content
- access; set by default to public but can be any of
private, public or role
Authentication: Users are authenticated and validated using JSON web token (JWT). By generating a token on registration and login, API endpoints and documents are protected from unauthorised access. Requests to protected routes are validated using the generated token.
This application was developed using NodeJs with express for routing. Postgres was used for persisting data with Sequelize as ORM.
The frontend was built with the react and redux framework.
- Clone the project repository.
- Run git clone https://github.com/andela-hchukwu/Document-Management-System.git.
- Change directory into the Document-Management-System directory.
- Run npm install to install the dependencies in the package.json file.
- Use Postman or any API testing tool of your choice to access the endpoints.
- Run DB migrate commmand with
sequelize db:migrate
. - Run DB seeder command with
sequelize db:seed
to seed initial data into your DB. - Start the app with
$ npm start
- Login, Sign Up and start creating Documents once the app opens up on the browser
Read the docs: Documentation
- Then play around with the available routes
Here's the collection of routes. They can be checked out on Postman
EndPoint | Functionality |
---|---|
POST /users/login | Logs in a user. |
POST /users/logout | Logs out a user. |
POST /users/ | Creates a new user. |
GET /users/ | Gets all users (available to only the Admin). |
GET /users/:id | Finds user by id. |
PUT /users/:id | Updates a user's attributes based on the id specified (available to only the SuperAdmin and Admin) |
DELETE /users/:id | Deletes user (available only to the Admin) |
GET /users/:id/documents | Gets all documents for a particular user |
EndPoint | Functionality |
---|---|
POST /documents/ | Creates a new document instance. |
GET /documents/ | Gets all documents. |
GET /documents/:id | Find document by id. |
PUT /documents/:id | Updates a document attributes. |
DELETE /documents/:id | Delete document. |
GET search/documents/?q=${query} | Get all documents with title containing the search query |
EndPoint | Functionality |
---|---|
GET /roles/ | Get all Roles. |
POST /roles/ | Create a Role. |
PUT /roles/:id | Edit a Role. |
DELETE /roles/:id | Delete a Role. |
It should be noted that the endpoints for roles here are only available to the Admin.
- JavaScript (ES6)
- Node.js
- Express
- Postgresql
- React/Redux
- Sequelize ORM.
- Fork this repositry to your account.
- Clone your repositry: git clone https://github.com/andela-hchukwu/Document-Management-System.git
- Create your feature branch: git checkout -b new-feature
- Commit your changes: git commit -m "did something"
- Push to the remote branch: git push origin new-feature
- Open a pull request.
ISC
Copyright (c) 2017 Henry Chukwu