Skip to content

getwithashish/ExAM

Repository files navigation

IT Asset Management Tool

Overview

This project is a Django-based web application with a MySQL database, utilizing Celery for asynchronous task processing and Gunicorn for serving the application in a production environment. The project is containerized using Docker and has a frontend built with React and TypeScript using Vite and Yarn for production builds.

Table of Contents

Project Structure

.
β”œβ”€β”€ exam_django
β”‚Β Β  β”œβ”€β”€ ai
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ clients
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── gemini_client
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ config
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ migrations
β”‚Β Β  β”‚Β Β  └── service
β”‚Β Β  β”‚Β Β      └── database_service
β”‚Β Β  β”œβ”€β”€ asset
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ migrations
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ models
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ serializers
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_approve_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── lead_role_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_assign_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_count_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_lifecycle_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_log_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_type_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ asset_unassign_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ business_unit_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ data_import_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ employee_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ export_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ location_crud_service
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── memory_crud_service
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ tests
β”‚Β Β  β”‚Β Β  └── views
β”‚Β Β  β”œβ”€β”€ exam_django
β”‚Β Β  β”œβ”€β”€ notification
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ client
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ config
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ migrations
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ service
β”‚Β Β  β”‚Β Β  └── utils
β”‚Β Β  β”‚Β Β      └── email_body_contents
β”‚Β Β  β”œβ”€β”€ static
β”‚Β Β  β”œβ”€β”€ user_auth
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ migrations
β”‚Β Β  β”‚Β Β  └── tests
β”‚Β Β  └── utils
└── exam_frontend
    β”œβ”€β”€ public
    β”‚Β Β  β”œβ”€β”€ images
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ authentication
    β”‚Β Β  β”‚Β Β  β”œβ”€β”€ products
    β”‚Β Β  β”‚Β Β  └── users
    β”‚Β Β  └── static
    └── src
        β”œβ”€β”€ Test
        β”‚Β Β  β”œβ”€β”€ AssetTable
        β”‚Β Β  β”œβ”€β”€ Charts
        β”‚Β Β  β”œβ”€β”€ DrawerComponent
        β”‚Β Β  β”œβ”€β”€ DropDown
        β”‚Β Β  β”œβ”€β”€ Export
        β”‚Β Β  β”œβ”€β”€ GlobalSearch
        β”‚Β Β  └── RejectedAssetPage
        β”œβ”€β”€ components
        β”‚Β Β  β”œβ”€β”€ AddAsset
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ AssetTable
        β”‚Β Β  β”‚Β Β  β”œβ”€β”€ api
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ AssignAsset
        β”‚Β Β  β”‚Β Β  β”œβ”€β”€ AssetTable
        β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CardComponent
        β”‚Β Β  β”‚Β Β  β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”‚Β Β  └── Assign
        β”‚Β Β  β”‚Β Β      └── types
        β”‚Β Β  β”œβ”€β”€ AutocompleteBox
        β”‚Β Β  β”‚Β Β  └── api
        β”‚Β Β  β”œβ”€β”€ Avatar
        β”‚Β Β  β”œβ”€β”€ CardComponent
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ ChatBot
        β”‚Β Β  β”œβ”€β”€ DashBoardCardComponent
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ DashboardAssetTable
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ Deallocate
        β”‚Β Β  β”‚Β Β  └── AssetTable
        β”‚Β Β  β”‚Β Β      β”œβ”€β”€ CardComponent
        β”‚Β Β  β”‚Β Β      β”‚Β Β  └── types
        β”‚Β Β  β”‚Β Β      └── types
        β”‚Β Β  β”œβ”€β”€ DrawerComponent
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ DropDown
        β”‚Β Β  β”œβ”€β”€ Export
        β”‚Β Β  β”œβ”€β”€ GlobalSearch
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ Navbar
        β”‚Β Β  β”œβ”€β”€ NoData
        β”‚Β Β  β”œβ”€β”€ QueryBuilder
        β”‚Β Β  β”‚Β Β  β”œβ”€β”€ api
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ SideDrawerComponent
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ TableNavBar
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ TimelineLog
        β”‚Β Β  β”‚Β Β  └── api
        β”‚Β Β  β”œβ”€β”€ Tooltip
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”œβ”€β”€ Upload
        β”‚Β Β  β”œβ”€β”€ UserContext
        β”‚Β Β  β”œβ”€β”€ charts
        β”‚Β Β  β”‚Β Β  β”œβ”€β”€ api
        β”‚Β Β  β”‚Β Β  β”œβ”€β”€ chartHandlers
        β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ PieChartHandlers
        β”‚Β Β  β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  β”‚Β Β  └── types
        β”‚Β Β  └── sidebar
        β”‚Β Β      └── types
        β”œβ”€β”€ config
        β”œβ”€β”€ layouts
        └── pages
            β”œβ”€β”€ ApprovedRequest
            β”œβ”€β”€ AssignAsset
            β”œβ”€β”€ Deallocate
            β”œβ”€β”€ ExpiredAssets
            β”œβ”€β”€ MyApprovals
            β”œβ”€β”€ PendingRequest
            β”œβ”€β”€ RejectedAssetPage
            β”œβ”€β”€ RequestPage
            β”œβ”€β”€ UpdatableAssetPage
            β”œβ”€β”€ authentication
            └── index
                └── types

