# ennded/smarttodo-ai architecture

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

- Interactive diagram: https://gitdiagram.com/ennded/smarttodo-ai
- Repository: https://github.com/ennded/smarttodo-ai

## Overview

##### Project type and purpose
- Full-stack web application (“SmartToDo-AI”)
- React-based single-page frontend that lets users register, log in, manage to-do items, and interact with AI features (chat, suggestions, weekly summary)
- Node.js/Express backend providing REST endpoints for authentication, to-do CRUD, and proxy to OpenAI
- Prisma ORM for relational DB persistence (e.g., PostgreSQL)

##### File structure
- Top-level:
- client/ — React app, organized by api, components, features (Redux slices), pages, tests, config, utils
- server/ — Express service, organized by routes, controllers, models, middleware, utils, Prisma schema, tests
- config files (vercel.json, .github/workflows) and package.json at root
- Patterns:
- Frontend uses Redux Toolkit (features folder), React Router (ProtectedRoute), Tailwind/CSS for styling
- Backend uses MVC-style controllers and middleware, JWT auth, OpenAI integration, input validation
- Shared client-server proxy (client/src/setupProxy.js)

##### README
- Minimal here; title implies AI-enhanced to-do list

##### Final recommendations
- Be explicit about middleware layers (auth, error handling) in the API
- Redux slices or feature modules to illustrate state management boundaries
- Proxy setup in development (client/src/setupProxy.js)
- Versioning or environment annotations if relevant (e.g., “/api/v1/…”)

## Diagram (Mermaid)

