How eao2/ne-to works
Main Components
• Frontend (Nuxt Application):
– This includes all pages (in the “pages” directory), layouts (in “layouts”), components (in “components”), and assets (in “assets”), which collectively render the user interface.
– The Nuxt configuration (nuxt.config.ts) sets up the overall app environment.
• Backend API:
– Located within the “server/api” folder, this part provides various endpoints (e.g., cargoTrackData.js, login.js, register.js, etc.).
– Also include “server/middleware” which is used for request handling (like authentication).
• Database Layer:
– The “prisma” directory holds the Prisma schema (schema.prisma) and migrations that manage the database schema. This indicates the app is using Prisma as its ORM, so the API layer will interact with the database using Prisma.
• Static Assets & Public Files:
– The “public” directory serves static files like cargo address configurations and robots.txt.
Relationships and Interactions
• The Browser/Client (or web user) requests pages that are rendered by the Nuxt frontend.
• The Nuxt frontend communicates with the backend API endpoints to fetch or update data (e.g., user authentication, cargo tracking data).
• The backend API, in turn, uses Prisma to interact with a database (or databases) to store and retrieve application data.
• Middleware components in the server (like auth.js) enforce security by checking authentication for protected API routes.
• External services (such as email services for “forgot-password” or “reset-password”) might be indirectly invoked via specialized API endpoints.
Architectural Patterns and Design Principles
• Decoupled Frontend and Backend: Even though the front and backend may be served from the same repository via Nuxt, they are architecturally distinct. The frontend components focus on the presentation, while the backend APIs encapsulate business logic and data persistence.
• MVC (loosely): The “pages”, “layouts”, and “components” folders serve as the ‘View’ layer, and the backend “server/api” acts as the controller or service layer.
• ORM-Driven Data Management: Prisma is used to manage and migrate the database, ensuring that the database layer is well-integrated with the business logic of the API.
• Modular API Design: Each API endpoint is separated into its own file, simplifying maintenance and scalability.