How durgaprasad118/blogging_app works
Main Components
• Frontend (Client):
• Contains a “client” folder with assets, pages, components, hooks, and store modules.
• Uses React with TypeScript and TailwindCSS.
• Key areas include layout and routing (client/src/Layout), page-level components for features like BlogList, BlogPage, Login, Signup, etc.
• Uses libraries such as react-simple-wysiwyg for the editor, recoil for state management, and other utilities.
• Backend (Server):
• Located in the “server” folder and structured into modules such as controllers, routes, middleware (for authentication), and utils.
• Uses Hono as a lightweight framework along with Prisma, which is used to handle database migrations and ORM for PostgreSQL.
• Controllers are divided by domain (blogs and users) and handle operations like creating, reading, updating, and deleting blog posts, as well as user authentication actions.
• Includes configuration and migration files under “server/prisma” for managing the PostgreSQL schema.
• Database:
• A PostgreSQL database managed via Prisma, with migrations stored in the prisma/migrations directories.
• External Services:
• The README mentions Cloudinary for handling image uploads.
Relationships and Interactions
• The Frontend communicates with the Backend via RESTful API calls over HTTP.
• Routing in the client directs users to various pages (blogs, authentication screens, editor) which then invoke API endpoints on the server.
• The Backend uses controllers (for blog and user operations) that process incoming requests, perform authentication (using the authMiddleware), and then interact with the PostgreSQL database using Prisma.
• Data flow parts:
• User actions in the client (e.g., creating a blog post, signing in) trigger API calls to the backend routes.
• The backend validates/authenticates the request, processes the operation via its controllers, and then returns responses.
• Image uploads are managed by sending files which may be forwarded to Cloudinary.
Architectural Patterns & Design Principles
• Separation of Concerns: The division between client and server ensures a clear separation between presentation logic and business logic.
• MVC-like Pattern on the Backend: Controllers, routes, and middleware suggest a layered architecture where the controller layer handles business logic, the middleware handles cross-cutting concerns (like authentication), and the routes define the API structure.
• Component-based Architecture on the Frontend: The client is organized in React components (e.g., BlogCard, Navbar, Editor) and pages that isolate UI concerns.
• Use of State Management: The client’s “store” (using Recoil) and hooks indicates a design that centralizes state and side effects.
• Pages (e.g., Home, Login, Signup, BlogPage)
• Components (e.g., Navbar, BlogCard, Editor)
• Layout & Routing
• Hooks & State Management
• API Routes (blog.routes, user.routes)
• Controllers (blog controllers, user controllers)
• Middleware (authMiddleware)
• Utilities (e.g., password hashing)
• Prisma ORM Integration
c. External Services:
• Optionally, include other external libraries or services that affect the system.
d. Interactions between components:
• From “Frontend” to “Backend” labeled “API Calls (HTTP/REST)”.
• From “Backend” to “Database” labeled “Prisma ORM Queries/Mutations”.
• From “Backend” to “Cloudinary” (if applicable) for image uploads.
• Middleware intercepting API calls for authentication.