This project implements a basic community posting platform where users can register with their neighbourhood (area), create posts automatically tagged with their area, and view a feed of posts only from their selected neighbourhood.
- Node.js with Express framework
- MySQL (via
mysql2library) - EJS templates for server‑side rendering
- Bootstrap 5 for styling
-
Install dependencies :
cd local_area_app npm install express ejs mysql2 express-session body-parser bcryptjs connect-flash -
Configure database credentials and session secret:
Create a
.envfile based on the provided.env.exampleand adjust values for your environment. The application reads configuration from this file usingprocess.env.Example
.env:PORT=3000 NODE_ENV=development SESSION_SECRET=change_this_secret DB_HOST=localhost DB_PORT=3306 DB_USER=your_user DB_PASSWORD=your_password DB_NAME=locallensforum # CORS_ORIGIN and JWT settings are optional CORS_ORIGIN=http://localhost:3000 JWT_SECRET=replace_with_a_long_random_string JWT_EXPIRES_IN=2d
-
Start the server:
node src/app.js
Start development Server (Do this to test feature live)
nodemon src/app.js
Or
npm run okk
-
Navigate to
http://localhost:3000to access the application.
follows MVC arch
- Routes define the endpoints and delegate to controllers.
- Controllers contain the business logic and interact with models.
- Models encapsulate database access, abstracting SQL queries away from controllers.
- Views (EJS templates) handle UI rendering and include partials for header and footer.
- Middleware attaches the current user to the response locals so that templates can easily access authentication state.