How yamang02/skku_fac works
Project type and purpose
• This is a full-stack web application (“SKKU 성미회 갤러리”) for managing and viewing art exhibitions and artworks.
• Backend: Node.js + Express.js with a layered, DDD-inspired folder structure (domain, infrastructure, common).
• Frontend: Server-rendered EJS templates + vanilla JavaScript + custom CSS.
• External services: MySQL database (via Sequelize ORM), Cloudinary for image storage, Railway for hosting, Swagger for API docs.
File structure
• Top-level “src/” holds:
• app.js (Express setup), server.js (boot), routeIndex.js (router aggregator)
• domain/ (per-feature MVC: controller, service, model/dto)
• infrastructure/ (cloudinary integration + DB adapter, repository, entity/relationship models)
• common/ (middleware, error types, utilities)
• config/ (environment-specific settings, infrastructure wiring)
• public/ (static assets: CSS, JS, images, uploads)
• views/ (EJS templates grouped by “admin” and “main” UX)
• Supporting files: swagger.json, ESLint/Stylelint configs, README, docs, CI/CD scripts.
Key insights from README
• Layered architecture with clear separation of concerns (Controller → Service → Repository).
• MVC pattern for each domain (auth, user, artwork, exhibition, admin).
• Repository/Adapter pattern abstracts DB operations.
• Uses middleware for sessions, auth, rate-limiting, helmet for security.
a. Main components:
• Client (Browser)
• Static assets: CSS, vanilla JS, images
• EJS-rendered pages
• Express Server
• Routing layer (routeIndex → domain routers)
• Controllers (per-domain API and view controllers)
• Middleware (auth, error handler, image upload, rate limiter, helmet)
• Services (business logic)
• Repositories & Adapters (DB access via Sequelize)
• MySQL Database (with entity tables & relationships)
• Cloudinary (external object storage for images)
• Session Store (backed by MySQL or in-memory store)
• Swagger UI (API documentation endpoint)
• CI/CD pipeline on Railway
b. Relationships & interactions:
• Browser → HTTP(S) → Express router → Controller → Service → Repository → MySQL.
• Image upload flows: Browser submits multipart → Express multer middleware → Cloudinary provider → returns URL → service persists URL in DB.
• Session management: After login, Express-session middleware ties user session to session store in DB.
• API docs: Browser ↔ Swagger-UI served from swagger.json.
c. Architectural patterns & principles:
• Layered (Presentation → Controller → Service → Repository → DB).
• MVC per domain (views + controllers + services).
• Repository & Adapter patterns decouple business logic from ORM details.
• DDD-style “domain” folder groups related artifacts.
• Separation of static assets (public) vs. dynamic rendering (views).
d. Key technologies & frameworks:
• Node.js, Express.js
• Sequelize ORM → MySQL
• EJS templating engine
• Vanilla JS for client scripts
• Cloudinary (image hosting)
• Middleware: Helmet, express-rate-limit, multer-storage-cloudinary
• Security: Session auth (express-session), bcrypt for passwords
• Deployment: Railway, environment variables via dotenv
Detail
• Middleware as a horizontal strip across the request flow.
• Notes on security (helmet, rate-limit) and caching for static assets.
• API documentation endpoint (/api-docs) connecting to swagger.json.