# Code Organization

A good coding convention must be complemented by good code organization on the macro level. A self-explanatory directory structures make the project more extensible and maintainable. Debugging is a lot easier. Besides, it guides folks new to the code base to understand code better.&#x20;

**Directory Structure of `lib/`**

```
│
├───lib
│   │   config.dart                                -> contains API keys
│   │   generated_plugin_registrant.dart           -> auto-generated by flutter
│   │   main.dart                                  -> starting point of the app
│   │
│   ├───bloc                              -> [DIR] in BLoC pattern
│   │   │   argument_models.dart          -> classes/models for passing arguments b/w pages
│   │   │   auth.dart                     -> functions related to user authentication
│   │   │   string_helpers.dart           -> misc. string manipulation function
│   │   │
│   │   └───api_callers                            -> [DIR] contains functions that make API calls
│   │           recommendation_helpers.dart        -> helper functions to fetch song recommendations    
│   │           user_data_helpers.dart             -> helper functions to fetch user profile data
│   │
│   ├───pages                              -> [DIR] contains all the widgets that make up pages of the app
│   │       auth_intermediate.dart         -> intermediate screen b/w auth redirect and user profile page
│   │       menu.dart                      -> Main Initial screen with sign in button
│   │       search_results.dart            -> Page displaying results of searching songs
│   │       search_screen.dart             -> Page prompting user to search for a song
│   │       song_view.dart                 -> Page displaying selected song and recommendations
│   │       undefined_view.dart            -> Page to redirect to when URL is unknown, similar to 404 page.
│   │       user_profile.dart              -> Page with User's stats
│   │
│   ├───routing                      -> [DIR] contains everything related to routing with URLs
│   │       router.dart              -> Contains functions to route user to pages appropriately
│   │       route_names.dart         -> Contains constants to implement named routing done by router.dart
│   │
│   ├───themes                       -> [DIR] to store various themes of the app
│   │       maintheme.dart           -> applies the primary themes of the app
│   │
│   └───widgets                                      -> [DIR] contains standalone widgets that will be embedded onto pages
│       │   custom_list_tiles.dart                   -> custom-made ListTile widget to create larger sized tiles
│       │
│       ├───profile_widgets                          -> [DIR] contains all widgets related to UserProfile page
│       │   │   headings.dart                        -> Widget creates headings in the UserProfile page
│       │   │   profile_header.dart                  -> Displays user details in UserProfile page
│       │   │   top_artists.dart                     -> Displays top artists the user listens to                                    
│       │   │   top_tracks.dart                      -> Displays top tracks the user listens to
│       │   │
│       │   └───cards                                -> [DIR] contains all Card widgets
│       │           analysis_card.dart               -> Displays User's Listening Analysis
│       │           by_duration_card.dart            -> Displays Tracks by duration
│       │           by_popularity_card.dart          -> Displays Tracks by popularity
│       │           by_release_date_card.dart        -> Displays Tracks by release date
│       │
│       └───song_view_widgets                        -> [DIR] contains widgets of SongView
│               recommendations_list.dart            -> Displays list of recommendations
│               song_header.dart                     -> Displays enlarged header containing song details
```
