Starcounter
HomeDownloadDocsCommunity
2.3.2
2.3.2
  • Starcounter Documentation
  • Getting Started
  • Starcounter
    • Collapsing the Stack
      • Complexity and Scalability Tradeoff
      • The Future of Micro-Services
      • 10 Benefits of Collapsing the Stack
    • Integrated Database and Web Server
  • Hello World - Tutorial
    • Create a Database Class
    • Create a Real Time UI
    • First Interactive UI
    • Computed Properties
    • Expense Tracker
    • Cancel and Delete
    • The Next Step
  • Guides
    • Database
      • Database Classes
      • Data manipulation
      • Object Identity and Object References
      • Querying with SQL
      • Data Types
      • Relations
      • Inheritance
      • Sharing data
      • Database Configuration
      • Comparing Database Objects
      • Referential Integrity and Constraints
    • SQL
      • Identifiers
      • Path Expressions
      • Data operators
      • Joins
      • Aggregates
      • Comparisons and Logical Operators
      • Sorting
      • Fetch
      • Offset Key
      • Indexes
      • Literals
      • Query Plan Hints
      • Reserved words
      • Query for Database Classes
      • SQL Isolation Between Applications
    • Transactions
      • Short-Running Transactions
      • Long running transactions
      • Using Transactions
      • Running Background Jobs
      • Commit Hooks
      • Post-commit hooks
    • Typed JSON
      • JSON-by-example
      • Code-Behind
      • Data Bindings
      • Callback Methods
      • Responding with JSON
      • Accepting JSON in Requests
      • Primitive Arrays and Single Value Types
      • Typed JSON Internals
    • Blendable Web Apps
      • Starcounter MVVM
      • Palindrom
      • Client-Side Stack
      • Sessions
      • HTML Views
      • App Shell
      • Web Components
      • View Attaching
      • View Composing
      • HTML Compositions
      • HTML Views Blending Guidelines
      • Avoiding CSS conflicts
      • Debugging
    • Network
      • HTTP
      • Internal Self Calls
      • Middleware
      • Anonymous or Substitute Handlers
      • URL Aliases and Redirects
      • Network Gateway
      • Static File Server
      • WebSocket
      • Avoiding URI conflicts
      • TCP Sockets
      • UDP Sockets
    • Publishing Apps
    • Working with Starcounter
      • Release Channels
      • Installation
      • Starting and Stopping Apps
      • Administrator Web UI
      • Star CLI
      • StarAdmin CLI
      • StarDump CLI
      • Working in Visual Studio
      • Error Log
      • Using HTTPS on NGINX
      • Using HTTPS on IIS
      • Run Starcounter in Production
      • Weaver
      • Investigating App Crashes
      • Configuration Structure
      • Database Refactoring
      • Using Unload/Reload to Modify Database Schema
      • Kernel Questions and Answers
      • Log Files
  • Cookbook
    • Attach an HTTP Request to an Existing Long-Running Transaction
    • Cookie-Based Authentication
    • Timestamp on Object Creation
    • Creating Strongly Typed JSON Collections
    • Migrating From 2.2 to 2.3+
    • Multiple Pages
    • Icons
    • Proposed Project Structure
    • Acceptance Testing with Selenium
    • Requesting a User to Authenticate
    • How to delete unused tables and columns
Powered by GitBook
On this page
  • Namespaces
  • C# files & Classes
  • Html Page Files
  • Custom Elements
  • JavaScript Libraries
  • Startup Program.cs Class
  • Visual Studio Files
  1. Cookbook

Proposed Project Structure

PreviousIconsNextAcceptance Testing with Selenium

Last updated 7 years ago

The Starcounter app project structure is inspired by . The difference is that ASP.NET has Controllers, Models, Scripts, and Views while Starcounter has Api handlers, JSON + HTML viewmodels and database classes.

This tree displays the structure of a Starcounter project:

Namespaces

Api, Database, Helpers, and ViewModels folders may or may not have their own namespace.

A json view model class would look like this:

using Starcounter;

namespace StarcounterSample 
{
    public class MainPage : Json 
    {
    }
}

A helper file inside Helpers folder would look like this:

namespace StarcounterSample 
{
    public class StringsHelper 
    {
    }
}

A handler file inside Api folder would look like this:

using Starcounter;

namespace StarcounterSample 
{
    public class MainHandlers 
    {
        public void Register() 
        {
            Handle.GET("/StarcounterSample", () => new MainPage());
        }
    }
}

Custom sub-folders and sub-namespaces could be used if needed.

A view page inside sub-folder: StarcounterSample/ViewModels/Launcher/AppMenuPage.json.

using Starcounter;

namespace StarcounterSample.Launcher 
{
    public class AppMenuPage: Json 
    {
    }
}

C# files & Classes

Name of .cs and .json files should be exactly the same as classes inside. Name of .json and .json.cs files should also match.

The correct structure for sign in page would be like this:

  • ViewModels/SignInPage.json

  • ViewModels/SignInPage.json.cs

  • class SignInPage : Json

Html Page Files

Html files which represent a json view model like SignInPage.Html should be named exactly the same as name of json file.

This is correct:

{
    "Html": "/GoogleSignIn/views/SignInPage.html"
}

And these are incorrect:

{
    "Html": "/GoogleSignIn/views/signinpage.html"
}
{
    "Html": "/GoogleSignIn/views/sign-in-page.html"
}

Custom Elements

The html files which do not represent any of json page should be stored inside elements folder. The name of a file should be exactly the same as name of the element inside.

JavaScript Libraries

Most of the Starcounter applications do not use custom JavaScript libraries outside of WebComponents. If you need a custom JavaScript library then it should be scoped to your application and saved inside a js folder.

Startup Program.cs Class

  • In small applicaions, the startup class may register handlers and make some preparations.

  • In big applications, the startup class should be minified and only call Register method of /Api/ classes.

Visual Studio Files

Visual Studio solution (sln) and project (csproj, kproj) files should be checked in to the version control system.

User preference files (suo), which carry information about unloaded projects in a solution or breakpoints in a project, should not be checked in to the version control system.

the structure of ASP.NET 5 projects