# abhay-gits/taskmates architecture

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

- Interactive diagram: https://gitdiagram.com/abhay-gits/taskmates
- Repository: https://github.com/abhay-gits/taskmates

## Overview

##### Project Type and Purpose
- TaskMates is a full-stack task management application with three clients:
- Web frontend (React + TypeScript + Vite + Tailwind)
- Mobile client (React Native / Expo‐style folder layout)
- Backend API (Node.js + Express + MongoDB + JWT)
- Purpose: allow users to sign up/log in, manage tasks, add friends, and view friends’ tasks in real time.

##### File Structure
- Top-level directories
- backend/ → Express app (controllers, routes, models, middleware)
- frontend/ → React web app (components, pages, context)
- mobile/ → React Native mobile app (app/, assets/, store/)
- Config files
- backend/*.env (MONGODB_URI, JWT_SECRET)
- frontend/vite.config.ts, tsconfig.json, tailwind via CSS imports
- mobile/tsconfig.json, app.json
- Architectural patterns
- Backend: MVC-style (routes → controllers → models → db)
- Frontend: Component + context (AuthContext) with React Router
- Mobile: Screen-based routing in app/(auth) & app/(tabs)

##### README for Additional Insights
- Tech stack summary
- Web: React, TypeScript, Tailwind, Vite, React Router DOM, Axios
- API: Node.js, Express, Mongoose, JWT, CORS
- DB: MongoDB
- Features hint at real-time updates (may be implemented via polling or WebSockets)

##### Main Components & Relationships
a. Clients
– Web Browser (React app)
– Mobile App (React Native)
b. API Layer
– Express Server
– authRoutes, taskRoutes, friendRoutes, userRoutes
– authMiddleware (JWT verification)
c. Business Logic
– Controllers (authController, taskController, friendController)
– Models (User, Task) via Mongoose
d. Data Layer
– MongoDB database (collections: users, tasks)
e. External Services
– JWT service (sign/verify tokens)
– Potential real-time service (e.g., Socket.io or Firebase, if used)

##### Architectural Patterns & Design Principles
- Layered architecture (Presentation → API → Business Logic → Data)
- Stateless REST API with token-based auth
- Separation of concerns:
- Frontend UI vs. Backend API vs. Data storage
- Auth handled by middleware before business logic
- Scalability: each layer can be containerized and scaled independently

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Web Client
    subgraph "Web Client" 
        direction TB
        WC1["main.tsx"]:::frontend
        WC2["App.tsx"]:::frontend
        WC3["routes.tsx"]:::frontend
        WC4["AuthContext.tsx"]:::frontend
        subgraph "UI Components"
            direction TB
            WC5["Navbar.tsx"]:::frontend
            WC6["ProtectedRoute.tsx"]:::frontend
            WC7["FriendsTasks.tsx"]:::frontend
            WC8["MyFriends.tsx"]:::frontend
            WC9["Loading.tsx"]:::frontend
        end
        WC1 --> WC2
        WC2 --> WC3
        WC2 --> WC4
        WC3 --> WC5
        WC3 --> WC6
        WC3 --> WC7
        WC3 --> WC8
        WC3 --> WC9
    end

    %% Mobile Client
    subgraph "Mobile Client"
        direction TB
        MC1["app.json"]:::mobile
        MC2["tsconfig.json"]:::mobile
        subgraph "Auth Screens"
            direction TB
            MC3["_layout.jsx"]:::mobile
            MC4["index.jsx"]:::mobile
            MC5["signup.jsx"]:::mobile
        end
        subgraph "Tabs Screens"
            direction TB
            MC6["_layout.jsx"]:::mobile
            MC7["index.jsx"]:::mobile
            MC8["friends.jsx"]:::mobile
            MC9["profile.jsx"]:::mobile
        end
        MC10["_layout.jsx"]:::mobile
        MC11["authStore.js"]:::mobile
        MC12["colors.jsx"]:::mobile
        MC1 --> MC10
        MC10 --> MC3
        MC3 --> MC4
        MC4 --> MC5
        MC10 --> MC6
        MC6 --> MC7
        MC6 --> MC8
        MC6 --> MC9
        MC10 --> MC11
        MC10 --> MC12
    end

    %% Backend API
    subgraph "Backend API"
        direction TB
        BE1["index.js"]:::backend
        BE2["db/db.js"]:::backend
        BE12["auth.middleware.js"]:::backend
        subgraph "Routes"
            direction TB
            BE3["authRoutes.js"]:::backend
            BE4["taskRoutes.js"]:::backend
            BE5["friendRoutes.js"]:::backend
            BE6["userRoutes.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            BE7["authController.js"]:::backend
            BE8["taskController.js"]:::backend
            BE9["friendController.js"]:::backend
        end
        subgraph "Models"
            direction TB
            BE10["User.js"]:::backend
            BE11["Task.js"]:::backend
        end
        BE1 --> BE2
        BE1 --> BE3
        BE1 --> BE4
        BE1 --> BE5
        BE1 --> BE6
        BE3 --> BE7
        BE4 --> BE8
        BE5 --> BE9
        BE3 --> BE12
        BE4 --> BE12
        BE5 --> BE12
        BE7 --> BE10
        BE8 --> BE11
    end

    %% Database
    MongoDB["MongoDB\n(collections: users, tasks)"]:::db

    %% External Services
    JWT["JWT Service"]:::external

    %% Connections
    WC2 -->|REST JSON| BE1
    MC10 -->|REST JSON| BE1
    BE2 -->|TCP/27017| MongoDB
    BE7 -->|"uses"| JWT
    BE12 -->|"verifies"| JWT
    MongoDB -->|stores data| BE2

    %% Click Events - Web
    click WC1 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/main.tsx"
    click WC2 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/App.tsx"
    click WC3 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/routes.tsx"
    click WC4 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/context/AuthContext.tsx"
    click WC5 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/components/Navbar.tsx"
    click WC6 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/components/ProtectedRoute.tsx"
    click WC7 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/components/FriendsTasks.tsx"
    click WC8 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/components/MyFriends.tsx"
    click WC9 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/components/Loading.tsx"
    click WC1 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/main.tsx"
    click WC2 "https://github.com/abhay-gits/taskmates/blob/master/frontend/src/App.tsx"

    %% Click Events - Mobile
    click MC1 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app.json"
    click MC2 "https://github.com/abhay-gits/taskmates/blob/master/mobile/tsconfig.json"
    click MC3 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(auth)/_layout.jsx"
    click MC4 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(auth)/index.jsx"
    click MC5 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(auth)/signup.jsx"
    click MC6 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(tabs)/_layout.jsx"
    click MC7 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(tabs)/index.jsx"
    click MC8 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(tabs)/friends.jsx"
    click MC9 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/(tabs)/profile.jsx"
    click MC10 "https://github.com/abhay-gits/taskmates/blob/master/mobile/app/_layout.jsx"
    click MC11 "https://github.com/abhay-gits/taskmates/blob/master/mobile/store/authStore.js"
    click MC12 "https://github.com/abhay-gits/taskmates/blob/master/mobile/constants/colors.jsx"

    %% Click Events - Backend
    click BE1 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/index.js"
    click BE2 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/db/db.js"
    click BE3 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/routes/authRoutes.js"
    click BE4 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/routes/taskRoutes.js"
    click BE5 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/routes/friendRoutes.js"
    click BE6 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/routes/userRoutes.js"
    click BE7 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/controllers/authController.js"
    click BE8 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/controllers/taskController.js"
    click BE9 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/controllers/friendController.js"
    click BE10 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/models/User.js"
    click BE11 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/models/Task.js"
    click BE12 "https://github.com/abhay-gits/taskmates/blob/master/backend/src/middleware/auth.middleware.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef mobile fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#000,stroke-width:1px
    classDef db fill:#ffe5cc,stroke:#000,stroke-width:1px
    classDef external fill:#f0f0f0,stroke:#000,stroke-width:1px
```
