How mo-renike/data-visualization-dashboard works
Project Type and Purpose
• This is a full-stack web application (“XYZ Shop”) for visualizing sales data with interactive charts, user authentication (admin/customer), order management, and time-based analytics.
• Frontend: React + TypeScript + Tailwind + Chart.js
• Backend: Node.js + Express + TypeScript + Prisma ORM + PostgreSQL + JWT
File Structure Analysis
• Top-level “client” and “server” directories separate the two major parts.
• client/src organizes UI components, pages, contexts, hooks, services, constants, validation, and assets—typical React feature-folder structure.
• server/src contains controllers (business logic), routes (REST API endpoints), middleware (JWT auth), utils (data population, filtering), and the Prisma schema under prisma/.
• Configuration files: vite.config.js (frontend build), tsconfig.json, package.json, .gitignore files, Prisma migrations.
Key Architectural Insights from README
• RESTful API with endpoints for auth (/api/auth), orders (/api/orders), and stats (/api/stats).
• Role-based access control enforced via JWT middleware.
• Prisma as Data Access Layer mapping to PostgreSQL.
• Frontend calls backend over Axios to fetch or mutate data.
Main Components
a. Presentation Layer (Client)
– Browser / React App
– UI Modules: Auth pages, Dashboard charts, Order management pages
– State & Context (AuthContext)
– API Service (Axios wrappers)
b. API Layer (Server)
– Express HTTP Server
– Route Handlers: auth, orders, stats
– Middleware: JWT authentication, error handlers
– Controllers: chartController, orderController, statsController
c. Business & Data Layer
– Prisma ORM (client-generated library)
– PostgreSQL Database
– Data Seeder script (populateOrders.ts)
d. External Services
– JWT provider (secret key)
– Possibly Vercel / Render for hosting
Relationships and Data Flow
• User interacts with the React UI → UI dispatches Axios HTTP requests → Express routes receive requests
• Auth middleware validates JWT → Controllers execute business logic → Prisma client executes SQL against PostgreSQL → Results flow back through controllers → Response to Axios → UI updates charts or tables
• Data-seeding utility populates the database on setup
Architectural Patterns & Principles
• Layered Architecture: Presentation → API Layer → Business Logic → Data Access
• MVC-style separation in the backend (Routes → Controllers → ORM)
• Feature-based grouping on the frontend
• Single responsibility: each controller, middleware, and React component has a focused role
• Blue for frontend components
• Green for backend/API layers
• Orange for database
• Gray for external services
• Protocols (HTTP/REST, JWT tokens, SQL).