How mlldzi/coffee-corner-sp works
Main Components
a. Client (Browser)
• The user’s browser running the React/Next.js UI.
b. Frontend Service
• Next.js app (React) in a Node.js container.
• Renders pages (menu, checkout, history, etc.) and serves static assets (images, videos).
• Contains a client-side “services/api.js” for communicating with the backend and “services/store.js” for state management.
c. Backend Service
• Flask/Python application in its own container.
• Exposes RESTful endpoints under /auth, /menu, /orders, /user.
• Layers:
• Routes (in backend/app/routes/)
• Business logic (in backend/app/services/)
• Data models (SQLAlchemy models in backend/app/models.py)
• Utilities (decorators, helpers)
d. Database
• PostgreSQL container managed via Docker Compose.
• Stores users, orders, menu items. Credentials loaded from backend/secrets.
e. Docker Compose
• Orchestrates the three containers (frontend, backend, database) and defines networking.
f. Optional/Test Components
• Frontend ESLint config, but not a runtime component.
Relationships & Data Flows
• User → (HTTP) → Next.js frontend
• Next.js frontend → (HTTP/REST) → Flask backend
• Flask backend → (SQL) → PostgreSQL
• PostgreSQL → (SQL results) → Flask backend → (JSON) → Frontend → Browser
• Docker Compose networks all three via an internal bridge
• Secrets fed into the backend container at runtime
Architectural Patterns
• Separation of Concerns:
• Presentation (Next.js) vs. API (Flask) vs. Persistence (Postgres)
• Layered Backend:
• Controllers (routes) → Services → Models → DB
• Component-Based Frontend:
• React components under src/app/components
• CSS Modules for styling
• Containerization:
• Each service in its own Docker container
• Single docker-compose.yaml for dev/local orchestration
Technologies/Frameworks
• Frontend: Next.js, React, CSS Modules, ESLint
• Backend: Flask, SQLAlchemy, Pytest
• Database: PostgreSQL
• DevOps: Docker, Docker Compose