# sujanraghav05/codealpha_tasks architecture

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

- Interactive diagram: https://gitdiagram.com/sujanraghav05/codealpha_tasks
- Repository: https://github.com/sujanraghav05/codealpha_tasks

## Overview

#### Repository Scope
This repository contains two independent full-stack applications:
- An e-commerce system under `CodeAlpha_E-commerce/eco_comm_fullstack`.
- A social-media platform (“Truth Talks”) under `CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql`.

They have separate frontend/backend runtimes, data models, and deployment boundaries.

#### E-commerce Application
The e-commerce backend is a Node.js service entered through `CodeAlpha_E-commerce/eco_comm_fullstack/backend/src/server.js`. It exposes route groups for authentication, products, orders, and administration:
- `backend/src/routes/auth.js`
- `backend/src/routes/products.js`
- `backend/src/routes/orders.js`
- `backend/src/routes/admin.js`

Routes delegate to domain controllers, which form the HTTP-to-business-logic boundary: `backend/src/controllers/authController.js`, `backend/src/controllers/productController.js`, and `backend/src/controllers/orderController.js`.

#### E-commerce Identity, Data, and Security
Persistent domain entities are separated into model files for users, products, orders, and OTP tokens:
- `backend/src/models/User.js`
- `backend/src/models/Product.js`
- `backend/src/models/Order.js`

Database initialization and token configuration are centralized at `backend/src/config/db.js` and `backend/src/config/jwt.js`. Authentication middleware protects restricted endpoints, while shared error handling is isolated from controller logic:
- `backend/src/middleware/auth.js`
- `backend/src/middleware/errorHandler.js`

A SQL schema exists at `CodeAlpha_E-commerce/eco_comm_fullstack/sql/schema.sql`, representing a material database boundary for this application.

#### E-commerce Client Boundary
The e-commerce UI is a static HTML/CSS/JavaScript client rather than a component-based SPA. Its storefront, cart, account, and administration surfaces are individual pages under `frontend/pages`, including:
- `frontend/pages/products.html`
- `frontend/pages/cart.html`
- `frontend/pages/admin.html`

Shared browser-side behavior is concentrated in `frontend/js/utils.js`, with global styling in `frontend/css/style.css`. The client is expected to call the backend HTTP API; no server-rendering entry point is present in the tree.

#### Truth Talks Client
Truth Talks is a React client entered through `CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/client/src/index.js`, with top-level composition/routing in `client/src/App.jsx`. It separates authenticated and application layouts:
- `client/src/components/layout/AuthLayout.jsx`
- `client/src/components/layout/AppLayout.jsx`

Feature pages cover feed, profiles, post creation, stories, reels, channels, and chat. Core client data boundaries are the HTTP API wrapper and stateful authentication/socket contexts:
- `client/src/utils/api.js`
- `client/src/context/authStore.js`
- `client/src/context/SocketContext.jsx`

#### Truth Talks Server, Realtime, and Media
The Node.js server entry point is `CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/server/index.js`. REST routes partition core social functions—authentication, users, posts, stories, reels, channels, chat, discovery, and upload—such as:
- `server/routes/auth.js`
- `server/routes/posts.js`
- `server/routes/chat.js`

The server applies auth middleware (`server/middleware/auth.js`), accesses relational data through `server/config/db.js` and `server/models/index.js`, and includes a SQLite database at `server/data/truth_talks.sqlite`. Schema evolution is initiated by `server/migrations/run.js`.

Realtime communication is a distinct Socket.IO-style boundary implemented in `server/socket/socketHandler.js`, consumed by the client socket context. Media upload/storage is split between local upload directories and Cloudinary configuration:
- `server/routes/upload.js`
- `server/config/cloudinary.js`
- `server/uploads/`

Thus, Truth Talks’ primary flow is React UI → HTTP API or socket connection → authenticated route/socket handlers → SQLite models, with uploaded media handled through local storage and configured cloud-media integration.

