How anze10/senzemo-app works
Project type and purpose
• This is a full-stack Next.js application (App Router) with a React/TypeScript frontend and a Node.js server runtime.
• It uses Prisma as an ORM to interact with a relational database, Lucia for session-based authentication, and Google OAuth for SSO.
• The feature set includes an admin editing console, inventory management, order management, sales dashboards, sensor reading utilities, and developer utilities—all delivered from the same monolithic repo.
File structure
• Top-level framework/config: next.config.ts, tsconfig.json, bun.lockb, tailwind.config.ts, eslint.config.mjs, postcss.config.mjs.
• prisma/schema.prisma: ORM schema definition for production database.
• src/app: the App Router directory. Each subfolder under src/app (e.g., adminedit, inventory, orders, sales, sensors, dev, login/google…) is a separate route segment with its own React page.tsx and child components.
• src/lib, src/providers.tsx: shared utilities, context providers, base URL resolution.
• src/server: server-only modules (Google OAuth flows, Lucia session management, Prisma client instantiation, helper functions).
• src/validators: input or token validation logic.
• public: static assets.
README for additional insights
• Bootstrapped by Create-Next-App, deployed on Vercel.
• Uses next/font for optimized font loading.
• Standard npm scripts: dev, build, start.
Main components and their relationships
a. Frontend (Browser/Client)
• React components under src/app/* rendered via Next.js.
• Layouts (layout.tsx) supply shared navigation, styling via Tailwind.
• Client-side interactivity: hooks, sensors logic, button handlers, fetch calls to server actions.
b. Next.js Server (Node.js Runtime)
• Renders pages server-side and serves client bundles.
• Exposes server actions (src/server/actions.ts) and API routes (src/app/login/google/route.ts, callback routes).
• Middleware (src/server/middleware.ts) applies authentication guard.
c. Authentication & Session
• Google OAuth endpoints → obtains tokens → persisted via Lucia (src/server/lucia.ts, session.ts).
• validate_session.ts enforces access controls on protected pages.
d. Database (Prisma-backed)
• Prisma Client (src/server/prisma.ts) connects to underlying Postgres/MySQL/SQLite defined in schema.prisma.
• CRUD operations triggered by server actions or direct API handlers.
e. External Services
• Google OAuth 2.0 for sign-in.
• Potential file storage or printer server integrations under src/app/dev/components/printer.
Architectural patterns and design principles
• Full-stack monolithic architecture using Next.js App Router.
• Separation of concerns:
• UI layers under src/app.
• Business logic and auth flows under src/server.
• Data access layer via Prisma.
• Server actions for secure server-side mutations.
• Middleware for cross-cutting concerns (session validation).
• Route segment conventions for domain features (inventory, orders, sales, sensors).
• Client/browser
• Next.js Server (SSR + API Routes + Server Actions)
• Authentication subsystem (Google OAuth, Lucia)
• Database (Prisma ORM layer)
• External services (Google, printer service)
b. Interactions/data flow
• Next.js Server → Prisma Client → Database → returns data
• Next.js Server → OAuth endpoints → Google → returns user tokens
• Next.js Server → Lucia → session store
• Browser ← SSR HTML or JSON payloads
c. Technologies/Frameworks
• React/Next.js on Node.js
• TypeScript, Tailwind CSS
• Prisma ORM + relational DB
• Lucia for sessions
• Google OAuth
• Vercel (deployment)
d. Architectural patterns
• Monolithic modular feature routing
• App Router with nested layouts
• Server-side rendering and server actions
• Middleware pipeline for auth
Detail
• How global providers (src/providers.tsx) and global CSS (globals.css) fit into page layouts.
• Middleware ordering: auth middleware runs before serving protected routes.