# Build a Banking App Part 1: HTML Templates and Routes in a Web App ```mermaid journey title Your Banking App Development Journey section SPA Fundamentals Understand single-page apps: 3: Student Learn template concepts: 4: Student Master DOM manipulation: 4: Student section Routing Systems Implement client-side routing: 4: Student Handle browser history: 5: Student Create navigation systems: 5: Student section Professional Patterns Build modular architecture: 5: Student Apply best practices: 5: Student Create user experiences: 5: Student ``` When Apollo 11's guidance computer navigated to the moon in 1969, e bin gats switch between different programs without restarting the entire system. Modern web applications dey work similarly – dem dey change wetin you dey see without reloading everything from scratch. Dis one dey create the smooth, responsive experience wey users dey expect nowadays. Unlike traditional websites wey dey reload whole pages for every interaction, modern web apps dey update only the parts wey need to change. Dis method, like how mission control dey switch between different displays while still dey communicate, e dey create that fluid experience we don dey expect. Na wetin make di difference so big: | Traditional Multi-Page Apps | Modern Single-Page Apps | |----------------------------|-------------------------| | **Navigation** | Full page reload for each screen | Instant content switching | | **Performance** | Slower due to complete HTML downloads | Faster with partial updates | | **User Experience** | Jarring page flashes | Smooth, app-like transitions | | **Data Sharing** | Difficult between pages | Easy state management | | **Development** | Multiple HTML files to maintain | Single HTML with dynamic templates | **Understanding the evolution:** - **Traditional apps** need server requests for every navigation action - **Modern SPAs** load once and update content dynamically using JavaScript - **User expectations** now dey favour instant, smooth interactions - **Performance benefits** dey include less bandwidth usage and faster responses For this lesson, we go build a banking app wey get many screens wey dey flow well together. Like how scientists dey use modular instruments wey you fit reconfigure for different experiments, we go use HTML templates as reusable components wey fit show anytime we need am. You go work with HTML templates (reusable blueprints for different screens), JavaScript routing (the system wey dey switch between screens), and the browser's history API (wey keep the back button dey work as e suppose). Dem na the same important methods wey frameworks like React, Vue, and Angular use. By the end, you go get a working banking app wey show professional single-page application principles. ```mermaid mindmap root((Single-Page Applications)) Architecture Template System Client-side Routing State Management Event Handling Templates Reusable Components Dynamic Content DOM Manipulation Content Switching Routing URL Management History API Navigation Logic Browser Integration User Experience Fast Navigation Smooth Transitions Consistent State Modern Interactions Performance Reduced Server Requests Faster Page Transitions Efficient Resource Usage Better Responsiveness ``` ## Pre-Lecture Quiz [Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/41) ### Wetin You Go Need We go need local web server to test our banking app – no worry, e easy pass as e sound! If you never set am up before, just install [Node.js](https://nodejs.org) and run `npx lite-server` from your project folder. Dis command go start local server and open your app for browser automatically. ### Preparation For your computer, create folder wey dem go call `bank` put inside am file wey get name `index.html`. We go start from dis HTML [boilerplate](https://en.wikipedia.org/wiki/Boilerplate_code): ```html Bank App ``` **Wetin dis boilerplate dey provide:** - **Establishes** the HTML5 document structure with proper DOCTYPE declaration - **Configures** character encoding as UTF-8 for international text support - **Enables** responsive design with the viewport meta tag for mobile compatibility - **Sets** a descriptive title wey go show for browser tab - **Creates** clean body section wey we go take build our application > πŸ“ **Project Structure Preview** > > **By the end of this lesson, your project go get:** > ``` > bank/ > β”œβ”€β”€ index.html > β”œβ”€β”€ app.js > └── style.css > ``` > > **File responsibilities:** > - **index.html**: Get all templates and app structure > - **app.js**: E dey handle routing, navigation, and template management > - **Templates**: Na UI for login, dashboard, and other screens --- ## HTML Templates Templates dey solve one basic problem for web development. When Gutenberg invent movable type printing for 1440s, e realize say instead make e carve full pages, e fit create reusable letter blocks and arrange dem as e want. HTML templates dey work like dat – instead of creating separate HTML files for each screen, you go define reusable structures wey you fit show anytime you need am. ```mermaid flowchart TD A["πŸ“‹ Templet Definshon"] --> B["πŸ’¬ Hid en DOM"] B --> C["πŸ” JavaScript Dey Find Templet"] C --> D["πŸ“‹ Klon Templet Kontent"] D --> E["πŸ”— Atach to We Dey Visible DOM"] E --> F["πŸ‘οΈ Yusae Dey See Kontent"] G["Login Templet"] --> A H["Dashboard Templet"] --> A I["Futura Templet"] --> A style A fill:#e3f2fd style D fill:#e8f5e8 style F fill:#fff3e0 style B fill:#f3e5f5 ``` Think templates as blueprint for different parts of your app. Like architect wey create one blueprint and use am many times instead of drawing exact rooms again and again, we dey create templates once and e go show anytime we need am. The browser dey hide these templates until JavaScript use am activate dem. If you want make web page get many screens, one way na to create one HTML file for every screen you want show. But dis one get small wahala: - You go gats reload full HTML anytime you change screen, e fit slow. - E hard to share data between the different screens. Another way na to get only one HTML file, and define many [HTML templates](https://developer.mozilla.org/docs/Web/HTML/Element/template) using the `