# kibet-rotich/cropdoc architecture

> Architecture diagram of the GitHub repository kibet-rotich/cropdoc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kibet-rotich/cropdoc
- Repository: https://github.com/kibet-rotich/cropdoc

## Overview

Cropdoc is a Django REST backend for crop, disease, treatment, and user records. Its main workflow routes API requests to CRUD or specialized handlers, serializes domain data, and reads or writes the configured database; disease queries can return treatment recommendations. Additional capabilities include user statistics, sample-image listing, Django admin, and maize-data population commands. The README identifies no broader product workflow, and the sampled files do not show a disease-detection or image-classification pipeline. The graph reflects only relationships visible in the excerpts or README; the configured database service is not identified.

Main entry points: [`core/views.py`](https://github.com/kibet-rotich/cropdoc/blob/main/core/views.py) (API handlers), [`core/admin.py`](https://github.com/kibet-rotich/cropdoc/blob/main/core/admin.py) (Admin registration), [`core/serializers.py`](https://github.com/kibet-rotich/cropdoc/blob/main/core/serializers.py) (API serializers), [`core/models.py`](https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py) (Crop records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_project_routes["Project routing<br/>[urls.py]"]
  node_app_routes["API routing<br/>[urls.py]"]
  node_api_handlers["API handlers<br/>[views.py]"]
  node_admin_setup["Admin registration<br/>[admin.py]"]
  node_serializers["API serializers<br/>[serializers.py]"]
end

subgraph group_domain["Crop knowledge"]
  node_user_records["User records<br/>[models.py]"]
  node_crop_records["Crop records<br/>[models.py]"]
  node_disease_records["Disease records<br/>[models.py]"]
  node_treatment_records["Treatment records<br/>[models.py]"]
  node_seed_command["Maize data import<br/>[populate_data.py]"]
end

subgraph group_storage["Data and configuration"]
  node_database_config["Database configuration<br/>[settings.py]"]
  node_database[("Configured database")]
  node_sample_images["Sample images"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_project_routes
node_project_routes -->|"routes API"| node_app_routes
node_app_routes -->|"dispatches requests"| node_api_handlers
node_project_routes -->|"routes admin"| node_admin_setup
node_api_handlers -->|"serializes results"| node_serializers
node_serializers -->|"maps fields"| node_user_records
node_serializers -->|"maps fields"| node_crop_records
node_serializers -->|"maps fields"| node_disease_records
node_serializers -->|"maps fields"| node_treatment_records
node_api_handlers -->|"queries users"| node_user_records
node_api_handlers -->|"serves crop CRUD"| node_crop_records
node_api_handlers -->|"queries diseases"| node_disease_records
node_api_handlers -->|"queries treatments"| node_treatment_records
node_admin_setup -->|"registers model"| node_user_records
node_admin_setup -->|"registers model"| node_crop_records
node_admin_setup -->|"registers model"| node_disease_records
node_admin_setup -->|"registers model"| node_treatment_records
node_seed_command -->|"ensures crop"| node_crop_records
node_seed_command -->|"creates diseases"| node_disease_records
node_seed_command -->|"creates treatments"| node_treatment_records
node_database_config -->|"configures connection"| node_database
node_api_handlers -->|"lists image files"| node_sample_images

click node_project_routes "https://github.com/kibet-rotich/cropdoc/blob/main/cropdoc/urls.py"
click node_app_routes "https://github.com/kibet-rotich/cropdoc/blob/main/core/urls.py"
click node_api_handlers "https://github.com/kibet-rotich/cropdoc/blob/main/core/views.py"
click node_admin_setup "https://github.com/kibet-rotich/cropdoc/blob/main/core/admin.py"
click node_serializers "https://github.com/kibet-rotich/cropdoc/blob/main/core/serializers.py"
click node_user_records "https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py"
click node_crop_records "https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py"
click node_disease_records "https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py"
click node_treatment_records "https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py"
click node_seed_command "https://github.com/kibet-rotich/cropdoc/blob/main/core/management/commands/populate_data.py"
click node_database_config "https://github.com/kibet-rotich/cropdoc/blob/main/cropdoc/settings.py"
click node_sample_images "https://github.com/kibet-rotich/cropdoc/tree/main/media/sample_images"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_project_routes,node_app_routes,node_api_handlers,node_admin_setup,node_serializers,node_client toneBlue
class node_user_records,node_crop_records,node_disease_records,node_treatment_records,node_seed_command toneAmber
class node_database_config,node_database,node_sample_images toneMint
```

## Components

### API and access

- [Project routing](https://github.com/kibet-rotich/cropdoc/blob/main/cropdoc/urls.py): `cropdoc/urls.py`
- [API routing](https://github.com/kibet-rotich/cropdoc/blob/main/core/urls.py): `core/urls.py`
- [API handlers](https://github.com/kibet-rotich/cropdoc/blob/main/core/views.py): `core/views.py`
- [Admin registration](https://github.com/kibet-rotich/cropdoc/blob/main/core/admin.py): `core/admin.py`
- [API serializers](https://github.com/kibet-rotich/cropdoc/blob/main/core/serializers.py): `core/serializers.py`

### Crop knowledge

- [User records](https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py): `core/models.py`
- [Crop records](https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py): `core/models.py`
- [Disease records](https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py): `core/models.py`
- [Treatment records](https://github.com/kibet-rotich/cropdoc/blob/main/core/models.py): `core/models.py`
- [Maize data import](https://github.com/kibet-rotich/cropdoc/blob/main/core/management/commands/populate_data.py): `core/management/commands/populate_data.py`

### Data and configuration

- [Database configuration](https://github.com/kibet-rotich/cropdoc/blob/main/cropdoc/settings.py): `cropdoc/settings.py`
- **Configured database**
- [Sample images](https://github.com/kibet-rotich/cropdoc/tree/main/media/sample_images): `media/sample_images`

### Other components

- **API client**

## Connections

- API client → Project routing: sends requests (evidence: `cropdoc/urls.py`)
- Project routing → API routing: routes API (evidence: `cropdoc/urls.py`)
- API routing → API handlers: dispatches requests (evidence: `core/urls.py`)
- Project routing → Admin registration: routes admin (evidence: `cropdoc/urls.py`)
- API handlers → API serializers: serializes results (evidence: `core/views.py`)
- API serializers → User records: maps fields (evidence: `core/serializers.py`)
- API serializers → Crop records: maps fields (evidence: `core/serializers.py`)
- API serializers → Disease records: maps fields (evidence: `core/serializers.py`)
- API serializers → Treatment records: maps fields (evidence: `core/serializers.py`)
- API handlers → User records: queries users (evidence: `core/views.py`)
- API handlers → Crop records: serves crop CRUD (evidence: `core/views.py`)
- API handlers → Disease records: queries diseases (evidence: `core/views.py`)
- API handlers → Treatment records: queries treatments (evidence: `core/views.py`)
- Admin registration → User records: registers model (evidence: `core/admin.py`)
- Admin registration → Crop records: registers model (evidence: `core/admin.py`)
- Admin registration → Disease records: registers model (evidence: `core/admin.py`)
- Admin registration → Treatment records: registers model (evidence: `core/admin.py`)
- Maize data import → Crop records: ensures crop (evidence: `core/management/commands/populate_data.py`)
- Maize data import → Disease records: creates diseases (evidence: `core/management/commands/populate_data.py`)
- Maize data import → Treatment records: creates treatments (evidence: `core/management/commands/populate_data.py`)
- Database configuration → Configured database: configures connection (evidence: `cropdoc/settings.py`)
- API handlers → Sample images: lists image files (evidence: `core/views.py`)
