# rithickkumar308/ai-weatherwise- architecture

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

- Interactive diagram: https://gitdiagram.com/rithickkumar308/ai-weatherwise-
- Repository: https://github.com/rithickkumar308/ai-weatherwise-

## Overview

Weatherwise is a backend API for city weather lookup, AI-generated summaries and recommendations, user accounts, and per-user favorite locations. The main workflow is an API request routed through Express to a controller, which fetches weather or invokes AI generation and returns a result; account and favorites operations use authentication and user/location models. The excerpts show controller, route, and service relationships, but no README description or frontend. Database wiring is indexed but its implementation was not excerpted.

Main entry points: [`AI-Weatherwise/Backend/src/app.js`](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/app.js) (Express app), [`AI-Weatherwise/Backend/src/middleware/authMiddleware.js`](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/middleware/authMiddleware.js) (Token protection), [`AI-Weatherwise/Backend/src/routes/authRoutes.js`](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/authRoutes.js) (Auth routes), [`AI-Weatherwise/Backend/src/routes/aiRoutes.js`](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/aiRoutes.js) (AI routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API runtime"]
  node_server["Server startup<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
  node_dbconfig["DB connection<br/>[db.js]"]
end

subgraph group_identity["Accounts and access"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authcontroller["Account controller<br/>[authController.js]"]
  node_authmiddleware["Token protection<br/>[authMiddleware.js]"]
  node_usermodel["User model<br/>[User.js]"]
end

subgraph group_weather["Weather lookup"]
  node_weatheroutes["Weather routes<br/>[weatherRoutes.js]"]
  node_weathercontroller["Weather controller"]
  node_weatherservice["Weather service<br/>[weatherService.js]"]
  node_openweather["OpenWeatherMap"]
end

subgraph group_ai["AI guidance"]
  node_airoutes["AI routes<br/>[aiRoutes.js]"]
  node_aicontroller["AI controller<br/>[aiController.js]"]
  node_aiservice["AI service<br/>[aiService.js]"]
  node_gemini["Gemini API"]
end

subgraph group_favorites["Favorite locations"]
  node_locationroutes["Favorite routes<br/>[locationRoutes.js]"]
  node_locationcontroller["Favorite controller"]
  node_locationmodel["Location model<br/>[Location.js]"]
end

node_client(("API client"))

node_client -.->|"sends requests"| node_app
node_server -->|"starts"| node_app
node_server -->|"connects database"| node_dbconfig
node_app -->|"mounts"| node_authroutes
node_app -->|"mounts"| node_weatheroutes
node_app -->|"mounts"| node_airoutes
node_app -->|"mounts"| node_locationroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"protects profile"| node_authmiddleware
node_authcontroller -->|"queries"| node_usermodel
node_authmiddleware -->|"loads user"| node_usermodel
node_weatheroutes -->|"dispatches"| node_weathercontroller
node_weathercontroller -->|"fetches weather"| node_weatherservice
node_weatherservice -->|"requests weather"| node_openweather
node_airoutes -->|"dispatches"| node_aicontroller
node_airoutes -->|"protects endpoints"| node_authmiddleware
node_aicontroller -->|"generates guidance"| node_aiservice
node_aiservice -->|"generates content"| node_gemini
node_locationroutes -->|"dispatches"| node_locationcontroller
node_locationroutes -->|"protects endpoints"| node_authmiddleware
node_locationcontroller -->|"manages favorites"| node_locationmodel

click node_server "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/server.js"
click node_app "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/app.js"
click node_dbconfig "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/config/db.js"
click node_authroutes "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/authRoutes.js"
click node_authcontroller "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/authController.js"
click node_authmiddleware "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/middleware/authMiddleware.js"
click node_usermodel "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/models/User.js"
click node_weatheroutes "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/weatherRoutes.js"
click node_weathercontroller "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/weatherController.js"
click node_weatherservice "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/services/weatherService.js"
click node_airoutes "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/aiRoutes.js"
click node_aicontroller "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/aiController.js"
click node_aiservice "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/services/aiService.js"
click node_locationroutes "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/locationRoutes.js"
click node_locationcontroller "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/locationController.js"
click node_locationmodel "https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/models/Location.js"

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_server,node_app,node_dbconfig,node_client toneBlue
class node_authroutes,node_authcontroller,node_authmiddleware,node_usermodel toneAmber
class node_weatheroutes,node_weathercontroller,node_weatherservice,node_openweather toneMint
class node_airoutes,node_aicontroller,node_aiservice,node_gemini toneRose
class node_locationroutes,node_locationcontroller,node_locationmodel toneIndigo
```

## Components

### API runtime

- [Server startup](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/server.js): `AI-Weatherwise/Backend/src/server.js`
- [Express app](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/app.js): `AI-Weatherwise/Backend/src/app.js`
- [DB connection](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/config/db.js): `AI-Weatherwise/Backend/src/config/db.js`

### Accounts and access

- [Auth routes](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/authRoutes.js): `AI-Weatherwise/Backend/src/routes/authRoutes.js`
- [Account controller](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/authController.js): `AI-Weatherwise/Backend/src/controllers/authController.js`
- [Token protection](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/middleware/authMiddleware.js): `AI-Weatherwise/Backend/src/middleware/authMiddleware.js`
- [User model](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/models/User.js): `AI-Weatherwise/Backend/src/models/User.js`

### Weather lookup

- [Weather routes](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/weatherRoutes.js): `AI-Weatherwise/Backend/src/routes/weatherRoutes.js`
- [Weather controller](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/weatherController.js): `AI-Weatherwise/Backend/src/controllers/weatherController.js`
- [Weather service](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/services/weatherService.js): `AI-Weatherwise/Backend/src/services/weatherService.js`
- **OpenWeatherMap**

### AI guidance

- [AI routes](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/aiRoutes.js): `AI-Weatherwise/Backend/src/routes/aiRoutes.js`
- [AI controller](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/aiController.js): `AI-Weatherwise/Backend/src/controllers/aiController.js`
- [AI service](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/services/aiService.js): `AI-Weatherwise/Backend/src/services/aiService.js`
- **Gemini API**

### Favorite locations

- [Favorite routes](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/routes/locationRoutes.js): `AI-Weatherwise/Backend/src/routes/locationRoutes.js`
- [Favorite controller](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/controllers/locationController.js): `AI-Weatherwise/Backend/src/controllers/locationController.js`
- [Location model](https://github.com/rithickkumar308/ai-weatherwise-/blob/main/AI-Weatherwise/Backend/src/models/Location.js): `AI-Weatherwise/Backend/src/models/Location.js`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests
- Server startup → Express app: starts (evidence: `AI-Weatherwise/Backend/src/server.js`)
- Server startup → DB connection: connects database (evidence: `AI-Weatherwise/Backend/src/server.js`)
- Express app → Auth routes: mounts (evidence: `AI-Weatherwise/Backend/src/app.js`)
- Express app → Weather routes: mounts (evidence: `AI-Weatherwise/Backend/src/app.js`)
- Express app → AI routes: mounts (evidence: `AI-Weatherwise/Backend/src/app.js`)
- Express app → Favorite routes: mounts (evidence: `AI-Weatherwise/Backend/src/app.js`)
- Auth routes → Account controller: dispatches (evidence: `AI-Weatherwise/Backend/src/routes/authRoutes.js`)
- Auth routes → Token protection: protects profile (evidence: `AI-Weatherwise/Backend/src/routes/authRoutes.js`)
- Account controller → User model: queries (evidence: `AI-Weatherwise/Backend/src/controllers/authController.js`)
- Token protection → User model: loads user (evidence: `AI-Weatherwise/Backend/src/middleware/authMiddleware.js`)
- Weather routes → Weather controller: dispatches (evidence: `AI-Weatherwise/Backend/src/routes/weatherRoutes.js`)
- Weather controller → Weather service: fetches weather (evidence: `AI-Weatherwise/Backend/src/controllers/weatherController.js`)
- Weather service → OpenWeatherMap: requests weather (evidence: `AI-Weatherwise/Backend/src/services/weatherService.js`)
- AI routes → AI controller: dispatches (evidence: `AI-Weatherwise/Backend/src/routes/aiRoutes.js`)
- AI routes → Token protection: protects endpoints (evidence: `AI-Weatherwise/Backend/src/routes/aiRoutes.js`)
- AI controller → AI service: generates guidance (evidence: `AI-Weatherwise/Backend/src/controllers/aiController.js`)
- AI service → Gemini API: generates content (evidence: `AI-Weatherwise/Backend/src/services/aiService.js`)
- Favorite routes → Favorite controller: dispatches (evidence: `AI-Weatherwise/Backend/src/routes/locationRoutes.js`)
- Favorite routes → Token protection: protects endpoints (evidence: `AI-Weatherwise/Backend/src/routes/locationRoutes.js`)
- Favorite controller → Location model: manages favorites (evidence: `AI-Weatherwise/Backend/src/controllers/locationController.js`)
