|
|
Course: Web Technologies @ Università degli studi di Napoli Federico II (UNINA) Track: B - WebTech's MemeMuseum Author: Oreste Leone N86/1980 |
MemeMuseum is a Single Page Application (SPA) dedicated to sharing and discovering memes. It allows users to explore a gallery of memes, view a "Meme of the Day", and search by tags or dates. Authenticated users can upload memes, vote (upvote/downvote), and comment on content.
The project relies on a strictly defined architecture:
- Frontend: React + Vite (Feature-Based Architecture)
- Backend: Express + Node.js (3-Layer Architecture)
- Database: SQLite (managed via Prisma ORM)
- Infrastructure: Docker Compose
- Runtime: Node.js (v24 LTS)
- Framework: Express.js (TypeScript)
- Database: SQLite (
dev.db) - ORM: Prisma
- Auth: JWT (JSON Web Tokens) & bcryptjs
- File Upload: Multer (Local storage in
./public/uploads)
- Framework: React (Vite) + TypeScript
- Styling: Tailwind CSS + DaisyUI
- Data Fetching: Axios + React Query (TanStack Query)
- State Management: Context API (Auth state)
- Routing: React Router DOM
- Testing: Cypress (E2E)
- Orchestration: Docker Compose
- Web Server: Nginx (for serving the production frontend)
- Persistence: Docker Volumes for database and uploads
The easiest way to run the entire application is using Docker Compose.
- Docker Desktop installed and running.
-
Configure Network Access (Optional): If you plan to access the app from a mobile device or another computer on your network:
-
Create a
.envfile in the project root. -
Add your machine's local IP address (e.g.,
192.168.1.X):VITE_API_URL=http://<YOUR_LOCAL_IP>:3000
-
-
Start the application:
# If using a custom .env file for network access docker-compose --env-file .env up --build # Or simply (defaults to localhost) docker-compose up --build
This command builds the images for both frontend and backend, sets up the network, and mounts the necessary volumes.
-
Access the App:
- Frontend: http://localhost:5173 (or
http://<YOUR_LOCAL_IP>:5173) - Backend API: http://localhost:3000 (or
http://<YOUR_LOCAL_IP>:3000)
- Frontend: http://localhost:5173 (or
-
Stop the application: Press
Ctrl+Cin the terminal or run:docker-compose down
If you prefer running services individually without Docker.
cd backend
# Install dependencies
npm install
# Generate Prisma Client
npx prisma generate
# Push Database Schema (Create dev.db)
npx prisma db push
# Optional, Seed Database
npx prisma db seed
# Start the Server
npm run devThe backend will run on http://localhost:3000.
Open a new terminal window:
cd frontend
# Install dependencies
npm install
# Start the Dev Server
npm run devThe frontend will run on http://localhost:5173.
The project implements several clean-code patterns to ensure maintainability:
- Shared Types: TypeScript DTOs and constants are shared between Frontend and Backend in
/src/shared. - Async Error Handling: Uses a centralized
asyncHandlerwrapper in the backend to eliminate repetitive try-catch blocks. - Centralized API Client: A configured Axios instance with interceptors handles JWT token injection automatically.
- Logic Extraction: Complex UI logic (e.g., voting) is moved from components into custom hooks like
useVote.
/
├── docker-compose.yml # Orchestration
├── backend/ # Express API
│ ├── src/
│ │ ├── controllers/ # Request handling
│ │ ├── services/ # Business logic & DB access
│ │ ├── shared/ # Shared types & constants
│ │ ├── routes/ # API Routes definition
│ │ ├── lib/ # Utilities (AsyncHandler, etc.)
│ │ └── app.ts # Express setup
│ ├── prisma/ # Database schema
│ └── public/uploads/ # Meme image storage
└── frontend/ # React App
├── src/
│ ├── features/ # Logic grouped by feature (auth, memes)
│ ├── shared/ # Shared types & constants
│ ├── components/ # Shared UI components
│ ├── pages/ # Page assemblers
│ ├── lib/ # Utilities (Axios config)
│ └── layouts/ # MainLayout, Navbar
└── cypress/ # End-to-End tests
- Gallery: Browse memes with pagination.
- Meme of the Day: View a randomly selected meme.
- Search: Filter by tag or date.
- Sorting: Sort by upload date or popularity (votes).
- Details: View full-size image, score, and comments.
- Upload: Post new memes with images and tags.
- Interaction: Upvote/Downvote memes.
- Comments: Add comments to discussions.
End-to-End tests are implemented using Cypress.
To run tests (ensure frontend and backend are running):
cd frontend
npx cypress open- Mobile First: The UI is designed to be fully responsive.
- Persistence: SQLite database and uploaded images are persisted via Docker volumes.