我打造首個全端人臉識別應用的旅程:挑戰、錯誤與經驗教訓
Building My First Full-Stack Face Recognition App: The Journey, Challenges, Bugs, and Lessons Learned
作者打造首個全端人臉識別應用,藉此學習前端、後端、身份驗證、API 串接及部署。項目使用 React、Node.js、Express、JWT 和 Human.js,作者分享規劃、開發與除錯過程中的挑戰及經驗。




I started with an idea. I ended up learning much more about frontend development, backend development, authentication, APIs, debugging, and deployment than I expected.
Every developer has a project that pushes them beyond what they already know.
For me, that project was my Face Recognition App.
When I started, I wanted to build an application where users could submit an image and have faces detected in it. It sounded like an interesting React project, but I didn't want to stop at building just the interface.
I wanted to understand what happens behind the scenes too.
How does the frontend communicate with a backend? How does authentication work? How do we protect API routes? How do we handle requests and responses? How do we connect an external face-detection technology to an application?
These questions became part of my development journey.
This article is about the entire experience: the planning, frontend development, backend implementation, authentication, face detection, debugging, deployment, and the lessons I learned along the way.
Let's get into it.
1. The idea: More than just another React project
After spending time learning JavaScript and React, I wanted to challenge myself with something that would require me to think about the entire application.
I didn't want to build another frontend project that simply displayed information.
I wanted to build something that involved both the client side and the server side.
That's how the Face Recognition App started.
The idea was to create an application where users could interact with the system, submit image URLs, and have faces detected in the submitted images.
I also wanted to introduce authentication so users could have an account and access the application through a proper sign-in process.
The project gave me an opportunity to explore several important areas of web development:
- Frontend development with React.
- Backend development with Node.js and Express.
- API communication.
- Authentication and authorization.
- JWT-based protected routes.
- Face detection with Human.js.
- Error handling and validation.
- Deployment and production configuration.
I knew there would be challenges, but I was ready to learn through building.
2. Choosing the technology stack
I wanted a stack that would allow me to work on both frontend and backend development.
Here are the main technologies and tools I worked with:
| Technology | Purpose |
|---|---|
| React | Frontend application |
| Vite | Development environment and build tool |
| JavaScript | Application logic |
| CSS | Styling and responsive interface |
| Node.js | Backend runtime |
| Express.js | Backend server and API routes |
| JSON Web Token (JWT) | Authentication and protected routes |
| Human.js | Face detection |
| Postman | Testing backend API endpoints |
| Git and GitHub | Version control and project management |
Working with these technologies helped me understand that a full-stack application is not just a frontend connected to a server.
Every part has a responsibility, and those parts need to communicate correctly.
3. Building the frontend with React
I started with the frontend because I wanted to establish how users would interact with the application.
I used React with Vite and divided the interface into reusable components.
Some of the components I worked on included:
- Navigation
- Logo
- ImageLinkForm
- Rank
- FaceRecognition
- Authentication forms
I wanted to avoid putting the entire application inside one component.
Instead, I worked on separating responsibilities and passing information between components using props.
I also used React state to manage things such as:
- The image URL submitted by the user.
- The currently displayed image.
- Error messages.
- The scanning state.
- Authentication-related interface states.
This helped me understand how different components work together to create a complete application.
Making the interface more interactive
I didn't want the application to look too basic.
I worked with regular CSS to style the interface and experimented with additional libraries.
I integrated react-parallax-tilt to give the logo a 3D effect.
I also used @tsparticles/react and @tsparticles/slim to create animated background particles.
These were small details, but they helped me explore how external libraries can improve the user experience.
One thing I learned was that installing a package doesn't always mean everything will work immediately. Package versions, compatibility, and configuration can introduce problems of their own.
4. Connecting the frontend to the backend
This was one of the most important parts of the project for me.
I wanted to understand what happens when a React application communicates with a server.
I created a backend using Node.js and Express.
The backend ran separately from the Vite development server, using port 3001, while my frontend ran on port 5173.
This meant I had to understand how the two environments communicate.
I worked with Express routes to handle requests and responses.
I also configured CORS so the frontend running on http://localhost:5173 could communicate with the backend.
I used environment variables with dotenv to manage configuration values, including the JWT secret.
This was where I started understanding the importance of separating frontend responsibilities from backend responsibilities.
The frontend handles the user interface and interactions.
The backend handles server-side logic and API requests.
They communicate through HTTP requests and responses.
It sounds simple when explained, but actually setting everything up and getting it to work taught me a lot.
5. Authentication: Understanding JWT and protected routes
I wanted users to have a proper authentication experience.
So I introduced Sign In and Sign Up interfaces.
But I didn't want to stop at simply displaying authentication forms.
I wanted to understand what happens behind the scenes when a user authenticates.
I worked with JSON Web Tokens (JWT) and authentication middleware on the Express backend.
The idea was to authenticate users and use the token when accessing protected API routes.
I also worked on a protected endpoint:
GET /api/profile
This route required a valid token.
On the frontend, I used React's useEffect to make a request to the backend and included the JWT in the Authorization header using the Bearer token format.
This helped me understand a very important concept:
Authentication and authorization are not the same thing as displaying a Sign In form.
A user interface can collect login information, but the backend must handle authentication and protect resources.
I also worked on email validation and tested API routes using Postman.
Testing with Postman helped me understand what the backend was returning without depending entirely on the React interface.
It made debugging API requests much easier.
6. The face-detection functionality
Now, let's talk about the main feature that inspired the project.
How do you actually detect faces in an image?
At first, I explored different face-detection services and technologies.
I looked into Clarifai and other possible solutions, but I encountered connection and configuration difficulties.
I also explored MediaPipe as another possible option.
Eventually, I worked with Human.js.
Human.js allowed me to load a face-detection model and process images in the browser.
I worked with its loading and detection functionality:
- Loading the model.
- Processing an uploaded image.
- Detecting faces.
- Working with the detection results.
- Displaying the face-detection interface.
This part was particularly interesting because it introduced me to computer vision in a web application.
It also taught me something important: choosing a technology is only one part of integration. Understanding how it works, how to configure it, and how to use its results correctly is another challenge.
One technical distinction worth mentioning is that the Human.js implementation I explored performs face detection. Detecting a face is different from identifying whose face it is. That is an area I would like to explore further.
7. Image validation and user experience
I didn't want the application to behave unpredictably whenever someone submitted an invalid image URL.
So I worked on input validation.
I used JavaScript's URL constructor to validate submitted URLs and restricted the accepted protocols to HTTP and HTTPS.
I also added error handling for images that failed to load.
Another feature I worked on was the scanning experience.
When a user submits an image, the application displays a scanning message while processing takes place.
This introduced me to the importance of loading states and conditional rendering.
I learned that users should not have to guess what an application is doing.
A good application should communicate its current state, whether it is loading, processing, successful, or encountering an error.
8. The debugging experience: Nothing always works the first time
I wish I could say everything worked perfectly from the beginning.
It didn't.
I encountered several problems during development.
Some involved package compatibility.
Others involved imports, component setup, backend configuration, API communication, and authentication.
At one point, I encountered a useState error while working on the authentication components.
I had to investigate the import and setup rather than randomly changing code.
I also had to deal with CORS configuration and make sure my frontend and backend were communicating through the correct ports.
There were also difficulties while exploring external face-detection services.
And then came deployment.
Each problem required a different approach.
Sometimes I had to read documentation. Sometimes I had to inspect error messages. Other times, I had to test an endpoint independently using Postman.
I began to understand that debugging isn't something that happens occasionally in software development.
Debugging is part of the development process itself.
The most important thing I learned was to slow down, understand the error, investigate its cause, and test possible solutions instead of changing several things at once.
9. Deployment: Taking the project beyond localhost
After spending so much time developing the application locally, I wanted to make it accessible online.
This introduced another level of learning.
An application working on localhost doesn't automatically mean it will work in production.
The frontend and backend need to communicate correctly in the deployed environment too.
I encountered backend-related errors during deployment.
This meant I had to think about things I hadn't needed to worry about in the same way during local development:
- Production environment variables.
- Backend hosting.
- API URLs.
- CORS configuration.
- Server availability.
- Frontend-backend communication.
- Deployment logs.
It was frustrating, especially after putting so much work into the application.
But I realized that deployment is not just the final button you click after coding.
It is another part of building a full-stack application.
I still have more to learn in this area, but experiencing these issues has given me a better understanding of what happens when an application moves from development to production.
10. What I learned from building this full-stack project
This project helped me connect concepts I had previously learned separately.
Here are some of my biggest takeaways.
Frontend development
- Building reusable React components.
- Passing props between components.
- Managing state with
useState. - Using
useEffectfor side effects. - Handling forms and user input.
- Conditional rendering.
- Working with external libraries.
- Creating responsive interfaces.
Backend development
- Setting up a Node.js and Express server.
- Creating and handling API routes.
- Understanding HTTP requests and responses.
- Configuring CORS.
- Using environment variables.
- Implementing JWT authentication middleware.
- Protecting API endpoints.
Working with APIs
- Sending requests from React to Express.
- Passing authentication tokens.
- Testing endpoints with Postman.
- Handling API responses and errors.
- Understanding frontend-backend communication.
Computer vision
- Exploring face-detection technologies.
- Loading a detection model.
- Processing images with Human.js.
- Understanding the difference between face detection and face recognition.
Problem-solving
- Reading documentation.
- Debugging errors.
- Investigating package compatibility.
- Testing features independently.
- Working through deployment problems.
The biggest lesson?
I learned that building a full-stack application requires understanding how all the different pieces work together, not just knowing how to write code in each technology.
11. What I would improve if I started again
Looking back, there are things I would approach differently.
First, I would investigate the face-detection technology much earlier.
I spent time exploring different services and trying to understand their requirements. I would now research the available options and their limitations before committing to an integration approach.
Second, I would plan the frontend-backend communication more carefully from the beginning.
Third, I would test each feature independently as I build it.
I would also plan the deployment environment earlier instead of leaving too many production configuration questions until the end.
These are not lessons I want to forget.
They are things I want to carry into my next project.
12. What's next in my developer journey?
I'm still learning, and I don't want this project to be the end of my growth.
My goal is to become a Full-Stack Developer, and I want to keep improving my understanding of backend engineering, databases, authentication, system architecture, and scalable applications.
My next major project is an advanced multi-vendor e-commerce platform.
I want to explore how a larger application handles:
- Multiple user roles.
- Vendors and customer accounts.
- Product management.
- Inventory management.
- Shopping carts and orders.
- Payment integration.
- Database relationships.
- Authorization and security.
- Backend architecture.
I know it will be challenging, but that's exactly why I want to build it.
I want to keep learning by solving real development problems.
13. I'd love to hear from other developers
I didn't write this article simply to announce that I built a project.
I want to start a conversation.
There are developers here who have built much more complex applications than I have, and I'd genuinely appreciate learning from their experiences.
Here are a few questions I'd love to discuss:
1. Backend architecture: How would you structure the backend of a project like this? Would you use a modular monolith or a different architecture?
2. Authentication: What authentication practices would you recommend for a React and Express application using JWT? Are there things beginners commonly get wrong?
3. Face detection: If you were building this today, would you choose Human.js, MediaPipe, or a cloud-based face-detection API? Why?
4. Database design: How would you approach storing user information and other application data for a project like this?
5. Deployment: What hosting setup would you recommend for a full-stack React and Node.js application, especially when the frontend and backend are deployed separately?
6. General advice: For developers transitioning from frontend development into full-stack development, what concepts do you think deserve the most attention?
I'm open to corrections, constructive criticism, suggestions, and different approaches.
If you've worked on something similar, please share your experience in the comments.
I'd love to learn from you.
Final thoughts
This project reminded me why I enjoy building software.
There were moments when things worked perfectly, moments when I couldn't understand an error, and moments when I had to step back and reconsider my approach.
But every challenge gave me something to learn.
I started with an idea and used the project to explore both frontend and backend development.
I'm not claiming to know everything. I'm still learning, experimenting, and improving.
And that's the point.
The goal isn't to know everything before building. Sometimes, the best way to learn is to build something, encounter problems, and figure out how to solve them.
Thank you for reading.
Let's keep building. Let's keep learning. 🚀
Connect with me:
- GitHub: https://github.com/Horlah-dev
- LinkedIn: https://linkedin.com/in/raji-ridwan-90210b380
- X: https://x.com/horlah13711
FullStackDevelopment #React #NodeJS #ExpressJS #JavaScript #WebDevelopment #BuildInPublic #100DaysOfCode
來源:DEV Community · dev.to