DEV Community

Bharath Kumar_30
Bharath Kumar_30

Posted on

Fixing My Git Mistakes and Finally Understanding My Router Code

Today was one of those days where I didn’t just write code — I actually fixed my mistakes and understood what I built.


Cleaning Up My Git Mistakes

I realized I had made some serious beginner mistakes:

  • I committed my .env file (which contains secrets)
  • I pushed my database file to GitHub
  • I didn’t have a .gitignore

After guidance, I fixed everything properly:

  • Removed .env and .db from the repository
  • Created a .gitignore to avoid future mistakes
  • Added .env.example to show required environment variables without exposing secrets

This made me understand something important:

A clean and secure repository is as important as working code.


Understanding My Router Code

Earlier, my router files were just “working code” for me.

Today I actually understood what they do.

What is a Router?

In FastAPI, routers handle API requests.

Example:

@router.post("/login")
def login():
    return {"message": "User logged in"}
Enter fullscreen mode Exit fullscreen mode

Now I understand:

  • Router = entry point for requests
  • It connects frontend requests to backend logic
  • It calls services and database operations

Real Flow in My Project

Frontend → Router → Service → Database
Enter fullscreen mode Exit fullscreen mode
  • User clicks something on UI
  • Router receives request
  • Service handles logic
  • Database stores/retrieves data

What Changed Today

Before:

  • Code was running, but I didn’t fully understand it

Now:

  • I know how requests flow
  • I understand how routers connect everything

Key Learning

  • Never commit sensitive files like .env
  • Always use .gitignore
  • Routers are the backbone of API communication
  • Understanding your code matters more than just running it

Final Thought

Fixing mistakes taught me more than writing new code.

Every small correction is making me a better developer.


Next Step

  • Deep dive into services layer
  • Improve authentication flow
  • Prepare for technical discussion

If you’re building projects, take time to clean your repo and understand your code. That’s where real growth happens.

Top comments (0)