How ankush-web-eng/personal_website works
Main Components
• Client (Browser/User Interface): Represents how visitors interact with the website.
• Next.js Application Server:
• UI/Pages: All the rendered pages under the “app” directory (for example, landing pages for about, freelance, kaizen, messages, add pages).
• Components: The reusable UI elements in the “components” folder (headers, footers, navigation, cards, skeletons, etc.).
• Layout and Providers: Global layout files (app/layout.tsx, app/provider.tsx) and context providers (for sessions and themes).
• API Layer: Located in “app/api” with endpoints organized by resource (applications, blogs, freelance, ghost, messages, projects, skill, testimonial, and users). These endpoints handle CRUD operations and authentication (using NextAuth in the “auth” subfolder).
• Database & ORM: The “prisma” folder with the Prisma schema and migrations indicates a database layer (the data store for blogs, projects, testimonials, etc.) accessed via utilities in “lib/db.ts” and through models under “models”.
• External & Third-Party Services:
• Firebase Config: Found in the “config/firebase.ts” file may be used for notifications, storage, or other external service interactions.
• NextAuth: For authentication, integrated with the API endpoints in “api/auth/[...nextauth]”.
Relationships & Data Flow
• The Browser sends requests (either page navigation or API calls) to the Next.js server.
• The UI layer (pages and components) consumes data from the API endpoints.
• API endpoints (RESTful or Next.js route handlers) process incoming requests, perform database operations via Prisma, and then send responses back.
• The authentication flows (managed in “api/auth”) are used by the session provider under “context/SessionProvider.tsx” to secure pages and API endpoints.
• Shared utilities (in “lib” and “context”) assist with state management, theming, and database connections.
Architectural Patterns & Design Principles
• Separation of Concerns: The code is separated into UI (components, pages), API (server logic, CRUD operations), and data access (Prisma schema and models).
• Modular Design: Resources like “blogs”, “projects”, and “messages” are isolated in both their UI and API representations, supporting easier maintenance and potential refactoring.
• Dynamic Routing: The “app/(routes)” and “app/add” directories feature dynamic routes (using [id]) to handle variable content, which is a typical pattern in Next.js applications.
• Consistent Naming & Structure: The API routes mirror the structure of the UI routes, making the design more intuitive.