ForeCafe is a full-stack social web application for sharing favorite café drinks, saving café locations, and connecting with friends. The project uses an MVC-style Node.js backend with MongoDB for persistence, Redis-backed sessions for authentication state, Handlebars for page templates, and React bundles for interactive client-side views.
Accessible at -> https://forecafe-777e7f57c981.herokuapp.com/home
- Overview
- Key Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Available Scripts
- Application Routes
- Data Model Summary
- Security and Middleware
- Development Notes
ForeCafe is designed as a small social platform centered around café culture. After creating an account, users can:
- create and manage drinks,
- save café locations with coordinates,
- mark drinks as favorites,
- search for other users,
- send, accept, and reject friend requests,
- browse a shared home feed containing drinks and locations from across the platform,
- view a personal profile page with friends, favorite drinks, and saved locations.
The app serves Handlebars views from the Express server and mounts page-specific React applications into those views for dynamic behavior.
- Sign up with a username and password.
- Log in and log out with server-managed sessions.
- Change account passwords.
- Secure session storage using Redis.
- Create drinks with a name, temperature, and ingredients.
- Mark drinks as favorites at creation time or later.
- Remove previously created drinks.
- View personal drinks and shared drink content on the home page.
- Save café locations with a name, address, longitude, and latitude.
- Remove saved locations.
- View personal locations and platform-wide location content on the home page.
- Search for users by username.
- Send friend requests.
- Accept or reject incoming friend requests.
- View current friends on the friends page.
- View friends and favorite drinks on the profile page.
- The application includes an authenticated
/documentationpage that lists supported routes and expected request formats.
- Node.js
- Express
- Mongoose
- MongoDB
- Redis
- express-session
- connect-redis
- Handlebars
- React
- React DOM
- Webpack
- Babel
- CSS
- bcrypt for password hashing
- helmet for secure HTTP headers
- compression for response compression
- body-parser for JSON and form handling
.
├── client/ # React entry points for each page
├── hosted/ # Compiled frontend bundles, styles, and static assets
├── server/
│ ├── controllers/ # Route handlers and application logic
│ ├── middleware/ # Authentication and request middleware
│ ├── models/ # Mongoose schemas and model exports
│ ├── app.js # Express app bootstrap
│ └── router.js # Route definitions
├── views/ # Handlebars page templates
├── webpack.config.js # Frontend bundle configuration
└── package.json # Dependencies and npm scripts
Make sure the following services and tools are available locally:
- Node.js 18 or higher
- npm
- MongoDB
- Redis
-
Clone the repository.
-
Install dependencies:
npm ci
-
Create a
.envfile in the project root. -
Add the required environment variables listed below.
-
Start MongoDB and Redis.
-
Build the frontend bundles:
npm run webpack
-
Start the server:
npm start
-
Open
http://localhost:3000in your browser unless you configured a different port.
The server reads configuration from environment variables with dotenv.
| Variable | Required | Purpose |
|---|---|---|
PORT |
No | Primary port used by the Express server. |
NODE_PORT |
No | Fallback port if PORT is not set. |
MONGODB_URI |
No | MongoDB connection string. Defaults to mongodb://127.0.0.1/ForeCafe. |
REDISCLOUD_URL |
Yes | Redis connection URL used for session storage. Despite the name, it can point to a local Redis instance or a hosted Redis service. |
Example:
PORT=3000
MONGODB_URI=mongodb://127.0.0.1/ForeCafe
REDISCLOUD_URL=redis://127.0.0.1:6379| Script | Description |
|---|---|
npm start |
Starts the Express server. |
npm run nodemon |
Starts the server with file watching for server, HTML, and CSS changes. |
npm run webpack |
Builds the React frontend bundles into hosted/. |
npm run webpackWatch |
Rebuilds frontend assets in watch mode. |
npm test |
Runs ESLint on the server/ directory and then executes the placeholder test command. |
| Route | Method | Description | Access |
|---|---|---|---|
/ |
GET | Login page | Logged-out users |
/login |
GET | Login page | Logged-out users |
/home |
GET | Shared home feed for drinks and locations | Logged-in users |
/documentation |
GET | In-app API documentation page | Logged-in users |
/drink |
GET | Drink management page | Logged-in users |
/location |
GET | Location management page | Logged-in users |
/profile |
GET | Logged-in user profile | Logged-in users |
/friend |
GET | Friend search and requests page | Logged-in users |
/logout |
GET | Destroys session and redirects to login | Logged-in users |
| Route | Method | Description |
|---|---|---|
/login |
POST | Authenticates a user and starts a session |
/signup |
POST | Creates a new account |
/changePassword |
POST | Changes a user password |
/getUserProfile |
GET | Returns profile data, favorite drinks, friends, and locations |
/getFriends |
GET | Returns the authenticated user's friends |
/searchUsers |
GET | Searches users by username with a query parameter |
/sendFriendRequest |
POST | Sends a friend request to another user |
/acceptFriendRequest |
POST | Accepts a pending friend request |
/rejectFriendRequest |
POST | Rejects a pending friend request |
/getFriendRequests |
GET | Returns pending friend requests |
/getHomeData |
GET | Returns drinks and locations shown on the home feed |
| Route | Method | Description |
|---|---|---|
/drink |
POST | Creates a new drink |
/getDrinks |
GET | Returns drinks owned by the authenticated user |
/removeDrink |
POST | Deletes a drink by ID or name |
/favoriteDrink |
POST | Toggles a drink's favorite status |
| Route | Method | Description |
|---|---|---|
/makeLocation |
POST | Creates a new location |
/getLocations |
GET | Returns locations owned by the authenticated user |
/removeLocation |
POST | Deletes a location by ID or name |
usernamepasswordprofilePicturefriendsfriendRequestsfavoriteDrinkslocationscreatedDate
nametemperature(HotorCold)ingredientsfavoriteownercreatedDate
nameaddressloc.typeloc.coordinatesownercreatedDate
- Passwords are hashed with
bcrypt. - Session state is stored in Redis using
express-sessionandconnect-redis. helmetis enabled for secure HTTP headers.- Auth-protected routes use middleware that requires an active session.
- Logged-in users are redirected away from logged-out-only routes.
- Drink and location names are sanitized at the schema level with
underscore.escape.
- Frontend code lives in
client/and is bundled per page with Webpack. - Compiled assets are emitted into
hosted/. - The server automatically creates an
uploadsdirectory at startup if it does not exist. - The current
npm testscript primarily performs linting and then prints a placeholder completion message, so additional automated test coverage may still be needed for production readiness.