```mermaid
graph TB
  subgraph "User Layer"
    User["User Browser"]
  end

  subgraph "Frontend (React SPA)"
    direction TB
    Index["index.js"]:::frontend
    App["App.js"]:::frontend
    Store["Redux Store\n(store.js)"]:::frontend
    Protected["ProtectedRoute.jsx"]:::frontend
    APIClient["API Client\n(client.js)"]:::frontend
    Proxy["setupProxy.js"]:::frontend

    subgraph "AI Features"
      AIPage["AIPage.jsx"]:::frontend
      AISlice["aiSlice.js"]:::frontend
      AIChat["AIChat.jsx"]:::frontend
      AISugg["AISuggestions.jsx"]:::frontend
      AIWeek["AIWeeklySummary.jsx"]:::frontend
    end

    subgraph "Auth Features"
      Login["LoginPage.jsx"]:::frontend
      Register["RegisterPage.jsx"]:::frontend
      OAuthBtn["OAuthButton.jsx"]:::frontend
      AuthSlice["authSlice.js"]:::frontend
    end

    subgraph "To-Do Features"
      TodoPage["TodoPage.jsx"]:::frontend
      TodoSlice["todoSlice.js"]:::frontend
      TodoForm["TodoForm.jsx"]:::frontend
      TodoItem["TodoItem.jsx"]:::frontend
      TodoList["TodoList.test.jsx"]:::frontend
    end

    subgraph "Shared UI"
      Layout["Layout.jsx"]:::frontend
      Header["Header.jsx"]:::frontend
      Footer["Footer.jsx"]:::frontend
      Notify["NotificationBadge.jsx"]:::frontend
      Voice["VoiceInput.jsx"]:::frontend
    end
  end

  subgraph "Backend (Express API)"
    direction TB
    Server["server.js"]:::backend
    AppConf["app.js"]:::backend

    subgraph "Routes"
      AiRoute["aiRoutes.js"]:::backend
      AuthRoute["authRoutes.js"]:::backend
      TodoRoute["todoRoutes.js"]:::backend
    end

    subgraph "Controllers"
      AiCtrl["aiController.js"]:::backend
      AuthCtrl["authController.js"]:::backend
      TodoCtrl["todoController.js"]:::backend
    end

    subgraph "Middleware"
      AuthMw["authMiddleware.js"]:::backend
      ErrMw["errorMiddleware.js"]:::backend
      ValMw["todoValidation.js"]:::backend
    end

    subgraph "Models"
      UserModel["User.js"]:::backend
      TodoModel["Todo.js"]:::backend
    end

    PrismaSchema["schema.prisma"]:::backend

    subgraph "Config"
      OpenAIConf["openai.js"]:::backend
      JWTConf["passport.js"]:::backend
    end

    GenToken["generateToken.js"]:::backend
  end

  Database[(PostgreSQL via Prisma)]:::data

  CloudOpenAI([OpenAI API]):::external
  AuthProvider([Auth Provider]):::external

  %% Connections
  User -->|uses| App
  App -->|renders| Layout
  App --> Store
  Store --> AIPage
  Store --> Login
  App --> Protected
  Protected --> Login
  App --> TodoPage
  App --> APIClient
  APIClient --> Proxy
  APIClient -->|REST /auth,/todos,/ai| AppConf

  AppConf --> AiRoute
  AppConf --> AuthRoute
  AppConf --> TodoRoute
  AiRoute --> AiCtrl
  AuthRoute --> AuthCtrl
  TodoRoute --> TodoCtrl

  AiCtrl --> OpenAIConf
  AiCtrl -->|calls| CloudOpenAI
  AuthCtrl --> GenToken
  AuthCtrl -->|uses| JWTConf
  AuthCtrl --> AuthProvider
  TodoCtrl --> ValMw
  TodoCtrl --> UserModel
  TodoCtrl --> TodoModel

  AppConf --> AuthMw
  AppConf --> ErrMw

  UserModel -->|ORM| PrismaSchema
  TodoModel -->|ORM| PrismaSchema
  PrismaSchema --> Database

  %% Click Events
  click Index "https://github.com/ennded/smarttodo-ai/blob/main/client/src/index.js"
  click App "https://github.com/ennded/smarttodo-ai/blob/main/client/src/App.js"
  click Protected "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/ProtectedRoute.jsx"
  click Store "https://github.com/ennded/smarttodo-ai/blob/main/client/src/app/store.js"
  click APIClient "https://github.com/ennded/smarttodo-ai/blob/main/client/src/api/client.js"
  click Proxy "https://github.com/ennded/smarttodo-ai/blob/main/client/src/setupProxy.js"
  click AIChat "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/AIChat.jsx"
  click AISugg "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/AISuggestions.jsx"
  click AIWeek "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/AIWeeklySummary.jsx"
  click AISlice "https://github.com/ennded/smarttodo-ai/blob/main/client/src/features/ai/aiSlice.js"
  click AIPage "https://github.com/ennded/smarttodo-ai/blob/main/client/src/pages/AIPage.jsx"
  click Login "https://github.com/ennded/smarttodo-ai/blob/main/client/src/pages/LoginPage.jsx"
  click Register "https://github.com/ennded/smarttodo-ai/blob/main/client/src/pages/RegisterPage.jsx"
  click OAuthBtn "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/OAuthButton.jsx"
  click AuthSlice "https://github.com/ennded/smarttodo-ai/blob/main/client/src/features/auth/authSlice.js"
  click TodoSlice "https://github.com/ennded/smarttodo-ai/blob/main/client/src/features/todos/todoSlice.js"
  click TodoForm "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/TodoForm.jsx"
  click TodoItem "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/TodoItem.jsx"
  click TodoList "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/TodoList.test.jsx"
  click TodoPage "https://github.com/ennded/smarttodo-ai/blob/main/client/src/pages/TodoPage.jsx"
  click Layout "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/Layout.jsx"
  click Header "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/Header.jsx"
  click Footer "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/Footer.jsx"
  click Notify "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/NotificationBadge.jsx"
  click Voice "https://github.com/ennded/smarttodo-ai/blob/main/client/src/components/VoiceInput.jsx"
  click Server "https://github.com/ennded/smarttodo-ai/blob/main/server/server.js"
  click AppConf "https://github.com/ennded/smarttodo-ai/blob/main/server/app.js"
  click AiRoute "https://github.com/ennded/smarttodo-ai/blob/main/server/routes/aiRoutes.js"
  click AuthRoute "https://github.com/ennded/smarttodo-ai/blob/main/server/routes/authRoutes.js"
  click TodoRoute "https://github.com/ennded/smarttodo-ai/blob/main/server/routes/todoRoutes.js"
  click AiCtrl "https://github.com/ennded/smarttodo-ai/blob/main/server/controllers/aiController.js"
  click AuthCtrl "https://github.com/ennded/smarttodo-ai/blob/main/server/controllers/authController.js"
  click TodoCtrl "https://github.com/ennded/smarttodo-ai/blob/main/server/controllers/todoController.js"
  click AuthMw "https://github.com/ennded/smarttodo-ai/blob/main/server/middleware/authMiddleware.js"
  click ErrMw "https://github.com/ennded/smarttodo-ai/blob/main/server/middleware/errorMiddleware.js"
  click ValMw "https://github.com/ennded/smarttodo-ai/blob/main/server/middleware/todoValidation.js"
  click UserModel "https://github.com/ennded/smarttodo-ai/blob/main/server/models/User.js"
  click TodoModel "https://github.com/ennded/smarttodo-ai/blob/main/server/models/Todo.js"
  click PrismaSchema "https://github.com/ennded/smarttodo-ai/blob/main/server/prisma/schema.prisma"
  click OpenAIConf "https://github.com/ennded/smarttodo-ai/blob/main/server/config/openai.js"
  click JWTConf "https://github.com/ennded/smarttodo-ai/blob/main/server/config/passport.js"
  click GenToken "https://github.com/ennded/smarttodo-ai/blob/main/server/utils/generateToken.js"

  classDef frontend fill:#AED6F1,stroke:#2980B9,color:#1B2631
  classDef backend fill:#A9DFBF,stroke:#27AE60,color:#1B2631
  classDef data fill:#F9E79F,stroke:#F1C40F,color:#1B2631
  classDef external fill:#D2B4DE,stroke:#9B59B6,color:#1B2631
```
