How learnshare/blog-test works
Main Components
• Backend Services:
• Admin API: Found under apps/admin-api, this is the backend service that likely handles administrative tasks (managing accounts, posts, tickets, authentication, etc.).
• API: Located in apps/api, this service appears to provide the core blog functionality for public users – handling posts, files, bookmarks, and more.
• Frontend Applications:
• Admin Web: Under apps/admin-web, this application serves the administrative user interface.
• Web: Located in apps/web, this is the public-facing website likely built using Next.js (as indicated by next.config.ts and the file structure). It handles the user interface for blog readers, authors, and interactive pages.
• Shared Libraries and Utilities:
• packages/lib: Contains shared helper functions such as error handling, HTTP utilities, JWT and MD utilities.
• packages/lib/sdk: This SDK appears to provide programmatic access for both the admin and web frontends.
• packages/database: Serves as the data access layer with database configuration, migrations (using Prisma), and modules for handling accounts, posts, bookmarks, etc.
• Infrastructure & Environment:
• Dockerfiles, docker-compose.yaml, .env files, and pm2.json indicate container orchestration and process management.
• The presence of Nginx configuration files (e.g., .envs/dev/nginx-admin.conf) suggests that reverse proxy and load balancing are part of the deployment.
Understand the Relationships and Interactions
• The Admin Web application communicates with the Admin API service to perform back-office tasks.
• The Web application interacts with the API for public blog functionalities such as fetching posts and managing user sessions.
• Both API backends (Admin API and API) rely on the shared database layer (packages/database) for persistence. They use corresponding data models and migrations managed by Prisma.
• Shared libraries (packages/lib and its SDK) are integrated with these apps to provide common functionality (like JWT handling, error management, and HTTP requests).
• Docker and environment configurations indicate that all these components are containerized and may interact over defined network bridges or via a reverse proxy (Nginx).
Architectural Patterns and Design Principles
• Microservice/Multi-application Paradigm: While all code is in one repository, separate applications (admin API, API, admin web, and web) underline a separation of concerns, where the backend logic is divided based on user type (administrative vs. public).
• Shared Modules: The repo uses a modular approach for the database and library functions, promoting reuse across applications.
• Containerization: Dockerfiles and docker-compose signal a containerized deployment model, which is essential for replicating the environment reliably in production.
Key Technologies and Frameworks
• TypeScript: Evident by the .ts files across the backend and frontend.
• Node.js: The backend services and utilities are built in Node.js.
• Prisma: Used in packages/database for migrations and ORM functionality.
• Next.js: The Web application uses Next.js (as indicated by next.config.ts) for its frontend.
• Vite: The Admin Web application uses Vite for building and development as indicated by vite.config.ts.
• Docker and PM2: For deployment, process management, and environment configuration.
• Two Backend Services: "Admin API" and "API"
• Two Frontend Applications: "Admin Web" and "Web (Next.js)"
• Infrastructure components like "Docker", "PM2", and "Nginx" (if relevant to the architectural view).
• The API calls from Admin Web to Admin API.
• The API calls from Web to API.
• The database connections from both backend services to the Database.
• The integration between frontend apps and shared SDK libraries.
• Notes or legends:
• That the services are containerized.
• Technologies next to each service (e.g., “Admin API (Node.js, TypeScript)”, “Web (Next.js)”).