There are many structures (algebras, categories, etc) with natural gradings such that the degree 0 components are not semisimple. Particular examples include tensor algebras with non-semisimple degree 0 parts, extension algebras of standard modules of standardly stratified algebras. In this thesis we develop a generalized Koszul theory for graded algebras (categories) whose degree 0 parts may be non-semisimple. Under some extra assumption, we show that this generalized Koszul theory preserves many classical results such as the Koszul duality. Moreover, it has some close relation to the classical theory. Applications of this generalized theory to finite EI categories, directed categories, and extension algebras of standard modules of standardly stratified algebras are described. We also study the stratification property of standardly stratified algebras, and classify algebras standardly (resp., properly) stratified for all linear orders.