Prerequisites

  • Docker and Docker Compose
  • Python 3.10+
  • Node.js 18.20+ and yarn
  • MySQL

Run using Docker

Profiles are used for running docker containers in different environments.

For Development

Note: Add .env in exam_django with the configurations required for deploying in development environment

Note: Add aad.config.json in exam_django with the corresponding configurations

Note: Update .env in exam_frontend with the configurations required for deploying in development environment

docker compose --profile development up

For Stage

Note: Add .prod.env in exam_django with the configurations required for deploying in stage environment

Note: Add aad.config.json in exam_django with the corresponding configurations

Note: Update .env in exam_frontend with the configurations required for deploying in stage environment

docker compose --profile stage up

Backend Setup for Development

Install Dependencies

cd exam_django
// Create python virtual environment
pip install -r requirements.txt

Update Configurations in .env

// Dummy Values

DJANGO_SECRET_KEY=3r5@t!s6%j8(2)u@l*9z4&c%k1#s@9a7*
DEBUG_STATUS=True

DB_NAME=asset_management_database
DB_USER=my_user
DB_PORT=3306

DB_PASSWORD=my_password
DB_HOST=localhost

ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ORIGIN_WHITELIST=http://localhost:5173
CORS_ALLOWED_ORIGINS=http://localhost:5173

CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/0

EMAIL_HOST_USER=myemail@gmail.com
EMAIL_HOST_PASSWORD=abcd efgh ijk lmno
EMAIL_PORT=587
EMAIL_USE_TLS=True

SENTRY_DSN=https://72b3f8d4d2e4a2fc56d0c00e2a94b82e@r6248150176033174.ingest.us.sentry.io/234723642389
HEALTH_CHECK_APP=http://localhost:8000/health/app/
HEALTH_CHECK_EXTERNAL=http://localhost:8000/health/external/

BACKUP_PARENT_DIR=backup
FULL_BACKUP_DIR=full_backup

GOOGLE_API_KEY=your_api_key

Update configurations in aad.config.json

Change values of:

  • client_id
  • client_credential
  • authority
// Dummy values

{
    "type": {
        "client_type": "CONFIDENTIAL",
        "authority_type": "SINGLE_TENANT",
        "framework": "DJANGO"
    },
    "client": {
        "client_id": "12312cab-2342342-df324-32434c",
        "client_credential": "kasjdflasjdf3ou.asdjf~sdf23i9",
        "authority": "https://login.microsoftonline.com/723ba763cdf2370238"
    },
    "auth_request": {
        "redirect_uri": null,
        "scopes": [],
        "response_type": "code"
    },
    "flask": null,
    "django": {
        "id_web_configs": "MS_ID_WEB_CONFIGS",
        "auth_endpoints": {
            "prefix": "auth",
            "sign_in": "sign_in",
            "edit_profile": "edit_profile",
            "redirect": "redirect",
            "sign_out": "sign_out",
            "post_sign_out": "post_sign_out"
        }
    }
}

Migrations

python manage.py migrate

Run Development Server

python manage.py runserver

The development server will be hosted on http://localhost:8000 by default.

Celery Setup

Run Celery Worker

In another terminal,

celery -A exam_django worker --pool=solo --loglevel=info

Run Celery Beat

In another terminal,

celery -A exam_django beat --loglevel=info

Frontend Setup for Development

Install Dependencies

cd exam_frontend
yarn install

Update Configurations in .env

// Dummy values

VITE_CONFIG_URL=http://localhost:8000/api/v1
VITE_ADD_ASSET_URL=http://localhost:8000/api/v1/asset/
VITE_LOGIN_URL=http://localhost:8000/auth/sign_in
VITE_GET_ASSET_TYPE=http://localhost:8000/api/v1/asset/asset_type

Run Development Server

yarn dev

Populate Dummy Data

You should have curl installed in your system

For Linux

cd exam_django/dummy_data_scripts/
chmod +x dummy_data.sh
./dummy_data.sh 127.0.0.1

For Windows

cd exam_django/dummy_data_scripts/
dummy_data.bat 127.0.0.1

Login with test credentials

System Admin

  • username: getwithashish.sysadmin
  • password: getwithashish@sysadmin

Lead

  • username: getwithashish.lead
  • password: getwithashish@lead

Screenshots

Dashboard

Dashboard 1

Dashboard 2

Dashboard 3

Contribution

Feel free to open issues or pull requests if you find any bugs or have improvements.