Main entry points: [`CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/client/src/index.js`](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/client/src/index.js) (React client), [`CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/server/index.js`](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/server/index.js) (Social API server), [`CodeAlpha_E-commerce/eco_comm_fullstack/frontend/js/utils.js`](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/frontend/js/utils.js) (Browser utilities), [`CodeAlpha_E-commerce/eco_comm_fullstack/backend/src/server.js`](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/backend/src/server.js) (Commerce API server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ecommerce["E-commerce"]
  node_eco_ui["Static storefront pages<br/>browser UI<br/>[products.html]"]
  node_eco_browser_shared["Browser utilities<br/>client logic<br/>[utils.js]"]
  node_eco_server{{"Commerce API server<br/>Node.js entry<br/>[server.js]"}}
  node_eco_routes["API route groups<br/>Express routes"]
  node_eco_auth["Auth middleware"]
  node_eco_controllers["Commerce controllers<br/>domain controllers"]
  node_eco_models["Commerce models<br/>data models"]
  node_eco_db_config["Database configuration"]
  node_eco_schema[("Commerce SQL schema<br/>SQL database<br/>[schema.sql]")]
end

subgraph group_truth["Truth Talks"]
  node_truth_react{{"React client<br/>React entry<br/>[index.js]"}}
  node_truth_layouts["Auth and app layouts<br/>React layouts"]
  node_truth_client_api["HTTP API wrapper<br/>client API"]
  node_truth_client_state["Auth and socket contexts<br/>client state"]
  node_truth_server{{"Social API server<br/>Node.js entry<br/>[index.js]"}}
  node_truth_routes["Social REST routes<br/>Express routes"]
  node_truth_auth["Auth middleware"]
  node_truth_socket["Socket handlers<br/>realtime gateway"]
  node_truth_models["Relational models<br/>data models"]
  node_truth_db[("Truth Talks SQLite<br/>SQLite database")]
  node_truth_migrations["Schema migrations<br/>migration runner"]
  node_truth_upload["Media upload route<br/>upload API"]
  node_truth_cloudinary["Cloudinary integration<br/>media configuration"]
  node_truth_uploads[("Local media storage<br/>upload storage")]
end

node_eco_ui -->|"uses"| node_eco_browser_shared
node_eco_browser_shared -->|"HTTP API"| node_eco_server
node_eco_server -->|"mounts"| node_eco_routes
node_eco_routes -->|"protects routes"| node_eco_auth
node_eco_routes -->|"delegates"| node_eco_controllers
node_eco_controllers -->|"uses"| node_eco_models
node_eco_models -->|"connects through"| node_eco_db_config
node_eco_db_config -->|"persists to"| node_eco_schema
node_truth_react -->|"renders"| node_truth_layouts
node_truth_react -->|"uses"| node_truth_client_api
node_truth_react -->|"provides"| node_truth_client_state
node_truth_client_api -->|"HTTP API"| node_truth_server
node_truth_client_state -->|"socket connection"| node_truth_socket
node_truth_server -->|"mounts"| node_truth_routes
node_truth_server -->|"initializes"| node_truth_socket
node_truth_routes -->|"protects routes"| node_truth_auth
node_truth_routes -->|"uses"| node_truth_models
node_truth_socket -->|"uses"| node_truth_models
node_truth_models -->|"persists to"| node_truth_db
node_truth_migrations -->|"evolves schema"| node_truth_db
node_truth_routes -->|"mounts"| node_truth_upload
node_truth_upload -->|"stores locally"| node_truth_uploads
node_truth_upload -->|"uses configuration"| node_truth_cloudinary

click node_eco_ui "https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/frontend/pages/products.html"
click node_eco_browser_shared "https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/frontend/js/utils.js"
click node_eco_server "https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/backend/src/server.js"
click node_eco_schema "https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/sql/schema.sql"
click node_truth_react "https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/client/src/index.js"
click node_truth_server "https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/server/index.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_eco_ui,node_eco_browser_shared,node_eco_server,node_eco_routes,node_eco_auth,node_eco_controllers,node_eco_models,node_eco_db_config,node_eco_schema toneBlue
class node_truth_react,node_truth_layouts,node_truth_client_api,node_truth_client_state,node_truth_server,node_truth_routes,node_truth_auth,node_truth_socket,node_truth_models,node_truth_db,node_truth_migrations,node_truth_upload,node_truth_cloudinary,node_truth_uploads toneAmber
```

## Components

### E-commerce

Independent static-client and Node.js commerce application.

- [Static storefront pages](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/frontend/pages/products.html): browser UI · Products, cart, account, and administration pages. · `CodeAlpha_E-commerce/eco_comm_fullstack/frontend/pages/products.html`
- [Browser utilities](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/frontend/js/utils.js): client logic · Shared client behavior and styling. · `CodeAlpha_E-commerce/eco_comm_fullstack/frontend/js/utils.js`
- [Commerce API server](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/backend/src/server.js): Node.js entry · `CodeAlpha_E-commerce/eco_comm_fullstack/backend/src/server.js`
- **API route groups**: Express routes · Authentication, products, orders, and admin endpoints.
- **Auth middleware**: middleware · Protects restricted API endpoints.
- **Commerce controllers**: domain controllers · HTTP-to-business-logic boundary for auth, products, and orders.
- **Commerce models**: data models · Users, products, orders, and OTP tokens.
- **Database configuration**: database config
- [Commerce SQL schema](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_E-commerce/eco_comm_fullstack/sql/schema.sql): SQL database · `CodeAlpha_E-commerce/eco_comm_fullstack/sql/schema.sql`

### Truth Talks

Independent React, Node.js, SQLite, and realtime application.

- [React client](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/client/src/index.js): React entry · Client bootstrap and top-level application composition. · `CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/client/src/index.js`
- **Auth and app layouts**: React layouts · Separates unauthenticated and application experiences.
- **HTTP API wrapper**: client API
- **Auth and socket contexts**: client state · Maintains authentication and realtime connection state.
- [Social API server](https://github.com/sujanraghav05/codealpha_tasks/blob/main/CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/server/index.js): Node.js entry · `CodeAlpha_Social_Media/truth-talks-v2-sql/truth-talks-sql/server/index.js`
- **Social REST routes**: Express routes · Auth, social content, chat, discovery, and upload endpoints.
- **Auth middleware**: middleware
- **Socket handlers**: realtime gateway · Socket.IO-style realtime communication boundary.
- **Relational models**: data models
- **Truth Talks SQLite**: SQLite database · Relational persistent data store.
- **Schema migrations**: migration runner
- **Media upload route**: upload API · Accepts media uploads for local and cloud-backed handling.
- **Cloudinary integration**: media configuration
- **Local media storage**: upload storage

## Connections

- Static storefront pages → Browser utilities: uses
- Browser utilities → Commerce API server: HTTP API
- Commerce API server → API route groups: mounts
- API route groups → Auth middleware: protects routes
- API route groups → Commerce controllers: delegates
- Commerce controllers → Commerce models: uses
- Commerce models → Database configuration: connects through
- Database configuration → Commerce SQL schema: persists to
- React client → Auth and app layouts: renders
- React client → HTTP API wrapper: uses
- React client → Auth and socket contexts: provides
- HTTP API wrapper → Social API server: HTTP API
- Auth and socket contexts → Socket handlers: socket connection
- Social API server → Social REST routes: mounts
- Social API server → Socket handlers: initializes
- Social REST routes → Auth middleware: protects routes
- Social REST routes → Relational models: uses
- Socket handlers → Relational models: uses
- Relational models → Truth Talks SQLite: persists to
- Schema migrations → Truth Talks SQLite: evolves schema
- Social REST routes → Media upload route: mounts
- Media upload route → Local media storage: stores locally
- Media upload route → Cloudinary integration: uses configuration
