The Propylon Document Management System is a streamlined web application comprising a fundamental API backend and a client based on Django and React. It facilitates users in storing files at specific URLs for subsequent retrieval. The system employs Django Restful Framwork as the backend and adheres to a RESTful design for its API endpoints.
The primary functional modules of the "Propylon Document Management" System include:
- Facilitates user registration, login, and logout functionalities.
- Validates fields such as username/email and password.
Upon logging in, users can access a comprehensive view of uploaded file details.
- Supports filtering files by type (Images, Documents, Videos, Procedures, Others).
- Displays detailed information such as Filename, Version, URL, Size, Type, CreateTime, and Description.
- Provides pagination functionality.
- Stores files of any type and name
- Stores files at any URL
- Restricts interaction to authenticated users only.
- Prevents a user from accessing files submitted by another user.
- Supports the Download of User-Indexed Resources
-
Restricts interaction to authenticated users only.
-
Ensures a user cannot access files submitted by another user.
-
Base Url :
http://localhost:8001
-
Api Version:
v1
Only the Register API and Login API do not require authentication.
For other APIs, the Auth Token should be included in the headers.
User registration involves providing a unique email, username, and password. The email must be unique across users.
POST /api/v1/register/
Params | Value | Type | Required | Desc |
---|---|---|---|---|
username | zhenxu | string | Yes | Limited length of username between 4 and 15 |
[email protected] | string | Yes | Follow email format. | |
password | zhenxu0101 | string | Yes | Limited length of username between 4 and 15 |
curl -X POST \
'http:/ip:port/api/v1/register/' \
-H 'Content-Type:application/json' \
-d '{"username":"zhenxu","email":"[email protected]","password":"zhenxu0101"}'
Responses
{
"code": 200,
"data": 'Register successful!'
}
Obtain the Auth Token by logging in.
POST /api/v1/login/
Params | Value | Type | Required | Desc |
---|---|---|---|---|
username | [email protected] | string | Yes | this params value equal to the email of register . Todo: change to the email fields. |
password | zhenxu0101 | string | Yes | Limited length of username between 4 and 15 |
curl -X POST \
'http:/ip:port/api/v1/login/' \
-H 'Content-Type:application/json' \
-d '{"username":"[email protected]","password":"zhenxu0101"}'
Responses
{
"code": 200,
"data": {
{"token":"3a7c21d3be77cee9761fc3d50c1e145ca469a0be","user_id":1}
}
}
Remove the Auth Token by logging out.
GET /api/v1/logout/
Params | Value | Type | Required | Desc |
---|---|---|---|---|
Header | { "Authorization": "Token 3a7c21d3be77cee9761fc3d50c1e145ca469a0be"} | Dict | Yes | Authorization by Token |
curl -X GET \
'http:/ip:port/api/v1/logout/' \
-H "Authorization: Token 6119fb3fa535d92e0b23fdbe04f610bde1ab4611"
Responses
{
"code": 200,
"data": 'Logout successful!'
}
Users can specify any valid URL like /xx/xxxx/xxxxx/xxxx/
,
Then file_url
will be generate with format like /files/{user specific url}/{file_name}'
POST /api/v1/files/
Body : form-data
Form-data including fields as follow:
Fields | Type | Required | Desc |
---|---|---|---|
file_desc | string | Yes | current desc for file like modify infos |
file_url | string | Yes | generated with format like '/files/{user specific url}/{file_name}' |
file_name | string | Yes | file name |
file_size | float | Yes | file size |
file_uid | string | Optional | file unique id |
file_obj | File | Yes | file obj |
curl -X POST \
'http:/ip:port/api/v1/files/' \
-H "Authorization: Token 6119fb3fa535d92e0b23fdbe04f610bde1ab4611"
-d {form-data}
Responses
{
"code": 200,
"data": [{...},{...},{...},{...}]
}
Retrieve all files of the logged-in user and display file information in the dashboard.
GET /api/v1/files/
curl -X GET \
'http:/ip:port/api/v1/files/'
-H "Authorization: Token 6119fb3fa535d92e0b23fdbe04f610bde1ab4611"
Responses
{
"code": 200,
"data": [{...},{...},{...},{...}]
}
Tips:
Obtain all versions of a specific file by hash(file_url)
,
wherefile_url_hash
is obtained using hashlib.md5()
of file_url
GET /api/v1/files/{file_url_hash}
curl -X GET \
'http:/ip:port/api/v1/files/{file_url_hash}'
-H "Authorization: Token 6119fb3fa535d92e0b23fdbe04f610bde1ab4611"
Responses
{
"code": 200,
"data": [{...},{...},{...},{...}]
}
Tips:
Get the file details by specific file_url
and revision
where file_url_hash
is obtained by using hashlib.md5()
of file_url
revision
is the file_version
GET /api/v1/files/{file_url_hash}?revision=1
curl -X GET \
'http:/ip:port/api/v1/files/{file_url_hash}?revision={file_version}'
-H "Authorization: Token 6119fb3fa535d92e0b23fdbe04f610bde1ab4611"
Responses
{
"code": 200,
"data": [{...},{...},{...},{...}]
}
Retrieve file content data by file_uuid
, file_type
, and file_name
.
Locate the file object data from the server storage (local static file) and return it.
GET /api/v1/files/content
Params: ?file_uuid={file_uuid}&file_type={file_type}&file_name={file_name}
curl -X GET \
'http:/ip:port/api/v1/files/content?file_uuid={file_uuid}&file_type={file_type}&file_name={file_name}'
-H "Authorization: Token 6119fb3fa535d92e0b23fdbe04f610bde1ab4611"
Responses
{
"code": 200,
"data": xxxxxxxxxxxxxxxxxxxxxxxx
}
git clone https://github.com/stoneyezhenxu/document-manager-assessment
- Install Pipenv Manages your Python virtual environments by Pipenv.
- This project requires Python 3.11 so you will need to ensure that this version of Python is installed on your OS before building the virtual environment.
pipenv install -r requirements/local.txt
.pipenv run python manage.py migrate
to create the database.pipenv run python manage.py runserver 0.0.0.0:8001
to start the development server on port 8001.
-
Navigate to the client/doc-manager directory.
-
yarn install
to install the dependencies. -
yarn start
to start the React development server.
-
To create a superuser account, use this command:
$ python manage.py createsuperuser
Running type checks with mypy:
$ mypy propylon_document_manager
To run the tests, check your test coverage, and generate an HTML coverage report:
$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html
$ pytest