How praveenreddy4512/sdp works
• Frontend/UI: Represented by the Next.js “pages” in the src/app directory. This includes several distinct sections such as:
– Admin Dashboard (under src/app/admin): managing buses, machines, reports, routes, trips, and vendors.
– Authentication pages (src/app/auth) for login and registration.
– Self-service and vendor POS interfaces (src/app/self-pos and src/app/vendor-pos) for customer interactions.
– Public booking and dashboard pages.
• API Backend: Next.js API routes (under src/app/api) are divided into multiple endpoints. For example:
– Authentication endpoints (src/app/api/auth) for user sessions and registration.
– Domain-specific endpoints for buses, machines, seats, tickets (including cancellation), routes, and trips.
– Reporting endpoints (e.g., sales reports under src/app/api/reports/sales).
• Database: The PostgreSQL database is managed via Prisma. Illustrate the Prisma folder where migrations, schema definitions, and seeds exist.
• Authentication Service: NextAuth.js integration is configured in the API (see the [...nextauth] routes) and further supported by frontend components.
• Utility/Shared Libraries: The src/lib folder, containing helper modules for authentication, database connection, Prisma setup, and scripts for resetting the DB.
• Deployment & Configuration: Include configuration files like next.config.ts, vercel.json, and the deployment README steps that manage environment variables and migration commands.
• API routes act as intermediaries that process requests, interact with business logic, and then communicate with the PostgreSQL database by leveraging Prisma.
• Authentication flows are managed by NextAuth.js: illustrate how the frontend sends credentials that are handled by API endpoints, which in turn interact with the authentication service.
• How the Admin dashboard, Self-Service, and Vendor POS modules each connect to the underlying API for bus and ticket data.
• How the Prisma migrations and seeding scripts ensure that the database schema stays in sync, which is essential during both local development (prisma migrate dev) and production deployment (prisma migrate deploy).
Architectural Patterns and Design Principles
• Separation of Concerns: Clearly demarcate the UI layer, API/business logic layer, and database layer.
• Modular Organization: Each major domain (buses, machines, trips, reports, routes, tickets, vendors) has its own module both at the API and the UI level.
• Extensibility: With separate modules for admin, self-service, and vendor interfaces, it is easier to extend functionalities without interfering with other parts.
• Use of modern, serverless deployment practices (Vercel) so highlight the stateless aspects of API endpoints and the state managed in the database.