Everything you need as a full stack developer

Building a Simple Portfolio Project

- Posted in Junior Developer by

TL;DR Building a professional online presence is crucial for developers, as it showcases skills, experience, and accomplishments to potential clients or employers. A portfolio project can be built from scratch using popular technologies like HTML5, CSS3, JavaScript, Node.js, Express.js, and MongoDB. The project structure includes an index.html file, styles.css, script.js, server.js, models/Project.js, and routes/projects.js.

Building a Simple Portfolio Project: A Step-by-Step Guide for Beginners

As a full-stack developer, having a professional online presence is crucial in today's digital landscape. A portfolio project showcases your skills, experience, and accomplishments to potential clients, employers, or collaborators. In this article, we'll embark on a journey to build a simple yet effective portfolio project from scratch, covering the foundational concepts and techniques essential for any beginner.

Why a Portfolio Project Matters

Before diving into the nitty-gritty of building our project, let's understand why having a portfolio is vital for developers:

  • Demonstrate expertise: A portfolio provides concrete evidence of your skills, making it easier to attract clients or land job interviews.
  • Stand out from the crowd: In a competitive industry, a well-crafted portfolio sets you apart from other developers and helps you establish a unique identity.
  • Continuous improvement: Building and maintaining a portfolio encourages you to continually update your skills and showcase new projects.

Choosing the Right Technologies

For our simple portfolio project, we'll focus on popular, easy-to-learn technologies that provide a solid foundation for beginners:

  • Frontend: HTML5, CSS3, and JavaScript (using vanilla JS)
  • Backend: Node.js with Express.js framework
  • Database: MongoDB (using Mongoose ORM)

Project Structure

Our project will consist of the following components:

  • index.html: The main entry point for our portfolio website.
  • styles.css: A stylesheet to add visual appeal and consistency to our site.
  • script.js: A JavaScript file containing interactive elements and dynamic content.
  • server.js: Our Node.js server-side script, responsible for handling requests and interacting with the database.
  • models/Project.js: A MongoDB model representing individual projects in our portfolio.
  • routes/projects.js: An Express.js route handler for retrieving and displaying project data.

Building the Frontend

Let's start by creating a basic HTML structure in index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Portfolio</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <!-- Project list will be rendered here -->
    <div id="project-list"></div>
    <script src="script.js"></script>
</body>
</html>

Next, add some basic styling in styles.css to make our site visually appealing:

body {
    font-family: Arial, sans-serif;
    margin: 20px;
}

#project-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

Adding Interactivity with JavaScript

In script.js, we'll use vanilla JavaScript to fetch project data from our backend API and render it in the #project-list container:

fetch('/api/projects')
    .then(response => response.json())
    .then(projects => {
        const projectList = document.getElementById('project-list');
        projects.forEach(project => {
            const projectCard = document.createElement('div');
            projectCard.innerHTML = `
                <h2>${project.title}</h2>
                <p>${project.description}</p>
            `;
            projectList.appendChild(projectCard);
        });
    })
    .catch(error => console.error('Error:', error));

Setting Up the Backend

Create a new file server.js and set up an Express.js server:

const express = require('express');
const app = express();
const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost:27017/my-portfolio', { useNewUrlParser: true, useUnifiedTopology: true });

app.use(express.json());

app.get('/api/projects', (req, res) => {
    // We'll implement this route handler soon
});

app.listen(3000, () => console.log('Server started on port 3000'));

Defining the Project Model

In models/Project.js, define a MongoDB model for our projects:

const mongoose = require('mongoose');

const projectSchema = new mongoose.Schema({
    title: String,
    description: String,
    url: String,
});

module.exports = mongoose.model('Project', projectSchema);

Implementing the Route Handler

In routes/projects.js, create a route handler to retrieve and send project data:

const express = require('express');
const router = express.Router();
const Project = require('../models/Project');

router.get('/', async (req, res) => {
    try {
        const projects = await Project.find().exec();
        res.json(projects);
    } catch (error) {
        console.error('Error:', error);
        res.status(500).json({ message: 'Internal Server Error' });
    }
});

