# souptik-mu/leafdoc architecture

> Architecture diagram of the GitHub repository souptik-mu/leafdoc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/souptik-mu/leafdoc
- Repository: https://github.com/souptik-mu/leafdoc

## Overview

LeafDoc is a React/Spring Boot application with a separately runnable FastAPI ML service. The documented user journey is to use the frontend, authenticate through the backend, and use backend-backed features; however, the sampled frontend is still the Vite starter screen, so no frontend API calls are evidenced. The backend tree identifies authentication and ML components, while the README documents MySQL, email, and OTP capabilities. Backend implementation excerpts were not provided, and the ML prediction handler currently only reports uploaded-file metadata; uncertain wiring is therefore omitted.

Main entry points: [`LeafDocBackend/src/main/java/com/example/leafdoc/controllers/AuthController.java`](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/controllers/AuthController.java) (Auth endpoints), [`LeafDocBackend/src/main/java/com/example/leafdoc/repository/UserRepository.java`](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/repository/UserRepository.java) (User repository), [`ml-service/app/server.py`](https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/server.py) (FastAPI server), [`LeafDocFrontend/src/main.tsx`](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocFrontend/src/main.tsx) (React entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_webroot["React entry<br/>[main.tsx]"]
  node_webapp["Application UI<br/>[App.tsx]"]
end

subgraph group_backend["Spring backend"]
  node_authapi["Auth endpoints"]
  node_authlogic["Auth service<br/>[AuthService.java]"]
  node_authdata["Auth DTOs"]
  node_jwt["JWT security"]
  node_securityconfig["Security config"]
  node_mlapi["ML endpoints<br/>[MlController.java]"]
  node_mllogic["ML client logic<br/>[MlService.java]"]
  node_mailotp["Email and OTP"]
end

subgraph group_ml["ML service"]
  node_mlserver["FastAPI server<br/>[server.py]"]
  node_mlconfig["ML configuration<br/>[config.py]"]
  node_predictor["Model module<br/>[model.py]"]
end

subgraph group_state["Persistence and identity"]
  node_userentity["User entity<br/>[User.java]"]
  node_userrepo["User repository"]
  node_mysql[("MySQL")]
end

node_person(("User"))

node_person -->|"opens"| node_webroot
node_webroot -->|"renders"| node_webapp
node_person -->|"authenticates"| node_authapi
node_authapi --> node_authlogic
node_authapi -->|"accepts and returns"| node_authdata
node_authlogic --> node_userrepo
node_userrepo -->|"persists"| node_userentity
node_userrepo -->|"reads and writes"| node_mysql
node_securityconfig -->|"configures"| node_jwt
node_person -->|"requests diagnosis"| node_mlapi
node_mlapi --> node_mllogic
node_mllogic -.->|"calls configured service"| node_mlserver
node_person -->|"uploads image"| node_mlserver
node_mlserver -->|"reads settings"| node_mlconfig

click node_webroot "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocFrontend/src/main.tsx"
click node_webapp "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocFrontend/src/App.tsx"
click node_authapi "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/controllers/AuthController.java"
click node_authlogic "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/service/AuthService.java"
click node_authdata "https://github.com/souptik-mu/leafdoc/tree/main/LeafDocBackend/src/main/java/com/example/leafdoc/DTO"
click node_jwt "https://github.com/souptik-mu/leafdoc/tree/main/LeafDocBackend/src/main/java/com/example/leafdoc/security"
click node_securityconfig "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/confiurations/SecurityConfig.java"
click node_mlapi "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/controllers/MlController.java"
click node_mllogic "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/service/MlService.java"
click node_userentity "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/entity/User.java"
click node_userrepo "https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/repository/UserRepository.java"
click node_mailotp "https://github.com/souptik-mu/leafdoc/tree/main/LeafDocBackend/src/main/java/com/example/leafdoc/service"
click node_mlserver "https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/server.py"
click node_mlconfig "https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/config.py"
click node_predictor "https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/ml/model.py"

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_webroot,node_webapp,node_person toneBlue
class node_authapi,node_authlogic,node_authdata,node_jwt,node_securityconfig,node_mlapi,node_mllogic,node_mailotp toneAmber
class node_mlserver,node_mlconfig,node_predictor toneMint
class node_userentity,node_userrepo,node_mysql toneRose
```

## Components

### Web interface

- [React entry](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocFrontend/src/main.tsx): `LeafDocFrontend/src/main.tsx`
- [Application UI](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocFrontend/src/App.tsx): `LeafDocFrontend/src/App.tsx`

### Spring backend

- [Auth endpoints](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/controllers/AuthController.java): `LeafDocBackend/src/main/java/com/example/leafdoc/controllers/AuthController.java`
- [Auth service](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/service/AuthService.java): `LeafDocBackend/src/main/java/com/example/leafdoc/service/AuthService.java`
- [Auth DTOs](https://github.com/souptik-mu/leafdoc/tree/main/LeafDocBackend/src/main/java/com/example/leafdoc/DTO): `LeafDocBackend/src/main/java/com/example/leafdoc/DTO`
- [JWT security](https://github.com/souptik-mu/leafdoc/tree/main/LeafDocBackend/src/main/java/com/example/leafdoc/security): `LeafDocBackend/src/main/java/com/example/leafdoc/security`
- [Security config](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/confiurations/SecurityConfig.java): `LeafDocBackend/src/main/java/com/example/leafdoc/confiurations/SecurityConfig.java`
- [ML endpoints](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/controllers/MlController.java): `LeafDocBackend/src/main/java/com/example/leafdoc/controllers/MlController.java`
- [ML client logic](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/service/MlService.java): `LeafDocBackend/src/main/java/com/example/leafdoc/service/MlService.java`
- [Email and OTP](https://github.com/souptik-mu/leafdoc/tree/main/LeafDocBackend/src/main/java/com/example/leafdoc/service): `LeafDocBackend/src/main/java/com/example/leafdoc/service`

### ML service

- [FastAPI server](https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/server.py): `ml-service/app/server.py`
- [ML configuration](https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/config.py): `ml-service/app/config.py`
- [Model module](https://github.com/souptik-mu/leafdoc/blob/main/ml-service/app/ml/model.py): `ml-service/app/ml/model.py`

### Persistence and identity

- [User entity](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/entity/User.java): `LeafDocBackend/src/main/java/com/example/leafdoc/entity/User.java`
- [User repository](https://github.com/souptik-mu/leafdoc/blob/main/LeafDocBackend/src/main/java/com/example/leafdoc/repository/UserRepository.java): `LeafDocBackend/src/main/java/com/example/leafdoc/repository/UserRepository.java`
- **MySQL**

### Other components

- **User**

## Connections

- User → React entry: opens
- React entry → Application UI: renders
- User → Auth endpoints: authenticates
- Auth endpoints → Auth service
- Auth endpoints → Auth DTOs: accepts and returns
- Auth service → User repository
- User repository → User entity: persists
- User repository → MySQL: reads and writes
- Security config → JWT security: configures
- User → ML endpoints: requests diagnosis
- ML endpoints → ML client logic
- ML client logic → FastAPI server: calls configured service
- User → FastAPI server: uploads image
- FastAPI server → ML configuration: reads settings
