How prabincankod/sunal-rahal works
Project Type and Main Purpose
• The project is a full-stack Next.js application with both client-side and server-side components.
• Its primary function is to allow users to connect their Spotify account, fetch the currently playing track, and display that information in a visually engaging format.
Key Components
a. Frontend (User Interface):
• Next.js pages (found in src/pages) that render the UI, including pages like index.tsx and profile.tsx.
• Reusable UI components (src/components and src/components/ui) such as Navbar, Footer, Layout, Avatar, Button, Card, etc.
• Client-side state management and styling (Tailwind CSS configurations in tailwind.config.js/ts and src/styles).
b. API Layer / Server-side Logic:
• Server directories such as src/pages/api and src/server that house the API endpoints.
• Business Logic & Routers: Represent the TRPC routers (e.g., src/server/api/routers/example.ts) and core “root” API endpoint (src/server/api/root.ts).
c. Database and Persistence:
• Prisma integration using the prisma/schema.prisma file.
• Connection from server-side code (src/server/db.ts) to the database, and mention any ORM-related components.
d. Authentication and External Integration:
• Authentication handler (e.g., src/pages/api/auth/[...nextauth].ts and src/server/auth.ts).
e. Utility and Helper Services:
• Utility modules (src/lib/utils.ts, src/server/utils/*, and src/utils/api.ts) that perform reusable tasks such as generating access tokens or handling data URIs.
• These can be boxed as helper functions that support major flows like API calls or processing third-party responses.
Relationships and Data Flow
• From the Browser/User interface to the Next.js pages and UI components.
• From UI components to backend API endpoints (for login, fetch track info, etc.).
• From API endpoints to the database (via Prisma) and to external services (Spotify API).
• Data exchanges among TRPC endpoints and the custom routers.
• Flow of authentication data from the UI to the authentication endpoints and then onto Spotify, ensuring users’ session data is managed appropriately.
Architectural Patterns and Technologies
• That the application leverages Next.js for server-side rendering and API routes.
• Use of TRPC for type-safe API procedures, ensuring consistent data contracts between client and server.
• Usage of Prisma as the ORM for database interactions.
• Mention the integration with Spotify’s API, which is central to the project’s music experience feature.
• That UI styling and theming is done with Tailwind CSS.