PRO-CG is a Robust, Reliable and Secure System of Record designed to deliver actionable Insights and meet the complex needs of Modern Enterprises, Multinational Organizations, Government Agencies, and Non-Government Institutions - supporting Compliance, Internal Controls and Risk Management requirements!
The backend repository for the PROCG web application.
- Core Backend: Flask-based API with modular Blueprint architecture.
- Security: JWT authentication and Role-Based Access Control (RBAC).
- Async Processing: Celery and Redis for background and scheduled tasks.
- Data Management: PostgreSQL with SQLAlchemy.
For full documentation, including architecture details and API reference, please visit the Documentation Hub.
- Framework: Flask
- Database: PostgreSQL, SQLAlchemy
- Message Broker / Cache: Redis
- Task Queue: Celery
- Scheduler: Celery Redbeat
- Authentication: Flask-JWT-Extended
Ensure you have the following installed:
- Python 3.8+
- Redis Server
- PostgreSQL
- Git LFS: Required for downloading large driver files located in the
drivers/folder.git lfs install git lfs pull
-
Clone the repository:
git clone <repository-url> cd flask
-
Create and activate a virtual environment:
python -m venv procg_venv # Windows procg_venv\Scripts\activate # Linux/Mac source procg_venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Install local drivers: Some connectors (like ServiceNow) require proprietary drivers located in the
drivers/folder. Install them using:# Windows pip install drivers/cdata_servicenow_connector-25.0.9454-cp311-cp311-win_amd64.whl -
Install CData License: After installing CData connectors, you must activate the license.
Option A: Command Line (Recommended) Run the registration module for the specific connector:
# For CData Connect python -m cdata.connect.register # For ServiceNow python -m cdata.servicenow.register
Option B: GUI License Manager If the command line method fails, run the license manager executable directly:
- Navigate to
procg_venv\Lib\site-packages\cdata\installlic_connect(orinstalllic_servicenow). - Run
install-license.exe. - Enter your product key or start a trial.
- Navigate to
Create a .env file in the root directory with the following variables:
# Database (Production)
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
# Database (Test) - Optional, for frontend testing without affecting production
DATABASE_URL_TEST=postgresql://user:password@localhost:5432/dbname_test
# Redis / Celery
MESSAGE_BROKER=redis://localhost:6379/0
FLOWER_URL=http://localhost:5555
# Security
JWT_SECRET_ACCESS_TOKEN=your_jwt_secret
CRYPTO_SECRET_KEY=your_crypto_key
# Email
MAIL_SERVER=smtp.example.com
MAIL_PORT=587
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_passwordNote: For the full
.envfile, please contact the PROCG Backend team.Environment Loading:
- For local testing, ensure
load_dotenv()is used to load variables from the.envfile.- For production, use
env_pathor system environment variables directly.- Files to modify:
config.pyandexecutors/__init__.py.
The test database (DATABASE_URL_TEST) runs alongside production. Use it for:
- Frontend team testing without affecting production data
- API development and experimentation
- Integration testing
flask run
# OR
python -m flask runThe API will be available at http://localhost:5000.
To process background tasks:
celery -A executors:celery_app worker --loglevel=infoTo run scheduled tasks:
celery -A executors:celery_app beat --loglevel=infoFailed webhook deliveries schedule a per-delivery Celery task (redbeat_s.tasks.retry_single_webhook_delivery) with an eta matching next_retry_date, so workers do not poll the database every minute.
Beat only runs an hourly sweeper (redbeat_s.tasks.retry_webhooks_task) for rows that are still FAILED and far past next_retry_date (e.g. lost broker messages). Tune SWEEPER_GRACE_SECONDS and SWEEPER_BATCH_LIMIT in utils/webhook_service.py if needed.
Optional — isolate webhook HTTP work: add a dedicated queue and consume it explicitly, for example in your Flask/Celery config mapping:
task_routes={
"redbeat_s.tasks.retry_single_webhook_delivery": {"queue": "webhooks"},
"redbeat_s.tasks.retry_webhooks_task": {"queue": "webhooks"},
},Then start workers with that queue subscribed, e.g. celery -A executors:celery_app worker -Q celery,webhooks --loglevel=info.
api/: Contains all Flask Blueprints (routes and logic).executors/: Application factory, extensions, and task execution logic.redbeat_s/: Redbeat scheduled task functions.utils/: Utility functions.config.py: Application configuration.app.py: Application entry point.
While you can still run the app using python app.py if you add app.run() to the bottom of the file, we recommend using flask run.
python app.py: Runs the file as a standalone script. It requires you to manually manage the server start logic in your code.flask run: Uses the official Flask CLI. It automatically finds your application object, handles environment variables (.env) more robustly, and provides a cleaner separation between your code and the server.
flask run is the modern standard. It keeps the application entry point clean and is the preferred way to run Flask applications during development.