module.exports = router;

Connecting the Dots

Finally, update server.js to include our route handler:

const express = require('express');
const app = express();
const projectsRouter = require('./routes/projects');

app.use('/api', projectsRouter);

app.listen(3000, () => console.log('Server started on port 3000'));

Conclusion

Congratulations! We've successfully built a simple portfolio project from scratch. This foundation will serve as a solid starting point for showcasing your skills and experience to the world.

In future articles, we'll explore ways to enhance our portfolio by adding more features, such as user authentication, filtering, and sorting. For now, take pride in what you've accomplished and start building upon this project to make it your own.

Remember, a portfolio is an ongoing process. Continuously update and refine it to reflect your growth as a developer. Happy coding!

Key Use Case

Here's a workflow or use-case for a meaningful example:

Personal Project Showcase

As a freelance web developer, I want to create an online portfolio to showcase my skills and experience to potential clients. My goal is to build a simple yet effective website that demonstrates my expertise in HTML5, CSS3, JavaScript, Node.js, Express.js, and MongoDB.

I will start by creating a basic HTML structure for the main entry point of my website. Then, I'll add some basic styling using CSS to make the site visually appealing. Next, I'll use vanilla JavaScript to fetch project data from my backend API and render it in a container on the website.

On the backend, I'll set up an Express.js server with Node.js and connect it to a MongoDB database using Mongoose ORM. I'll define a Project model for my projects and create a route handler to retrieve and send project data.

Once everything is connected, I'll be able to showcase my personal projects on the website, including their titles, descriptions, and URLs. This will help me stand out from other developers and attract potential clients to my services.

Finally

As we continue to build upon our portfolio project, it's essential to keep in mind the purpose of showcasing our skills and experience. By doing so, we'll be able to effectively communicate our value as developers to potential clients or employers, ultimately setting ourselves up for success in the industry.

Recommended Books

• "Full Stack Development with JavaScript" by Shyam Seshadri • "Node: Up and Running" by Tom Hughes-Croucher and Mike Wilson • "HTML and CSS: Design and Build Websites" by Jon Duckett

Fullstackist aims to provide immersive and explanatory content for full stack developers Fullstackist aims to provide immersive and explanatory content for full stack developers
Backend Developer 103 Being a Fullstack Developer 107 CSS 109 Devops and Cloud 70 Flask 108 Frontend Developer 357 Fullstack Testing 99 HTML 171 Intermediate Developer 105 JavaScript 206 Junior Developer 124 Laravel 221 React 110 Senior Lead Developer 124 VCS Version Control Systems 99 Vue.js 108

Recent Posts

Web development learning resources and communities for beginners...

TL;DR As a beginner in web development, navigating the vast expanse of online resources can be daunting but with the right resources and communities by your side, you'll be well-equipped to tackle any challenge that comes your way. Unlocking the World of Web Development: Essential Learning Resources and Communities for Beginners As a beginner in web development, navigating the vast expanse of online resources can be daunting. With so many tutorials, courses, and communities vying for attention, it's easy to get lost in the sea of information. But fear not! In this article, we'll guide you through the most valuable learning resources and communities that will help you kickstart your web development journey.

Read more

Understanding component-based architecture for UI development...

Component-based architecture breaks down complex user interfaces into smaller, reusable components, improving modularity, reusability, maintenance, and collaboration in UI development. It allows developers to build, maintain, and update large-scale applications more efficiently by creating independent units that can be used across multiple pages or even applications.

Read more

What is a Single Page Application (SPA) vs a multi-page site?...

Single Page Applications (SPAs) load a single HTML file initially, handling navigation and interactions dynamically with JavaScript, while Multi-Page Sites (MPS) load multiple pages in sequence from the server. SPAs are often preferred for complex applications requiring dynamic updates and real-time data exchange, but MPS may be suitable for simple websites with minimal user interactions.

Read more