# manjeetgodara/medico-backend-dev architecture

> Architecture diagram of the GitHub repository manjeetgodara/medico-backend-dev, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manjeetgodara/medico-backend-dev
- Repository: https://github.com/manjeetgodara/medico-backend-dev

## Overview

##### Project type and purpose
- This is a modular, monolithic Django-based backend (“Medico-Backend”) serving as the core API for a healthcare/medico platform.
- It exposes REST endpoints, runs scheduled background jobs, handles transactions, notifications, search, promotions, and user management.

##### File structure
- Top-level project folder “MLP” contains Django project settings (settings.py), URL routing (urls.py), ASGI/WSGI entrypoints, and Celery integration (celery.py).
- Apps under root:
- cronjob – standalone scripts for periodic notifications (e.g., pendingnotifications.py, subscription_expiry.py)
- misc, notification_settings, promotions, search, transactions, users – each is a Django app with models.py, views.py/serializers.py, tests, URLs, services.
- Services folder inside MLP: reusable utilities (email services under MLP/services/emails, templating under MLP/services/templates, SES wrapper under MLP/services/utils).
- importData.py & db.json/demo_data.json – data import scripts.
- requirements.txt – lists dependencies.

##### README
- Minimal (“# Medico-Backend”) but confirms this repository is the central backend.

##### Main components & their interactions
a. Web/API Layer
- Gunicorn/Uvicorn + Django ASGI/WSGI serves HTTP(S) traffic
- URL routing delegates requests to app views (users, search, transactions, promotions, notification_settings, misc)
- Views/serializers orchestrate business logic and access the database via Django ORM
- Authentication/authorization handled in users app (decorators, consumers, signals)
b. Database
- A relational database (PostgreSQL/MySQL) storing all Django models across apps
- Migrations folder in each app indicates strong schema evolution
c. Background Task Layer
- Celery worker(s), configured in MLP/celery.py
- Message broker (Redis/RabbitMQ) receives tasks from Django and dispatches to workers
- cronjob app provides scheduled tasks either via Celery Beat or external cron invoking cronjob/main.py
- Tasks implemented in cronjob/*.py and possibly triggered by Django services
d. Email & Notification Services
- MLP/services/emails/email_services.py defines high-level email operations
- Templates in MLP/services/templates for various notification types
- SES wrapper (MLP/services/utils/seswrapper.py) integrates with AWS SES
e. External Services
- AWS SES for email delivery
- Payment gateway(s) in transactions/service.py (e.g., MIHPay, Apple transactions)
- Possibly caching layer (Redis) if used for session or rate-limiting
f. Data Import Utility
- importData.py reads db.json/demo_data.json to seed or migrate data

##### Architectural patterns & design principles
- Layered pattern: Presentation (views/serializers), Business (service.py), Data (models/migrations)
- Modular apps encourage separation of concerns
- Asynchronous processing via Celery for non-blocking tasks (emails, notifications, batch jobs)
- Template-based email generation keeps content separate from logic
- Cronjob scripts decouple periodic job definitions from core Django apps

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client and Gateway
    Client["Clients\n(Browser/Mobile)"]:::external
    API_Gateway["API Gateway\n(Load Balancer)"]:::infra
    Client -->|HTTPS Requests| API_Gateway

    %% Django App Server
    Django_Server["Django App Server\n(Gunicorn/Uvicorn)"]:::core
    API_Gateway -->|Pass to WSGI/ASGI| Django_Server

    %% Medico-Backend Project
    subgraph "Medico-Backend (MLP Project)"
        direction TB
        %% Core Configuration & Entrypoints
        Settings["settings.py"]:::core
        Urls["urls.py"]:::core
        ASGI["asgi.py"]:::core
        WSGI["wsgi.py"]:::core
        CeleryConfig["celery.py"]:::core

        Settings --> Django_Server
        Urls --> Django_Server
        ASGI --> Django_Server
        WSGI --> Django_Server
        CeleryConfig --> Django_Server

        %% Django Apps
        subgraph "Django Apps"
            direction TB
            Users["Users App\n(service layer)"]:::core
            Search["Search App\n(views & serializers)"]:::core
            Transactions["Transactions App\n(service layer)"]:::core
            Promotions["Promotions App"]:::core
            NotificationSettings["Notification Settings App"]:::core
            Miscellaneous["Miscellaneous App"]:::core

            Django_Server --> Users
            Django_Server --> Search
            Django_Server --> Transactions
            Django_Server --> Promotions
            Django_Server --> NotificationSettings
            Django_Server --> Miscellaneous
        end

        %% Shared Services Module
        subgraph "Shared Services"
            direction TB
            EmailServices["email_services.py"]:::services
            SESWrapper["seswrapper.py"]:::services
            TemplatesDir["Templates\n(registration, notifications)"]:::services
        end

        %% Data Import & Management
        ImportData["importData.py"]:::infra
        DemoData["db.json/demo_data.json"]:::infra
        ManagePy["manage.py"]:::infra

        %% Task Layer - Cronjob Scripts
        CronJobs["Cronjob Scripts\n(main, subscriptions, notifications)"]:::infra
    end

    %% Infrastructure
    DB["Relational Database\n(PostgreSQL/MySQL)"]:::infra
    Broker["Message Broker\n(Redis/RabbitMQ)"]:::infra
    Django_Server --> DB
    Django_Server --> Broker

    %% Celery Workers
    subgraph "Background Processing"
        direction TB
        CeleryWorkers["Celery Workers"]:::worker
        CeleryBeat["Celery Beat / Scheduler"]:::infra
    end

    Broker --> CeleryWorkers
    CeleryBeat --> CronJobs
    CronJobs -->|Enqueue Tasks| Broker
    CeleryWorkers --> EmailServices
    CeleryWorkers --> NotificationSettings

    %% Service Integrations
    EmailServices -->|Send Email via SES| AWS_SES
    SESWrapper --> AWS_SES
    Transactions -->|Payment Processing| PaymentGateway

    %% External Systems
    AWS_SES["AWS SES"]:::external
    PaymentGateway["Payment Gateway"]:::external

    %% Click Events
    click Settings "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/settings.py"
    click Urls "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/urls.py"
    click ASGI "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/asgi.py"
    click WSGI "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/wsgi.py"
    click CeleryConfig "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/celery.py"
    click Users "https://github.com/manjeetgodara/medico-backend-dev/blob/main/users/service.py"
    click Search "https://github.com/manjeetgodara/medico-backend-dev/blob/main/search/views.py"
    click Transactions "https://github.com/manjeetgodara/medico-backend-dev/blob/main/transactions/service.py"
    click NotificationSettings "https://github.com/manjeetgodara/medico-backend-dev/blob/main/notification_settings/service.py"
    click EmailServices "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/services/emails/email_services.py"
    click SESWrapper "https://github.com/manjeetgodara/medico-backend-dev/blob/main/MLP/services/utils/seswrapper.py"
    click CronJobs "https://github.com/manjeetgodara/medico-backend-dev/blob/main/cronjob/main.py"
    click ImportData "https://github.com/manjeetgodara/medico-backend-dev/blob/main/importData.py"
    click DemoData "https://github.com/manjeetgodara/medico-backend-dev/blob/main/db.json"
    click ManagePy "https://github.com/manjeetgodara/medico-backend-dev/blob/main/manage.py"

    %% Styles
    classDef core fill:#cce5ff,stroke:#004085,color:#004085
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#383d41
    classDef worker fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
    classDef services fill:#f8d7da,stroke:#721c24,color:#721c24
```
