How subh05sus/codenearby works
Project type and purpose (API-focused view)
• CodeNearby is a full-stack Next.js application. For “API part only,” we focus on the backend/serverless‐functions layer under the app/api and app/api/v1 directories.
• These directories define all REST endpoints and versioned APIs. They connect client requests to data stores, caches, authentication, and external services (GitHub, AI, Firebase, Cloudinary, Razorpay, Redis).
File structure for the API layer
• Top-level API directories:
• app/api/* – core endpoints (authentication, user/profile, posts, gatherings, chat, search, share, upload, etc.).
• app/api/v1/* – versioned endpoints for programmatic clients (API-key auth, billing, pricing, repos, user-tokens, user-tier, etc.).
• Support libraries under lib/ provide connections to:
• MongoDB (lib/mongodb.ts)
• Redis (lib/redis.ts)
• Firebase (lib/firebase.ts)
• Cloudinary (lib/razorpay.ts)
• GitHub/Ai (lib/github-search.ts, lib/ai.ts)
• Authentication layer under app/api/auth/[...nextauth] using NextAuth.js.
README insights on APIs
• Features mention AI-Connect (/api/ai-chat), GitHub-integration endpoints, Redis caching, billing webhooks (/api/v1/billing).
• Auth flows: NextAuth.js (GitHub provider) at /api/auth and API key auth under /api/v1/auth/api-key.
Elements
• Clear labels: “API Routes”, “Auth (NextAuth)”, “DB (MongoDB)”, “Cache (Redis)”, etc.
• Blue for internal components (Next.js, Auth layer)
• Green for data stores (MongoDB, Redis)
• Orange for external services (GitHub, AI, Firebase, Cloudinary, Razorpay)